diff --git a/crates/cargo-test-support/src/compare.rs b/crates/cargo-test-support/src/compare.rs index c2aa8f96927..53b752621de 100644 --- a/crates/cargo-test-support/src/compare.rs +++ b/crates/cargo-test-support/src/compare.rs @@ -405,7 +405,7 @@ pub(crate) fn match_unordered(expected: &str, actual: &str, cwd: Option<&Path>) /// somewhere. /// /// See [Patterns](index.html#patterns) for more information on pattern matching. -pub fn match_contains(expected: &str, actual: &str, cwd: Option<&Path>) -> Result<()> { +pub(crate) fn match_contains(expected: &str, actual: &str, cwd: Option<&Path>) -> Result<()> { let expected = normalize_expected(expected, cwd); let actual = normalize_actual(actual, cwd); let e: Vec<_> = expected.lines().map(|line| WildStr::new(line)).collect(); diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 6c81939836b..a2f2a7b021a 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -5,7 +5,6 @@ use std::io::prelude::*; use std::path::Path; use std::thread; -use cargo_test_support::compare; use cargo_test_support::compare::assert_e2e; use cargo_test_support::cross_compile; use cargo_test_support::git; @@ -2298,26 +2297,23 @@ fn failed_install_retains_temp_directory() { let err = cargo_process("install foo").exec_with_output().unwrap_err(); let err = err.downcast::().unwrap(); let stderr = String::from_utf8(err.stderr.unwrap()).unwrap(); - compare::match_contains( - "\ + assert_e2e().eq(&stderr, str![[r#" [UPDATING] `dummy-registry` index [DOWNLOADING] crates ... [DOWNLOADED] foo v0.0.1 (registry `dummy-registry`) [INSTALLING] foo v0.0.1 [COMPILING] foo v0.0.1 -", - &stderr, - None, - ) - .unwrap(); - compare::match_contains( - "error: failed to compile `foo v0.0.1`, intermediate artifacts can be found at \ - `[..]`.\nTo reuse those artifacts with a future compilation, set the environment \ - variable `CARGO_TARGET_DIR` to that path.", - &stderr, - None, - ) - .unwrap(); +[ERROR] expected one of `!` or `::`, found `` + --> [ROOT]/home/.cargo/registry/src/-[..]/foo-0.0.1/src/main.rs:1:1 + | +1 | x + | ^ expected one of `!` or `::` + +[ERROR] could not compile `foo` (bin "foo") due to 1 previous error +[ERROR] failed to compile `foo v0.0.1`, intermediate artifacts can be found at `[..]`. +To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path. + +"#]]); // Find the path in the output. let stderr = stderr.split_once("found at `").unwrap().1; diff --git a/tests/testsuite/profile_trim_paths.rs b/tests/testsuite/profile_trim_paths.rs index fbdec2a6919..58a3fd15d5d 100644 --- a/tests/testsuite/profile_trim_paths.rs +++ b/tests/testsuite/profile_trim_paths.rs @@ -1,10 +1,12 @@ //! Tests for `-Ztrim-paths`. use cargo_test_support::basic_manifest; +use cargo_test_support::compare::assert_e2e; use cargo_test_support::git; use cargo_test_support::paths; use cargo_test_support::project; use cargo_test_support::registry::Package; +use cargo_test_support::str; #[cargo_test] fn gated_manifest() { @@ -711,7 +713,6 @@ fn custom_build_env_var_trim_paths() { #[cfg(unix)] #[cargo_test(requires_lldb, nightly, reason = "-Zremap-path-scope is unstable")] fn lldb_works_after_trimmed() { - use cargo_test_support::compare::match_contains; use cargo_util::is_ci; if !is_ci() { @@ -770,14 +771,17 @@ fn lldb_works_after_trimmed() { let bin_path = p.bin("foo"); assert!(bin_path.is_file()); let stdout = String::from_utf8(run_lldb(bin_path).stdout).unwrap(); - match_contains("[..]stopped[..]", &stdout, None).unwrap(); - match_contains("[..]stop reason = breakpoint[..]", &stdout, None).unwrap(); - match_contains( - "\ -(lldb) continue -Hello, Ferris!", + assert_e2e().eq( &stdout, - None, - ) - .unwrap(); + str![[r#" +... +[..]stopped[..] +[..]stop reason = breakpoint 1.1[..] +... +(lldb) continue +Hello, Ferris! +... + +"#]], + ); } diff --git a/tests/testsuite/registry_auth.rs b/tests/testsuite/registry_auth.rs index 1ac1ba28444..12c00998134 100644 --- a/tests/testsuite/registry_auth.rs +++ b/tests/testsuite/registry_auth.rs @@ -1,7 +1,8 @@ //! Tests for registry authentication. -use cargo_test_support::compare::match_contains; +use cargo_test_support::compare::assert_e2e; use cargo_test_support::registry::{Package, RegistryBuilder, Token}; +use cargo_test_support::str; use cargo_test_support::{project, Execs, Project}; fn cargo(p: &Project, s: &str) -> Execs { @@ -473,23 +474,14 @@ fn token_not_logged() { .exec_with_output() .unwrap(); let log = String::from_utf8(output.stderr).unwrap(); - let lines = "\ -[UPDATING] crates.io index -[PACKAGING] foo v0.1.0 [..] -[VERIFYING] foo v0.1.0 [..] -[DOWNLOADING] crates ... -[DOWNLOADED] bar v1.0.0 -[COMPILING] bar v1.0.0 -[COMPILING] foo v0.1.0 [..] -[FINISHED] [..] -[PACKAGED] 3 files[..] -[UPLOADING] foo v0.1.0[..] -[UPLOADED] foo v0.1.0 to registry `crates-io` -[NOTE] waiting [..] -"; - for line in lines.lines() { - match_contains(line, &log, None).unwrap(); - } + assert_e2e().eq( + &log, + str![[r#" +... +[PUBLISHED] foo v0.1.0 at registry `crates-io` + +"#]], + ); let authorizations: Vec<_> = log .lines() .filter(|line| {