Skip to content

Commit f236982

Browse files
authored
Unrolled build for rust-lang#129185
Rollup merge of rust-lang#129185 - Zalathar:validate-json, r=jieyouxu Port `run-make/libtest-json/validate_json.py` to Rust This is a trivial Python script that simply tries to parse each line of stdin (i.e. the test process output) as JSON, to verify that the overall output is JSON Lines. We can perform the same check directly in `rmake.rs` using `serde_json`. r? ````@jieyouxu````
2 parents 79f5c16 + 3116db6 commit f236982

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

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

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@ ignore-cross-compile
44
//@ needs-unwind (test file contains #[should_panic] test)
55

6-
use run_make_support::{cmd, diff, python_command, rustc};
6+
use run_make_support::{cmd, diff, rustc, serde_json};
77

88
fn main() {
99
rustc().arg("--test").input("f.rs").run();
@@ -21,7 +21,18 @@ fn run_tests(extra_args: &[&str], expected_file: &str) {
2121
.run_fail();
2222
let test_stdout = &cmd_out.stdout_utf8();
2323

24-
python_command().arg("validate_json.py").stdin(test_stdout).run();
24+
// Verify that the test process output is JSON Lines, i.e. each line is valid JSON.
25+
for (line, n) in test_stdout.lines().zip(1..) {
26+
if let Err(e) = serde_json::from_str::<serde_json::Value>(line) {
27+
panic!(
28+
"could not parse JSON on line {n}: {e}\n\
29+
\n\
30+
=== STDOUT ===\n\
31+
{test_stdout}\
32+
=============="
33+
);
34+
}
35+
}
2536

2637
diff()
2738
.expected_file(expected_file)

tests/run-make/libtest-json/validate_json.py

-8
This file was deleted.

0 commit comments

Comments
 (0)