From 96a5897e916da69c20e2de643176bfd0167f0de3 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 24 Jul 2024 16:34:22 -0500 Subject: [PATCH 1/2] test: Migrate another 'test' json test Rather than blocking on assert-rs/snapbox#351, we can get away with `--no-run` for what this test is covering. --- tests/testsuite/test.rs | 68 ++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 8a301fc02..f5df37964 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -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(); } From 922cfe575905427315cfe84ce91250787627e637 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 23 Jul 2024 16:23:43 -0500 Subject: [PATCH 2/2] fix(test): Remove unused deprecated function --- crates/cargo-test-support/src/lib.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index 73b4b0714..ac4e342da 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -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(&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.