Skip to content

Commit fcc742d

Browse files
authored
Unrolled build for rust-lang#129837
Rollup merge of rust-lang#129837 - aDotInTheVoid:test-better-json, r=jieyouxu Actually parse stdout json, instead of using hacky contains logic. Fixes up the test added in rust-lang#128963, to actually parse the stdout to JSON, instead of just checking that it contains `{"`. CC ``@GuillaumeGomez`` r? ``@jieyouxu``
2 parents 9b82580 + f78979e commit fcc742d

File tree

1 file changed

+15
-4
lines changed
  • tests/run-make/rustdoc-output-stdout

1 file changed

+15
-4
lines changed

tests/run-make/rustdoc-output-stdout/rmake.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@
44
use std::path::PathBuf;
55

66
use run_make_support::path_helpers::{cwd, has_extension, read_dir_entries_recursive};
7-
use run_make_support::rustdoc;
7+
use run_make_support::{rustdoc, serde_json};
88

99
fn main() {
10-
// First we check that we generate the JSON in the stdout.
11-
rustdoc()
10+
let json_string = rustdoc()
1211
.input("foo.rs")
1312
.out_dir("-")
1413
.arg("-Zunstable-options")
1514
.output_format("json")
1615
.run()
17-
.assert_stdout_contains("{\"");
16+
.stdout_utf8();
17+
18+
// First we check that we generate the JSON in the stdout.
19+
let json_value: serde_json::Value =
20+
serde_json::from_str(&json_string).expect("stdout should be valid json");
21+
22+
// We don't care to test the specifics of the JSON, as that's done
23+
// elsewhere, just check that it has a format_version (as all JSON output
24+
// should).
25+
let format_version = json_value["format_version"]
26+
.as_i64()
27+
.expect("json output should contain format_version field");
28+
assert!(format_version > 30);
1829

1930
// Then we check it didn't generate any JSON file.
2031
read_dir_entries_recursive(cwd(), |path| {

0 commit comments

Comments
 (0)