Auto merge of #14297 - epage:test-json, r=weihanglo

Misc test clean up

### What does this PR try to resolve?

Part of this is a follow up to #14293.

Part of this is a follow up to some of #14039's work.

### How should we test and review this PR?

### Additional information
This commit is contained in:
bors 2024-07-25 00:13:24 +00:00
commit 0d0bab6d9f
2 changed files with 36 additions and 43 deletions

View File

@ -747,17 +747,6 @@ impl Execs {
self self
} }
/// Verifies that stdout contains the given contiguous lines somewhere in
/// its output, and should be repeated `number` times.
///
/// See [`compare`] for supported patterns.
#[deprecated(note = "replaced with `Execs::with_stdout_data(expected)`")]
pub fn with_stdout_contains_n<S: ToString>(&mut self, expected: S, number: usize) -> &mut Self {
self.expect_stdout_contains_n
.push((expected.to_string(), number));
self
}
/// Verifies that stdout does not contain the given contiguous lines. /// Verifies that stdout does not contain the given contiguous lines.
/// ///
/// See [`compare`] for supported patterns. /// See [`compare`] for supported patterns.

View File

@ -4383,38 +4383,42 @@ fn json_artifact_includes_test_flag() {
.file("src/lib.rs", "") .file("src/lib.rs", "")
.build(); .build();
p.cargo("test --lib -v --message-format=json") p.cargo("test --lib -v --no-run --message-format=json")
.with_json( .with_stdout_data(
r#" str![[r#"
{ [
"reason":"compiler-artifact", {
"profile": { "executable": "[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]",
"debug_assertions": true, "features": [],
"debuginfo": 2, "filenames": "{...}",
"opt_level": "1", "fresh": false,
"overflow_checks": true, "manifest_path": "[ROOT]/foo/Cargo.toml",
"test": true "package_id": "path+[ROOTURL]/foo#0.0.1",
}, "profile": "{...}",
"executable": "[..]/foo-[..]", "reason": "compiler-artifact",
"features": [], "target": {
"package_id":"path+file:///[..]/foo#0.0.1", "crate_types": [
"manifest_path": "[..]", "lib"
"target":{ ],
"kind":["lib"], "doc": true,
"crate_types":["lib"], "doctest": true,
"doc": true, "edition": "2015",
"doctest": true, "kind": [
"edition": "2015", "lib"
"name":"foo", ],
"src_path":"[..]lib.rs", "name": "foo",
"test": true "src_path": "[ROOT]/foo/src/lib.rs",
}, "test": true
"filenames":"{...}", }
"fresh": false },
} {
"reason": "build-finished",
{"reason": "build-finished", "success": true} "success": true
"#, }
]
"#]]
.is_json()
.against_jsonlines(),
) )
.run(); .run();
} }