Skip to content

Commit f78979e

Browse files
committed
Actually parse stdout json, instead of using hacky contains logic.
1 parent d571ae8 commit f78979e

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)