Skip to content

Commit

Permalink
Auto merge of #14297 - epage:test-json, r=weihanglo
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jul 25, 2024
2 parents a7917fd + 922cfe5 commit 0d0bab6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 43 deletions.
11 changes: 0 additions & 11 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,17 +747,6 @@ impl Execs {
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.
///
/// See [`compare`] for supported patterns.
Expand Down
68 changes: 36 additions & 32 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4383,38 +4383,42 @@ fn json_artifact_includes_test_flag() {
.file("src/lib.rs", "")
.build();

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

0 comments on commit 0d0bab6

Please sign in to comment.