Skip to content

Commit c4aa7a7

Browse files
committed
Port run-make/libtest-json to rmake
1 parent 91376f4 commit c4aa7a7

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

Diff for: src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ run-make/incr-add-rust-src-component/Makefile
99
run-make/issue-84395-lto-embed-bitcode/Makefile
1010
run-make/jobserver-error/Makefile
1111
run-make/libs-through-symlinks/Makefile
12-
run-make/libtest-json/Makefile
1312
run-make/libtest-junit/Makefile
1413
run-make/libtest-thread-limit/Makefile
1514
run-make/macos-deployment-target/Makefile

Diff for: tests/run-make/libtest-json/Makefile

-20
This file was deleted.

Diff for: tests/run-make/libtest-json/output-default.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
{ "type": "test", "name": "c", "event": "ok" }
88
{ "type": "test", "event": "started", "name": "d" }
99
{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10-
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
10+
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": "$EXEC_TIME" }

Diff for: tests/run-make/libtest-json/output-stdout-success.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at f.rs:15:5:\nassertion failed: false\n" }
88
{ "type": "test", "event": "started", "name": "d" }
99
{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10-
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
10+
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": "$EXEC_TIME" }

Diff for: tests/run-make/libtest-json/rmake.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Check libtest's JSON output against snapshots.
2+
3+
//@ ignore-cross-compile
4+
//@ needs-unwind (test file contains #[should_panic] test)
5+
6+
use run_make_support::{cmd, diff, python_command, rustc};
7+
8+
fn main() {
9+
rustc().arg("--test").input("f.rs").run();
10+
11+
run_tests(&[], "output-default.json");
12+
run_tests(&["--show-output"], "output-stdout-success.json");
13+
}
14+
15+
#[track_caller]
16+
fn run_tests(extra_args: &[&str], expected_file: &str) {
17+
let cmd_out = cmd("./f")
18+
.env("RUST_BACKTRACE", "0")
19+
.args(&["-Zunstable-options", "--test-threads=1", "--format=json"])
20+
.args(extra_args)
21+
.run_fail();
22+
let test_stdout = &cmd_out.stdout_utf8();
23+
24+
python_command().arg("validate_json.py").stdin(test_stdout).run();
25+
26+
diff()
27+
.expected_file(expected_file)
28+
.actual_text("stdout", test_stdout)
29+
.normalize(r#"(?<prefix>"exec_time": )[0-9.]+"#, r#"${prefix}"$$EXEC_TIME""#)
30+
.run();
31+
}

0 commit comments

Comments
 (0)