Skip to content

Commit c2b6a7e

Browse files
Rollup merge of rust-lang#129037 - Zalathar:rmake-libtest, r=jieyouxu
Port `run-make/libtest-json` and `run-make/libtest-junit` to rmake Unlike rust-lang#126773, this is just a straightforward port to `rmake`, without attempting to switch to compiletest or get rid of the (trivial) Python scripts. Part of rust-lang#121876. r? ```@jieyouxu``` try-job: x86_64-msvc try-job: i686-mingw try-job: test-various try-job: aarch64-gnu try-job: aarch64-apple
2 parents 0188ec0 + fc733a6 commit c2b6a7e

File tree

7 files changed

+64
-44
lines changed

7 files changed

+64
-44
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +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
13-
run-make/libtest-junit/Makefile
1412
run-make/libtest-thread-limit/Makefile
1513
run-make/macos-deployment-target/Makefile
1614
run-make/reproducible-build/Makefile

tests/run-make/libtest-json/Makefile

-20
This file was deleted.

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" }

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" }

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+
}

tests/run-make/libtest-junit/Makefile

-20
This file was deleted.

tests/run-make/libtest-junit/rmake.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Check libtest's JUnit (XML) 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.xml");
12+
run_tests(&["--show-output"], "output-stdout-success.xml");
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=junit"])
20+
.args(extra_args)
21+
.run_fail();
22+
let test_stdout = &cmd_out.stdout_utf8();
23+
24+
python_command().arg("validate_junit.py").stdin(test_stdout).run();
25+
26+
diff()
27+
.expected_file(expected_file)
28+
.actual_text("stdout", test_stdout)
29+
.normalize(r#"\btime="[0-9.]+""#, r#"time="$$TIME""#)
30+
.run();
31+
}

0 commit comments

Comments
 (0)