Skip to content

Commit dc5ac62

Browse files
committed
fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would make it easier for people to discover what tasks remain and allow us to divide and conquer this work rather than doing a heroic PR. In theory, this will be short lived and we'll go back to seeing deprecations in our tests.
1 parent ff2ddeb commit dc5ac62

File tree

146 files changed

+301
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+301
-0
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,13 +559,15 @@ impl Execs {
559559

560560
/// Verifies that stdout is equal to the given lines.
561561
/// See [`compare`] for supported patterns.
562+
#[deprecated(note = "replaced with `Execs::with_stdout_data(expected)`")]
562563
pub fn with_stdout<S: ToString>(&mut self, expected: S) -> &mut Self {
563564
self.expect_stdout = Some(expected.to_string());
564565
self
565566
}
566567

567568
/// Verifies that stderr is equal to the given lines.
568569
/// See [`compare`] for supported patterns.
570+
#[deprecated(note = "replaced with `Execs::with_stderr_data(expected)`")]
569571
pub fn with_stderr<S: ToString>(&mut self, expected: S) -> &mut Self {
570572
self.expect_stderr = Some(expected.to_string());
571573
self
@@ -613,6 +615,7 @@ impl Execs {
613615
/// its output.
614616
///
615617
/// See [`compare`] for supported patterns.
618+
#[deprecated(note = "replaced with `Execs::with_stdout_data(expected)`")]
616619
pub fn with_stdout_contains<S: ToString>(&mut self, expected: S) -> &mut Self {
617620
self.expect_stdout_contains.push(expected.to_string());
618621
self
@@ -622,6 +625,7 @@ impl Execs {
622625
/// its output.
623626
///
624627
/// See [`compare`] for supported patterns.
628+
#[deprecated(note = "replaced with `Execs::with_stderr_data(expected)`")]
625629
pub fn with_stderr_contains<S: ToString>(&mut self, expected: S) -> &mut Self {
626630
self.expect_stderr_contains.push(expected.to_string());
627631
self
@@ -631,6 +635,7 @@ impl Execs {
631635
/// its output, and should be repeated `number` times.
632636
///
633637
/// See [`compare`] for supported patterns.
638+
#[deprecated(note = "replaced with `Execs::with_stdout_data(expected)`")]
634639
pub fn with_stdout_contains_n<S: ToString>(&mut self, expected: S, number: usize) -> &mut Self {
635640
self.expect_stdout_contains_n
636641
.push((expected.to_string(), number));
@@ -642,6 +647,7 @@ impl Execs {
642647
/// See [`compare`] for supported patterns.
643648
///
644649
/// See note on [`Self::with_stderr_does_not_contain`].
650+
#[deprecated]
645651
pub fn with_stdout_does_not_contain<S: ToString>(&mut self, expected: S) -> &mut Self {
646652
self.expect_stdout_not_contains.push(expected.to_string());
647653
self
@@ -656,6 +662,7 @@ impl Execs {
656662
/// your test will pass without verifying the correct behavior. If
657663
/// possible, write the test first so that it fails, and then implement
658664
/// your fix/feature to make it pass.
665+
#[deprecated]
659666
pub fn with_stderr_does_not_contain<S: ToString>(&mut self, expected: S) -> &mut Self {
660667
self.expect_stderr_not_contains.push(expected.to_string());
661668
self
@@ -665,6 +672,7 @@ impl Execs {
665672
/// ignoring the order of the lines.
666673
///
667674
/// See [`Execs::with_stderr_unordered`] for more details.
675+
#[deprecated(note = "replaced with `Execs::with_stdout_data(expected.unordered())`")]
668676
pub fn with_stdout_unordered<S: ToString>(&mut self, expected: S) -> &mut Self {
669677
self.expect_stdout_unordered.push(expected.to_string());
670678
self
@@ -691,6 +699,7 @@ impl Execs {
691699
///
692700
/// This will randomly fail if the other crate name is `bar`, and the
693701
/// order changes.
702+
#[deprecated(note = "replaced with `Execs::with_stderr_data(expected.unordered())`")]
694703
pub fn with_stderr_unordered<S: ToString>(&mut self, expected: S) -> &mut Self {
695704
self.expect_stderr_unordered.push(expected.to_string());
696705
self
@@ -718,6 +727,7 @@ impl Execs {
718727
///
719728
/// Be careful writing the `without` fragments, see note in
720729
/// `with_stderr_does_not_contain`.
730+
#[deprecated]
721731
pub fn with_stderr_line_without<S: ToString>(
722732
&mut self,
723733
with: &[S],
@@ -750,6 +760,7 @@ impl Execs {
750760
/// - The order of arrays is ignored.
751761
/// - Strings support patterns described in [`compare`].
752762
/// - Use `"{...}"` to match any object.
763+
#[deprecated(note = "replaced with `Execs::with_stdout_data(expected.json_lines())`")]
753764
pub fn with_json(&mut self, expected: &str) -> &mut Self {
754765
self.expect_json = Some(expected.to_string());
755766
self
@@ -764,6 +775,7 @@ impl Execs {
764775
/// what you are doing.
765776
///
766777
/// See `with_json` for more detail.
778+
#[deprecated]
767779
pub fn with_json_contains_unordered(&mut self, expected: &str) -> &mut Self {
768780
match &mut self.expect_json_contains_unordered {
769781
None => self.expect_json_contains_unordered = Some(expected.to_string()),

tests/build-std/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//! Otherwise the tests are skipped.
2020
2121
#![allow(clippy::disallowed_methods)]
22+
#![allow(deprecated)]
2223

2324
use cargo_test_support::*;
2425
use std::env;

tests/testsuite/advanced_env.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! -Zadvanced-env tests
22
3+
#![allow(deprecated)]
4+
35
use cargo_test_support::{paths, project, registry::Package};
46

57
#[cargo_test]

tests/testsuite/alt_registry.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Tests for alternative registries.
22
3+
#![allow(deprecated)]
4+
35
use cargo_test_support::compare::assert_e2e;
46
use cargo_test_support::publish::validate_alt_upload;
57
use cargo_test_support::registry::{self, Package, RegistryBuilder};

tests/testsuite/artifact_dep.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Tests specific to artifact dependencies, designated using
22
//! the new `dep = { artifact = "bin", … }` syntax in manifests.
33
4+
#![allow(deprecated)]
5+
46
use cargo_test_support::compare::assert_e2e;
57
use cargo_test_support::registry::{Package, RegistryBuilder};
68
use cargo_test_support::str;

tests/testsuite/artifact_dir.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Tests for --artifact-dir flag.
22
3+
#![allow(deprecated)]
4+
35
use cargo_test_support::sleep_ms;
46
use cargo_test_support::{basic_manifest, project};
57
use std::env;

tests/testsuite/bad_config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Tests for some invalid .cargo/config files.
22
3+
#![allow(deprecated)]
4+
35
use cargo_test_support::git::cargo_uses_gitoxide;
46
use cargo_test_support::registry::{self, Package};
57
use cargo_test_support::{basic_manifest, project, rustc_host};

tests/testsuite/bad_manifest_path.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Tests for invalid --manifest-path arguments.
22
3+
#![allow(deprecated)]
4+
35
use cargo_test_support::{basic_bin_manifest, main_file, project};
46

57
#[track_caller]

tests/testsuite/bench.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Tests for the `cargo bench` command.
22
3+
#![allow(deprecated)]
4+
35
use cargo_test_support::paths::CargoPathExt;
46
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project};
57

tests/testsuite/binary_name.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(deprecated)]
2+
13
use cargo_test_support::install::{
24
assert_has_installed_exe, assert_has_not_installed_exe, cargo_home,
35
};

0 commit comments

Comments
 (0)