From 6914c2958f12ed553cfcf4d0c11ff8027d15005a Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 12 Jun 2024 09:28:24 -0600 Subject: [PATCH 1/6] test: Merge common redactions --- crates/cargo-test-support/src/compare.rs | 55 ++++++++---------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index 8f7a510ebef..c877c237880 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -77,37 +77,8 @@ use url::Url; /// a problem. /// - Carriage returns are removed, which can help when running on Windows. pub fn assert_ui() -> snapbox::Assert { - let root = paths::root(); - // Use `from_file_path` instead of `from_dir_path` so the trailing slash is - // put in the users output, rather than hidden in the variable - let root_url = url::Url::from_file_path(&root).unwrap().to_string(); - let mut subs = snapbox::Redactions::new(); - subs.extend(MIN_LITERAL_REDACTIONS.into_iter().cloned()) - .unwrap(); - subs.insert("[ROOT]", root).unwrap(); - subs.insert("[ROOTURL]", root_url).unwrap(); - subs.insert( - "[ELAPSED]", - regex::Regex::new("Finished.*in (?[0-9]+(\\.[0-9]+))s").unwrap(), - ) - .unwrap(); - // output from libtest - subs.insert( - "[ELAPSED]", - regex::Regex::new("; finished in (?[0-9]+(\\.[0-9]+))s").unwrap(), - ) - .unwrap(); - subs.insert( - "[FILE_SIZE]", - regex::Regex::new("(?[0-9]+(\\.[0-9]+)([a-zA-Z]i)?)B").unwrap(), - ) - .unwrap(); - subs.insert( - "[HASH]", - regex::Regex::new("home/\\.cargo/registry/src/-(?[a-z0-9]+)").unwrap(), - ) - .unwrap(); + add_common_redactions(&mut subs); snapbox::Assert::new() .action_env(snapbox::assert::DEFAULT_ACTION_ENV) .redact_with(subs) @@ -145,23 +116,38 @@ pub fn assert_ui() -> snapbox::Assert { /// a problem. /// - Carriage returns are removed, which can help when running on Windows. pub fn assert_e2e() -> snapbox::Assert { + let mut subs = snapbox::Redactions::new(); + add_common_redactions(&mut subs); + subs.extend(E2E_LITERAL_REDACTIONS.into_iter().cloned()) + .unwrap(); + + snapbox::Assert::new() + .action_env(snapbox::assert::DEFAULT_ACTION_ENV) + .redact_with(subs) +} + +fn add_common_redactions(subs: &mut snapbox::Redactions) { let root = paths::root(); // Use `from_file_path` instead of `from_dir_path` so the trailing slash is // put in the users output, rather than hidden in the variable let root_url = url::Url::from_file_path(&root).unwrap().to_string(); - let mut subs = snapbox::Redactions::new(); subs.extend(MIN_LITERAL_REDACTIONS.into_iter().cloned()) .unwrap(); - subs.extend(E2E_LITERAL_REDACTIONS.into_iter().cloned()) - .unwrap(); subs.insert("[ROOT]", root).unwrap(); subs.insert("[ROOTURL]", root_url).unwrap(); + // For e2e tests subs.insert( "[ELAPSED]", regex::Regex::new("[FINISHED].*in (?[0-9]+(\\.[0-9]+))s").unwrap(), ) .unwrap(); + // for UI tests + subs.insert( + "[ELAPSED]", + regex::Regex::new("Finished.*in (?[0-9]+(\\.[0-9]+))s").unwrap(), + ) + .unwrap(); // output from libtest subs.insert( "[ELAPSED]", @@ -178,9 +164,6 @@ pub fn assert_e2e() -> snapbox::Assert { regex::Regex::new("home/\\.cargo/registry/src/-(?[a-z0-9]+)").unwrap(), ) .unwrap(); - snapbox::Assert::new() - .action_env(snapbox::assert::DEFAULT_ACTION_ENV) - .redact_with(subs) } static MIN_LITERAL_REDACTIONS: &[(&str, &str)] = &[ From d7de93777df03d9097382732799e50dc92597f0d Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 12 Jun 2024 13:26:54 -0600 Subject: [PATCH 2/6] test: Only compile regex replacements once --- crates/cargo-test-support/src/compare.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index c877c237880..2b8ff29dfbf 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -45,6 +45,15 @@ use std::path::Path; use std::str; use url::Url; +/// This makes it easier to write regex replacements that are guaranteed to only +/// get compiled once +macro_rules! regex { + ($re:literal $(,)?) => {{ + static RE: std::sync::OnceLock = std::sync::OnceLock::new(); + RE.get_or_init(|| regex::Regex::new($re).unwrap()) + }}; +} + /// Assertion policy for UI tests /// /// This emphasizes showing as much content as possible at the cost of more brittleness @@ -139,29 +148,29 @@ fn add_common_redactions(subs: &mut snapbox::Redactions) { // For e2e tests subs.insert( "[ELAPSED]", - regex::Regex::new("[FINISHED].*in (?[0-9]+(\\.[0-9]+))s").unwrap(), + regex!("[FINISHED].*in (?[0-9]+(\\.[0-9]+))s"), ) .unwrap(); // for UI tests subs.insert( "[ELAPSED]", - regex::Regex::new("Finished.*in (?[0-9]+(\\.[0-9]+))s").unwrap(), + regex!("Finished.*in (?[0-9]+(\\.[0-9]+))s"), ) .unwrap(); // output from libtest subs.insert( "[ELAPSED]", - regex::Regex::new("; finished in (?[0-9]+(\\.[0-9]+))s").unwrap(), + regex!("; finished in (?[0-9]+(\\.[0-9]+))s"), ) .unwrap(); subs.insert( "[FILE_SIZE]", - regex::Regex::new("(?[0-9]+(\\.[0-9]+)([a-zA-Z]i)?)B").unwrap(), + regex!("(?[0-9]+(\\.[0-9]+)([a-zA-Z]i)?)B"), ) .unwrap(); subs.insert( "[HASH]", - regex::Regex::new("home/\\.cargo/registry/src/-(?[a-z0-9]+)").unwrap(), + regex!("home/\\.cargo/registry/src/-(?[a-z0-9]+)"), ) .unwrap(); } From 6a7b15a61e2d332c7a7ab80835401cd425296581 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Mon, 10 Jun 2024 10:07:48 -0600 Subject: [PATCH 3/6] test: Auto-redact host target and alt target --- crates/cargo-test-support/src/compare.rs | 7 ++++++- crates/cargo-test-support/src/cross_compile.rs | 17 +++++++++++------ tests/testsuite/cargo_add/target/mod.rs | 2 +- tests/testsuite/cargo_add/target/out/Cargo.toml | 2 +- .../testsuite/cargo_add/target/stderr.term.svg | 4 ++-- .../cargo_remove/invalid_target/out/Cargo.toml | 6 +++--- .../cargo_remove/invalid_target/stderr.term.svg | 2 +- .../cargo_remove/invalid_target_dep/mod.rs | 2 +- .../invalid_target_dep/out/Cargo.toml | 6 +++--- .../invalid_target_dep/stderr.term.svg | 4 ++-- .../cargo_remove/remove-target.in/Cargo.toml | 6 +++--- tests/testsuite/cargo_remove/target/mod.rs | 2 +- .../cargo_remove/target/out/Cargo.toml | 4 ++-- .../cargo_remove/target/stderr.term.svg | 2 +- .../testsuite/cargo_remove/target_build/mod.rs | 2 +- .../cargo_remove/target_build/out/Cargo.toml | 4 ++-- .../cargo_remove/target_build/stderr.term.svg | 2 +- tests/testsuite/cargo_remove/target_dev/mod.rs | 2 +- .../cargo_remove/target_dev/out/Cargo.toml | 4 ++-- .../cargo_remove/target_dev/stderr.term.svg | 2 +- 20 files changed, 46 insertions(+), 36 deletions(-) diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index 2b8ff29dfbf..af988395294 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -36,8 +36,9 @@ //! a problem. //! - Carriage returns are removed, which can help when running on Windows. -use crate::diff; +use crate::cross_compile::try_alternate; use crate::paths; +use crate::{diff, rustc_host}; use anyhow::{bail, Context, Result}; use serde_json::Value; use std::fmt; @@ -173,6 +174,10 @@ fn add_common_redactions(subs: &mut snapbox::Redactions) { regex!("home/\\.cargo/registry/src/-(?[a-z0-9]+)"), ) .unwrap(); + subs.insert("[HOST_TARGET]", rustc_host()).unwrap(); + if let Some(alt_target) = try_alternate() { + subs.insert("[ALT_TARGET]", alt_target).unwrap(); + } } static MIN_LITERAL_REDACTIONS: &[(&str, &str)] = &[ diff --git a/crates/cargo-test-support/src/cross_compile.rs b/crates/cargo-test-support/src/cross_compile.rs index a2daf882d9d..beda6616550 100644 --- a/crates/cargo-test-support/src/cross_compile.rs +++ b/crates/cargo-test-support/src/cross_compile.rs @@ -209,18 +209,23 @@ pub fn native_arch() -> &'static str { /// /// Only use this function on tests that check `cross_compile::disabled`. pub fn alternate() -> &'static str { + try_alternate().expect("This test should be gated on cross_compile::disabled.") +} + +/// A possible alternate target-triple to build with. +pub(crate) fn try_alternate() -> Option<&'static str> { if cfg!(all(target_os = "macos", target_arch = "aarch64")) { - "x86_64-apple-darwin" + Some("x86_64-apple-darwin") } else if cfg!(target_os = "macos") { - "x86_64-apple-ios" + Some("x86_64-apple-ios") } else if cfg!(target_os = "linux") { - "i686-unknown-linux-gnu" + Some("i686-unknown-linux-gnu") } else if cfg!(all(target_os = "windows", target_env = "msvc")) { - "i686-pc-windows-msvc" + Some("i686-pc-windows-msvc") } else if cfg!(all(target_os = "windows", target_env = "gnu")) { - "i686-pc-windows-gnu" + Some("i686-pc-windows-gnu") } else { - panic!("This test should be gated on cross_compile::disabled."); + None } } diff --git a/tests/testsuite/cargo_add/target/mod.rs b/tests/testsuite/cargo_add/target/mod.rs index ca7fa309170..57618e0f8c6 100644 --- a/tests/testsuite/cargo_add/target/mod.rs +++ b/tests/testsuite/cargo_add/target/mod.rs @@ -28,7 +28,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("add") - .arg_line("my-package1 my-package2 --target i686-unknown-linux-gnu") + .arg_line("my-package1 my-package2 --target wasm32-unknown-unknown") .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_add/target/out/Cargo.toml b/tests/testsuite/cargo_add/target/out/Cargo.toml index 384def08952..5f36855687f 100644 --- a/tests/testsuite/cargo_add/target/out/Cargo.toml +++ b/tests/testsuite/cargo_add/target/out/Cargo.toml @@ -5,6 +5,6 @@ name = "cargo-list-test-fixture" version = "0.0.0" edition = "2015" -[target.i686-unknown-linux-gnu.dependencies] +[target.wasm32-unknown-unknown.dependencies] my-package1 = "99999.0.0" my-package2 = "99999.0.0" diff --git a/tests/testsuite/cargo_add/target/stderr.term.svg b/tests/testsuite/cargo_add/target/stderr.term.svg index 0f1818707cb..8d97e11aee5 100644 --- a/tests/testsuite/cargo_add/target/stderr.term.svg +++ b/tests/testsuite/cargo_add/target/stderr.term.svg @@ -20,9 +20,9 @@ Updating `dummy-registry` index - Adding my-package1 v99999.0.0 to dependencies for target `i686-unknown-linux-gnu` + Adding my-package1 v99999.0.0 to dependencies for target `wasm32-unknown-unknown` - Adding my-package2 v99999.0.0 to dependencies for target `i686-unknown-linux-gnu` + Adding my-package2 v99999.0.0 to dependencies for target `wasm32-unknown-unknown` Locking 3 packages to latest compatible versions diff --git a/tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml index 6ae66d52f8f..45a3885cf0b 100644 --- a/tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml +++ b/tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml @@ -10,7 +10,7 @@ path = "src/main.rs" [target.x86_64-unknown-freebsd.build-dependencies] semver = "0.1.0" -[target.x86_64-unknown-linux-gnu.build-dependencies] +[target.wasm32-unknown-unknown.build-dependencies] semver = "0.1.0" [dependencies] @@ -20,14 +20,14 @@ semver = "0.1" toml = "0.1" clippy = "0.4" -[target.x86_64-unknown-linux-gnu.dependencies] +[target.wasm32-unknown-unknown.dependencies] dbus = "0.6.2" [dev-dependencies] regex = "0.1.1" serde = "1.0.90" -[target.x86_64-unknown-linux-gnu.dev-dependencies] +[target.wasm32-unknown-unknown.dev-dependencies] ncurses = "20.0" [features] diff --git a/tests/testsuite/cargo_remove/invalid_target/stderr.term.svg b/tests/testsuite/cargo_remove/invalid_target/stderr.term.svg index c3383ff1b90..e1290e530ee 100644 --- a/tests/testsuite/cargo_remove/invalid_target/stderr.term.svg +++ b/tests/testsuite/cargo_remove/invalid_target/stderr.term.svg @@ -21,7 +21,7 @@ Removing dbus from dependencies for target `powerpc-unknown-linux-gnu` - error: the dependency `dbus` could not be found in `target.powerpc-unknown-linux-gnu.dependencies`; it is present in `target.x86_64-unknown-linux-gnu.dependencies` + error: the dependency `dbus` could not be found in `target.powerpc-unknown-linux-gnu.dependencies`; it is present in `target.wasm32-unknown-unknown.dependencies` diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs b/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs index de2db154295..123787f79d2 100644 --- a/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs +++ b/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs @@ -28,7 +28,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("remove") - .args(["--target", "x86_64-unknown-linux-gnu", "toml"]) + .args(["--target", "wasm32-unknown-unknown", "toml"]) .current_dir(cwd) .assert() .code(101) diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml index 6ae66d52f8f..45a3885cf0b 100644 --- a/tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml +++ b/tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml @@ -10,7 +10,7 @@ path = "src/main.rs" [target.x86_64-unknown-freebsd.build-dependencies] semver = "0.1.0" -[target.x86_64-unknown-linux-gnu.build-dependencies] +[target.wasm32-unknown-unknown.build-dependencies] semver = "0.1.0" [dependencies] @@ -20,14 +20,14 @@ semver = "0.1" toml = "0.1" clippy = "0.4" -[target.x86_64-unknown-linux-gnu.dependencies] +[target.wasm32-unknown-unknown.dependencies] dbus = "0.6.2" [dev-dependencies] regex = "0.1.1" serde = "1.0.90" -[target.x86_64-unknown-linux-gnu.dev-dependencies] +[target.wasm32-unknown-unknown.dev-dependencies] ncurses = "20.0" [features] diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/stderr.term.svg b/tests/testsuite/cargo_remove/invalid_target_dep/stderr.term.svg index 1613c71bcc5..93230d4f6fd 100644 --- a/tests/testsuite/cargo_remove/invalid_target_dep/stderr.term.svg +++ b/tests/testsuite/cargo_remove/invalid_target_dep/stderr.term.svg @@ -19,9 +19,9 @@ - Removing toml from dependencies for target `x86_64-unknown-linux-gnu` + Removing toml from dependencies for target `wasm32-unknown-unknown` - error: the dependency `toml` could not be found in `target.x86_64-unknown-linux-gnu.dependencies`; it is present in `dependencies` + error: the dependency `toml` could not be found in `target.wasm32-unknown-unknown.dependencies`; it is present in `dependencies` diff --git a/tests/testsuite/cargo_remove/remove-target.in/Cargo.toml b/tests/testsuite/cargo_remove/remove-target.in/Cargo.toml index 6ae66d52f8f..45a3885cf0b 100644 --- a/tests/testsuite/cargo_remove/remove-target.in/Cargo.toml +++ b/tests/testsuite/cargo_remove/remove-target.in/Cargo.toml @@ -10,7 +10,7 @@ path = "src/main.rs" [target.x86_64-unknown-freebsd.build-dependencies] semver = "0.1.0" -[target.x86_64-unknown-linux-gnu.build-dependencies] +[target.wasm32-unknown-unknown.build-dependencies] semver = "0.1.0" [dependencies] @@ -20,14 +20,14 @@ semver = "0.1" toml = "0.1" clippy = "0.4" -[target.x86_64-unknown-linux-gnu.dependencies] +[target.wasm32-unknown-unknown.dependencies] dbus = "0.6.2" [dev-dependencies] regex = "0.1.1" serde = "1.0.90" -[target.x86_64-unknown-linux-gnu.dev-dependencies] +[target.wasm32-unknown-unknown.dev-dependencies] ncurses = "20.0" [features] diff --git a/tests/testsuite/cargo_remove/target/mod.rs b/tests/testsuite/cargo_remove/target/mod.rs index 264b9ddb8aa..e24b5043402 100644 --- a/tests/testsuite/cargo_remove/target/mod.rs +++ b/tests/testsuite/cargo_remove/target/mod.rs @@ -28,7 +28,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("remove") - .args(["--target", "x86_64-unknown-linux-gnu", "dbus"]) + .args(["--target", "wasm32-unknown-unknown", "dbus"]) .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_remove/target/out/Cargo.toml b/tests/testsuite/cargo_remove/target/out/Cargo.toml index aef5eef333d..0eb8fca0a84 100644 --- a/tests/testsuite/cargo_remove/target/out/Cargo.toml +++ b/tests/testsuite/cargo_remove/target/out/Cargo.toml @@ -10,7 +10,7 @@ path = "src/main.rs" [target.x86_64-unknown-freebsd.build-dependencies] semver = "0.1.0" -[target.x86_64-unknown-linux-gnu.build-dependencies] +[target.wasm32-unknown-unknown.build-dependencies] semver = "0.1.0" [dependencies] @@ -24,7 +24,7 @@ clippy = "0.4" regex = "0.1.1" serde = "1.0.90" -[target.x86_64-unknown-linux-gnu.dev-dependencies] +[target.wasm32-unknown-unknown.dev-dependencies] ncurses = "20.0" [features] diff --git a/tests/testsuite/cargo_remove/target/stderr.term.svg b/tests/testsuite/cargo_remove/target/stderr.term.svg index 41fbebd6b25..3fa32c2bb48 100644 --- a/tests/testsuite/cargo_remove/target/stderr.term.svg +++ b/tests/testsuite/cargo_remove/target/stderr.term.svg @@ -18,7 +18,7 @@ - Removing dbus from dependencies for target `x86_64-unknown-linux-gnu` + Removing dbus from dependencies for target `wasm32-unknown-unknown` diff --git a/tests/testsuite/cargo_remove/target_build/mod.rs b/tests/testsuite/cargo_remove/target_build/mod.rs index 11997bfdc64..2c1c8f2d1a6 100644 --- a/tests/testsuite/cargo_remove/target_build/mod.rs +++ b/tests/testsuite/cargo_remove/target_build/mod.rs @@ -28,7 +28,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("remove") - .args(["--build", "--target", "x86_64-unknown-linux-gnu", "semver"]) + .args(["--build", "--target", "wasm32-unknown-unknown", "semver"]) .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_remove/target_build/out/Cargo.toml b/tests/testsuite/cargo_remove/target_build/out/Cargo.toml index 6b337d836de..b0af7ac0049 100644 --- a/tests/testsuite/cargo_remove/target_build/out/Cargo.toml +++ b/tests/testsuite/cargo_remove/target_build/out/Cargo.toml @@ -17,14 +17,14 @@ semver = "0.1" toml = "0.1" clippy = "0.4" -[target.x86_64-unknown-linux-gnu.dependencies] +[target.wasm32-unknown-unknown.dependencies] dbus = "0.6.2" [dev-dependencies] regex = "0.1.1" serde = "1.0.90" -[target.x86_64-unknown-linux-gnu.dev-dependencies] +[target.wasm32-unknown-unknown.dev-dependencies] ncurses = "20.0" [features] diff --git a/tests/testsuite/cargo_remove/target_build/stderr.term.svg b/tests/testsuite/cargo_remove/target_build/stderr.term.svg index 9b4a6a5a588..c795f2c3d8c 100644 --- a/tests/testsuite/cargo_remove/target_build/stderr.term.svg +++ b/tests/testsuite/cargo_remove/target_build/stderr.term.svg @@ -18,7 +18,7 @@ - Removing semver from build-dependencies for target `x86_64-unknown-linux-gnu` + Removing semver from build-dependencies for target `wasm32-unknown-unknown` diff --git a/tests/testsuite/cargo_remove/target_dev/mod.rs b/tests/testsuite/cargo_remove/target_dev/mod.rs index 2a5f0babda1..fc75871f2bc 100644 --- a/tests/testsuite/cargo_remove/target_dev/mod.rs +++ b/tests/testsuite/cargo_remove/target_dev/mod.rs @@ -28,7 +28,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("remove") - .args(["--dev", "--target", "x86_64-unknown-linux-gnu", "ncurses"]) + .args(["--dev", "--target", "wasm32-unknown-unknown", "ncurses"]) .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_remove/target_dev/out/Cargo.toml b/tests/testsuite/cargo_remove/target_dev/out/Cargo.toml index 8c7a5c947c3..b0c66ef6c4f 100644 --- a/tests/testsuite/cargo_remove/target_dev/out/Cargo.toml +++ b/tests/testsuite/cargo_remove/target_dev/out/Cargo.toml @@ -10,7 +10,7 @@ path = "src/main.rs" [target.x86_64-unknown-freebsd.build-dependencies] semver = "0.1.0" -[target.x86_64-unknown-linux-gnu.build-dependencies] +[target.wasm32-unknown-unknown.build-dependencies] semver = "0.1.0" [dependencies] @@ -20,7 +20,7 @@ semver = "0.1" toml = "0.1" clippy = "0.4" -[target.x86_64-unknown-linux-gnu.dependencies] +[target.wasm32-unknown-unknown.dependencies] dbus = "0.6.2" [dev-dependencies] diff --git a/tests/testsuite/cargo_remove/target_dev/stderr.term.svg b/tests/testsuite/cargo_remove/target_dev/stderr.term.svg index f42b56e24ef..a39f6919381 100644 --- a/tests/testsuite/cargo_remove/target_dev/stderr.term.svg +++ b/tests/testsuite/cargo_remove/target_dev/stderr.term.svg @@ -18,7 +18,7 @@ - Removing ncurses from dev-dependencies for target `x86_64-unknown-linux-gnu` + Removing ncurses from dev-dependencies for target `wasm32-unknown-unknown` From 02459b707fcd638f3319f975ab98566df2b64382 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Mon, 10 Jun 2024 12:21:06 -0600 Subject: [PATCH 4/6] test: Auto-redact bench timing results --- crates/cargo-test-support/src/compare.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index af988395294..1ccea27d666 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -178,6 +178,16 @@ fn add_common_redactions(subs: &mut snapbox::Redactions) { if let Some(alt_target) = try_alternate() { subs.insert("[ALT_TARGET]", alt_target).unwrap(); } + subs.insert( + "[AVG_ELAPSED]", + regex!("(?[0-9]+(\\.[0-9]+)?) ns/iter"), + ) + .unwrap(); + subs.insert( + "[JITTER]", + regex!("ns/iter \\(\\+/- (?[0-9]+(\\.[0-9]+)?)\\)"), + ) + .unwrap(); } static MIN_LITERAL_REDACTIONS: &[(&str, &str)] = &[ From 875a25fba71eadf92b80481ea21de0d6db7dfcd6 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 12 Jun 2024 09:18:14 -0600 Subject: [PATCH 5/6] test: Auto-redact exit status --- crates/cargo-test-support/src/compare.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index 1ccea27d666..b155c1dff78 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -194,6 +194,10 @@ static MIN_LITERAL_REDACTIONS: &[(&str, &str)] = &[ ("[EXE]", std::env::consts::EXE_SUFFIX), ("[BROKEN_PIPE]", "Broken pipe (os error 32)"), ("[BROKEN_PIPE]", "The pipe is being closed. (os error 232)"), + // Unix message for exit status + ("[EXIT_STATUS]", "exit status"), + // Windows message for exit status + ("[EXIT_STATUS]", "exit code"), ]; static E2E_LITERAL_REDACTIONS: &[(&str, &str)] = &[ ("[RUNNING]", " Running"), From 190ef86d0694fca3829a7d63a8b0063fa2033fda Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 12 Jun 2024 09:34:24 -0600 Subject: [PATCH 6/6] test: Auto-redact file hash --- crates/cargo-test-support/src/compare.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index b155c1dff78..9a7f93bc557 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -174,6 +174,8 @@ fn add_common_redactions(subs: &mut snapbox::Redactions) { regex!("home/\\.cargo/registry/src/-(?[a-z0-9]+)"), ) .unwrap(); + subs.insert("[HASH]", regex!("/[a-z0-9\\-_]+-(?[0-9a-f]{16})")) + .unwrap(); subs.insert("[HOST_TARGET]", rustc_host()).unwrap(); if let Some(alt_target) = try_alternate() { subs.insert("[ALT_TARGET]", alt_target).unwrap();