Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port run-make/libtest-json/validate_json.py to Rust #129185

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tests/run-make/libtest-json/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//@ ignore-cross-compile
//@ needs-unwind (test file contains #[should_panic] test)

use run_make_support::{cmd, diff, python_command, rustc};
use run_make_support::{cmd, diff, rustc, serde_json};

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

python_command().arg("validate_json.py").stdin(test_stdout).run();
// Verify that the test process output is JSON Lines, i.e. each line is valid JSON.
for (line, n) in test_stdout.lines().zip(1..) {
if let Err(e) = serde_json::from_str::<serde_json::Value>(line) {
panic!(
"could not parse JSON on line {n}: {e}\n\
\n\
=== STDOUT ===\n\
{test_stdout}\
=============="
);
}
}

diff()
.expected_file(expected_file)
Expand Down
8 changes: 0 additions & 8 deletions tests/run-make/libtest-json/validate_json.py

This file was deleted.

Loading