diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index 61cb85f4c7e..da06bc3adc0 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -1,9 +1,8 @@ //! Tests specific to artifact dependencies, designated using //! the new `dep = { artifact = "bin", … }` syntax in manifests. -#![allow(deprecated)] - use cargo_test_support::compare::assert_e2e; +use cargo_test_support::prelude::*; use cargo_test_support::registry::{Package, RegistryBuilder}; use cargo_test_support::str; use cargo_test_support::{ @@ -35,14 +34,13 @@ fn check_with_invalid_artifact_dependency() { .build(); p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: 'unknown' is not a valid artifact specifier -", - ) + +"#]]) .with_status(101) .run(); @@ -79,14 +77,13 @@ Caused by: .build(); run_cargo_with_and_without_bindeps_feature(&p, "check", &|cargo| { cargo - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: 'lib' specifier cannot be used without an 'artifact = …' value (bar) -", - ) + +"#]]) .with_status(101) .run(); }); @@ -112,14 +109,13 @@ Caused by: .build(); run_cargo_with_and_without_bindeps_feature(&p, "check", &|cargo| { cargo - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: 'target' specifier cannot be used without an 'artifact = …' value (bar) -", - ) + +"#]]) .with_status(101) .run(); }) @@ -149,9 +145,16 @@ fn check_with_invalid_target_triple() { .build(); p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains( - r#"[..]Could not find specification for target "unknown-target-triple"[..]"#, - ) + .with_stderr_data(str![[r#" +[ERROR] failed to run `rustc` to learn about target-specific information + +Caused by: + process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target unknown-target-triple [..]` ([EXIT_STATUS]: 1) + --- stderr + [ERROR] Error loading target specification: Could not find specification for target "unknown-target-triple". Run `rustc --print target-list` for a list of built-in targets + + +"#]]) .with_status(101) .run(); } @@ -179,14 +182,13 @@ fn build_without_nightly_aborts_with_error() { .build(); p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at [..] + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `artifact = …` requires `-Z bindeps` (bar) -", - ) + +"#]]) .run(); } @@ -215,11 +217,12 @@ fn disallow_artifact_and_no_artifact_dep_to_same_package_within_the_same_dep_cat p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) - .with_stderr("\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[WARNING] foo v0.0.0 ([CWD]) ignoring invalid dependency `bar_stable` which is missing a lib target -[ERROR] the crate `foo v0.0.0 ([CWD])` depends on crate `bar v0.5.0 ([CWD]/bar)` multiple times with different names", - ) +[WARNING] foo v0.0.0 ([ROOT]/foo) ignoring invalid dependency `bar_stable` which is missing a lib target +[ERROR] the crate `foo v0.0.0 ([ROOT]/foo)` depends on crate `bar v0.5.0 ([ROOT]/foo/bar)` multiple times with different names + +"#]]) .run(); } @@ -324,15 +327,14 @@ fn features_are_unified_among_lib_and_bin_dep_of_same_target() { p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 3 packages to latest compatible versions -[COMPILING] d2 v0.0.1 ([CWD]/d2) -[COMPILING] d1 v0.0.1 ([CWD]/d1) -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] d2 v0.0.1 ([ROOT]/foo/d2) +[COMPILING] d1 v0.0.1 ([ROOT]/foo/d1) +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -436,9 +438,17 @@ fn features_are_not_unified_among_lib_and_bin_dep_of_different_target() { p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) - .with_stderr_contains( - "error[E0425]: cannot find function `f2` in crate `d2`\n --> d1/src/main.rs:6:17", - ) + .with_stderr_data(str![[r#" +[LOCKING] 3 packages to latest compatible versions +[COMPILING] d2 v0.0.1 ([ROOT]/foo/d2) +[COMPILING] d1 v0.0.1 ([ROOT]/foo/d1) +error[E0425]: cannot find function `f2` in crate `d2` +... + +For more information about this error, try `rustc --explain E0425`. +[ERROR] could not compile `d1` (bin "d1") due to 1 previous error + +"#]]) .run(); } @@ -588,10 +598,15 @@ fn build_script_with_bin_artifacts() { .build(); p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains("[COMPILING] foo [..]") - .with_stderr_contains("[COMPILING] bar v0.5.0 ([CWD]/bar)") - .with_stderr_contains( - "[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", + .with_stderr_data( + str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); @@ -601,12 +616,12 @@ fn build_script_with_bin_artifacts() { assert_e2e().eq( &build_script_output, str![[r#" -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin/baz[EXE] -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/staticlib/bar-[..].lib -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/cdylib/bar.dll -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin/bar[EXE] -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin/bar[EXE] +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/baz[EXE] +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/staticlib/bar-[HASH].lib +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/cdylib/bar.dll +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar[EXE] +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar[EXE] "#]], ); @@ -614,12 +629,12 @@ fn build_script_with_bin_artifacts() { assert_e2e().eq( &build_script_output, str![[r#" -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin/baz-[..] -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/staticlib/libbar-[..].a -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/cdylib/[..]bar.[..] -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin/bar-[..] -[ROOT]/foo/target/debug/deps/artifact/bar-[..]/bin/bar-[..] +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/baz-[HASH][EXE] +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/staticlib/libbar-[HASH].a +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/cdylib/[..]bar.[..] +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar-[HASH][EXE] +[ROOT]/foo/target/debug/deps/artifact/bar-[HASH]/bin/bar-[HASH][EXE] "#]], ); @@ -670,6 +685,8 @@ fn build_script_with_bin_artifact_and_lib_false() { "#, ) .build(); + + #[allow(deprecated)] p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) @@ -712,6 +729,8 @@ fn lib_with_bin_artifact_and_lib_false() { "#, ) .build(); + + #[allow(deprecated)] p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) @@ -774,13 +793,13 @@ fn build_script_with_selected_dashed_bin_artifact_and_lib_true() { .build(); p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar-baz v0.5.0 ([CWD]/bar) -[COMPILING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", - ) +[COMPILING] bar-baz v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let build_script_output = build_script_output_string(&p, "foo"); @@ -789,8 +808,8 @@ fn build_script_with_selected_dashed_bin_artifact_and_lib_true() { assert_e2e().eq( &build_script_output, str![[r#" -[ROOT]/foo/target/debug/deps/artifact/bar-baz-[..]/bin -[ROOT]/foo/target/debug/deps/artifact/bar-baz-[..]/bin/baz_suffix[EXE] +[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin +[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin/baz_suffix[EXE] "#]], ); @@ -798,8 +817,8 @@ fn build_script_with_selected_dashed_bin_artifact_and_lib_true() { assert_e2e().eq( &build_script_output, str![[r#" -[ROOT]/foo/target/debug/deps/artifact/bar-baz-[..]/bin -[ROOT]/foo/target/debug/deps/artifact/bar-baz-[..]/bin/baz_suffix-[..] +[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin +[ROOT]/foo/target/debug/deps/artifact/bar-baz-[HASH]/bin/baz_suffix-[HASH][EXE] "#]], ); @@ -870,13 +889,13 @@ fn lib_with_selected_dashed_bin_artifact_and_lib_true() { .build(); p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar-baz v0.5.0 ([CWD]/bar) -[COMPILING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", - ) +[COMPILING] bar-baz v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!( @@ -921,10 +940,15 @@ fn allow_artifact_and_no_artifact_dep_to_same_package_within_different_dep_categ .build(); p.cargo("test -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains("[COMPILING] bar v0.5.0 ([CWD]/bar)") - .with_stderr_contains( - "[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..]", - ) + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH][EXE]) +[DOCTEST] foo + +"#]]) .run(); } @@ -991,11 +1015,11 @@ fn disallow_using_example_binaries_as_artifacts() { p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[ERROR] dependency `bar` in package `foo` requires a `bin:one-example` artifact to be present.", - ) +[ERROR] dependency `bar` in package `foo` requires a `bin:one-example` artifact to be present. + +"#]]) .run(); } @@ -1044,8 +1068,13 @@ fn allow_artifact_and_non_artifact_dependency_to_same_crate() { p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains("[COMPILING] bar [..]") - .with_stderr_contains("[COMPILING] foo [..]") + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1087,6 +1116,7 @@ fn build_script_deps_adopt_specified_target_unconditionally() { .file("bar/src/lib.rs", "pub fn doit() {}") .build(); + #[allow(deprecated)] p.cargo("check -v -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_stderr_does_not_contain(format!( @@ -1162,11 +1192,11 @@ fn build_script_deps_adopt_do_not_allow_multiple_targets_under_different_name_an p.cargo("check -v -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) - .with_stderr(format!( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -error: the crate `foo v0.0.0 ([CWD])` depends on crate `bar v0.5.0 ([CWD]/bar)` multiple times with different names", - )) +[ERROR] the crate `foo v0.0.0 ([ROOT]/foo)` depends on crate `bar v0.5.0 ([ROOT]/foo/bar)` multiple times with different names + +"#]]) .run(); } @@ -1206,6 +1236,7 @@ fn non_build_script_deps_adopt_specified_target_unconditionally() { .file("bar/src/lib.rs", "pub fn doit() {}") .build(); + #[allow(deprecated)] p.cargo("check -v -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_stderr_contains(format!( @@ -1267,17 +1298,15 @@ fn no_cross_doctests_works_with_artifacts() { p.cargo("test -Z bindeps --target") .arg(&target) .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr(&format!( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.5.0 ([CWD]/bar) -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/{triple}/debug/deps/foo-[..][EXE]) +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH][EXE]) [DOCTEST] foo -", - triple = target - )) + +"#]]) .run(); println!("c"); @@ -1288,15 +1317,17 @@ fn no_cross_doctests_works_with_artifacts() { p.cargo("test -Z bindeps -v --doc --target") .arg(&target) .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains(format!( - "[COMPILING] bar v0.5.0 ([CWD]/bar) -[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--target {triple} [..] -[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/main.rs [..]--target {triple} [..] -[COMPILING] foo v0.0.1 ([CWD]) -[RUNNING] `rustc --crate-name foo [..] -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..]", - triple = target - )) + .with_stderr_data(str![[r#" +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--target [ALT_TARGET] [..] +[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/main.rs [..]--target [ALT_TARGET] [..] +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..]` +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), cross-compilation doctests are not yet supported +See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile for more information. + +"#]]) .run(); if !cross_compile::can_run_on_host() { @@ -1307,14 +1338,16 @@ fn no_cross_doctests_works_with_artifacts() { p.cargo("test -Z bindeps -v --target") .arg(&target) .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains(&format!( - "[FRESH] bar v0.5.0 ([CWD]/bar) -[COMPILING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[FRESH] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo [..]--test[..] -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[CWD]/target/{triple}/debug/deps/foo-[..][EXE]`", - triple = target - )) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] `[ROOT]/foo/target/[ALT_TARGET]/debug/deps/foo-[HASH][EXE]` +[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), cross-compilation doctests are not yet supported +See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile for more information. + +"#]]) .run(); } @@ -1351,6 +1384,7 @@ fn build_script_deps_adopts_target_platform_if_target_equals_target() { .build(); let alternate_target = cross_compile::alternate(); + #[allow(deprecated)] p.cargo("check -v -Z bindeps --target") .arg(alternate_target) .masquerade_as_nightly_cargo(&["bindeps"]) @@ -1410,22 +1444,23 @@ fn profile_override_basic() { p.cargo("build -v -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name build_script_build [..] -C opt-level=1 [..]`", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/main.rs [..] -C opt-level=3 [..]`", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/main.rs [..] -C opt-level=1 [..]`", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..] -C opt-level=1 [..]`", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..] -C opt-level=3 [..]`", + .with_stderr_data( + str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name build_script_build [..] -C opt-level=1 [..]` +[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/main.rs [..] -C opt-level=3 [..]` +[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/main.rs [..] -C opt-level=1 [..]` +[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..] -C opt-level=1 [..]` +[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..] -C opt-level=3 [..]` +[RUNNING] `rustc --crate-name foo [..] -C opt-level=3 [..]` +[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` +[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) - .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..] -C opt-level=3 [..]`") .run(); } @@ -1482,14 +1517,13 @@ fn dependencies_of_dependencies_work_in_artifacts() { // cargo tree sees artifacts as the dependency kind they are in and doesn't do anything special with it. p.cargo("tree -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stdout( - "\ -foo v0.0.0 ([CWD]) + .with_stdout_data(str![[r#" +foo v0.0.0 ([ROOT]/foo) [build-dependencies] -└── bar v0.5.0 ([CWD]/bar) +└── bar v0.5.0 ([ROOT]/foo/bar) └── baz v1.0.0 -", - ) + +"#]]) .run(); } @@ -1522,21 +1556,26 @@ fn artifact_dep_target_specified() { p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains( - r#"[COMPILING] bindep v0.0.0 ([CWD]/bindep) -[CHECKING] foo v0.0.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]"#, - ) + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bindep v0.0.0 ([ROOT]/foo/bindep) +[CHECKING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .with_status(0) .run(); // TODO: This command currently fails due to a bug in cargo but it should be fixed so that it succeeds in the future. p.cargo("tree -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stdout("") - .with_stderr_contains( - r#"activated_features for invalid package: features did not find PackageId { name: "bindep", version: "0.0.0", source: "[..]" } NormalOrDev"# - ) + .with_stdout_data(str![[""]]) + .with_stderr_data(str![[r#" +thread 'main' panicked at src/cargo/[..]: +activated_features for invalid package: features did not find PackageId { name: "bindep", version: "0.0.0", source: "[..]" } NormalOrDev +[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace + +"#]]) .with_status(101) .run(); } @@ -1625,33 +1664,37 @@ fn index_version_filtering() { .build(); p.cargo("tree") - .with_stdout("foo v0.1.0 [..]\n└── bar v1.0.0") + .with_stdout_data(str![[r#" +foo v0.1.0 ([ROOT]/foo) +└── bar v1.0.0 + +"#]]) .run(); // And with -Zbindeps it can use 1.0.1. p.cargo("update -Zbindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ -[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest compatible versions [ADDING] artifact v1.0.0 -[UPDATING] bar v1.0.0 -> v1.0.1", - ) +[UPDATING] bar v1.0.0 -> v1.0.1 + +"#]]) .run(); // And without -Zbindeps, now that 1.0.1 is in Cargo.lock, it should fail. p.cargo("check") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -error: failed to select a version for the requirement `bar = \"^1.0\"` (locked to 1.0.1) + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for the requirement `bar = "^1.0"` (locked to 1.0.1) candidate versions found which didn't match: 1.0.0 -location searched: [..] -required by package `foo v0.1.0 [..]` -perhaps a crate was updated and forgotten to be re-vendored?", - ) +location searched: `dummy-registry` index (which is replacing registry `crates-io`) +required by package `foo v0.1.0 ([ROOT]/foo)` +perhaps a crate was updated and forgotten to be re-vendored? + +"#]]) .run(); } @@ -1707,7 +1750,7 @@ fn proc_macro_in_artifact_dep() { p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr("") + .with_stderr_data(str![[r#""#]]) .run(); } @@ -1748,8 +1791,20 @@ fn allow_dep_renames_with_multiple_versions() { .build(); p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains("[COMPILING] bar [..]") - .with_stderr_contains("[COMPILING] foo [..]") + .with_stderr_data( + str![[r#" +[UPDATING] `dummy-registry` index +[LOCKING] 3 packages to latest compatible versions +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`) +[COMPILING] bar v1.0.0 +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), + ) .run(); let build_script_output = build_script_output_string(&p, "foo"); assert_e2e().eq( @@ -1800,14 +1855,13 @@ fn allow_artifact_and_non_artifact_dependency_to_same_crate_if_these_are_not_the .build(); p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar [..] -[COMPILING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] bar v0.0.1 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1837,13 +1891,13 @@ fn prevent_no_lib_warning_with_artifact_dependencies() { .build(); p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ - [LOCKING] 2 packages to latest compatible versions\n\ - [COMPILING] bar v0.5.0 ([CWD]/bar)\n\ - [CHECKING] foo v0.0.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", - ) + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[CHECKING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1874,10 +1928,14 @@ fn show_no_lib_warning_with_artifact_dependencies_that_have_no_lib_but_lib_true( .build(); p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains("[WARNING] foo v0.0.0 ([CWD]) ignoring invalid dependency `bar` which is missing a lib target") - .with_stderr_contains("[COMPILING] bar v0.5.0 ([CWD]/bar)") - .with_stderr_contains("[CHECKING] foo [..]") - .with_stderr_contains("[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]") + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[WARNING] foo v0.0.0 ([ROOT]/foo) ignoring invalid dependency `bar` which is missing a lib target +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[CHECKING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1938,11 +1996,11 @@ fn check_missing_crate_type_in_package_fails() { p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[ERROR] dependency `bar` in package `foo` requires a `[..]` artifact to be present.", - ) +[ERROR] dependency `bar` in package `foo` requires a [..] artifact to be present. + +"#]]) .run(); } } @@ -1971,9 +2029,13 @@ fn check_target_equals_target_in_non_build_dependency_errors() { p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_status(101) - .with_stderr_contains( - " `target = \"target\"` in normal- or dev-dependencies has no effect (bar)", - ) + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` + +Caused by: + `target = "target"` in normal- or dev-dependencies has no effect (bar) + +"#]]) .run(); } @@ -2085,17 +2147,16 @@ fn env_vars_and_build_products_for_various_build_targets() { .build(); p.cargo("test -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar [..] -[COMPILING] foo [..] -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] unittests [..] -[RUNNING] tests/main.rs [..] +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH][EXE]) +[RUNNING] tests/main.rs (target/debug/deps/main-[HASH][EXE]) [DOCTEST] foo -", - ) + +"#]]) .run(); } @@ -2135,18 +2196,17 @@ fn publish_artifact_dep() { p.cargo("publish -Z bindeps --no-verify") .replace_crates_io(registry.index_url()) .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ -[UPDATING] [..] -[PACKAGING] foo v0.1.0 [..] -[PACKAGED] [..] -[UPLOADING] foo v0.1.0 [..] -[UPLOADED] foo v0.1.0 [..] -[NOTE] waiting [..] -You may press ctrl-c [..] -[PUBLISHED] foo v0.1.0 [..] -", - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[PACKAGING] foo v0.1.0 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[UPLOADING] foo v0.1.0 ([ROOT]/foo) +[UPLOADED] foo v0.1.0 to registry `crates-io` +[NOTE] waiting for `foo v0.1.0` to be available at registry `crates-io`. +You may press ctrl-c to skip waiting; the crate should be available shortly. +[PUBLISHED] foo v0.1.0 at registry `crates-io` + +"#]]) .run(); publish::validate_upload_with_contents( @@ -2272,16 +2332,15 @@ fn doc_lib_true() { p.cargo("doc -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.0.1 ([CWD]/bar) -[DOCUMENTING] bar v0.0.1 ([CWD]/bar) -[DOCUMENTING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -[GENERATED] [CWD]/target/doc/foo/index.html -", - ) +[COMPILING] bar v0.0.1 ([ROOT]/foo/bar) +[DOCUMENTING] bar v0.0.1 ([ROOT]/foo/bar) +[DOCUMENTING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[GENERATED] [ROOT]/foo/target/doc/foo/index.html + +"#]]) .run(); assert!(p.root().join("target/doc").is_dir()); @@ -2294,11 +2353,11 @@ fn doc_lib_true() { p.cargo("doc -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ -[FINISHED] [..] -[GENERATED] [CWD]/target/doc/foo/index.html", - ) + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[GENERATED] [ROOT]/foo/target/doc/foo/index.html + +"#]]) .run(); assert!(p.root().join("target/doc").is_dir()); @@ -2355,15 +2414,14 @@ fn rustdoc_works_on_libs_with_artifacts_and_lib_false() { p.cargo("doc -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.5.0 ([CWD]/bar) -[DOCUMENTING] foo v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -[GENERATED] [CWD]/target/doc/foo/index.html -", - ) +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[DOCUMENTING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[GENERATED] [ROOT]/foo/target/doc/foo/index.html + +"#]]) .run(); assert!(p.root().join("target/doc").is_dir()); @@ -2563,43 +2621,40 @@ fn calc_bin_artifact_fingerprint() { .build(); p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.5.0 ([CWD]/bar) -[CHECKING] foo v0.1.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.change_file("bar/src/main.rs", r#"fn main() { println!("bar") }"#); // Change in artifact bin dep `bar` propagates to `foo`, triggering recompile. p.cargo("check -v -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ -[DIRTY] bar v0.5.0 ([CWD]/bar): the file `bar/src/main.rs` has changed ([..]) -[COMPILING] bar v0.5.0 ([CWD]/bar) + .with_stderr_data(str![[r#" +[DIRTY] bar v0.5.0 ([ROOT]/foo/bar): the file `bar/src/main.rs` has changed ([..]) +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) [RUNNING] `rustc --crate-name bar [..]` -[DIRTY] foo v0.1.0 ([CWD]): the dependency bar was rebuilt -[CHECKING] foo v0.1.0 ([CWD]) +[DIRTY] foo v0.1.0 ([ROOT]/foo): the dependency bar was rebuilt +[CHECKING] foo v0.1.0 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo [..]` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // All units are fresh. No recompile. p.cargo("check -v -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ -[FRESH] bar v0.5.0 ([CWD]/bar) -[FRESH] foo v0.1.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[FRESH] bar v0.5.0 ([ROOT]/foo/bar) +[FRESH] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2645,16 +2700,15 @@ fn with_target_and_optional() { p.cargo("check -Z bindeps -F d1 -v") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] d1 v0.0.1 [..] +[COMPILING] d1 v0.0.1 ([ROOT]/foo/d1) [RUNNING] `rustc --crate-name d1 [..]--crate-type bin[..] -[CHECKING] foo v0.0.1 [..] +[CHECKING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo [..]--cfg[..]d1[..] -[FINISHED] `dev` profile [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2695,17 +2749,19 @@ fn with_assumed_host_target_and_optional_build_dep() { p.cargo("check -Z bindeps -F d1 -v") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] foo v0.0.1 ([CWD]) -[COMPILING] d1 v0.0.1 ([CWD]/d1) +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] d1 v0.0.1 ([ROOT]/foo/d1) [RUNNING] `rustc --crate-name build_script_build --edition=2021 [..]--crate-type bin[..] [RUNNING] `rustc --crate-name d1 --edition=2021 [..]--crate-type bin[..] -[RUNNING] `[CWD]/target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` [RUNNING] `rustc --crate-name foo --edition=2021 [..]--cfg[..]d1[..] [FINISHED] `dev` profile [..] -", + +"#]] + .unordered(), ) .run(); } @@ -2823,17 +2879,16 @@ fn decouple_same_target_transitive_dep_from_artifact_dep() { .build(); p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 5 packages to latest compatible versions -[COMPILING] c v0.1.0 ([CWD]/c) -[COMPILING] b v0.1.0 ([CWD]/b) -[COMPILING] a v0.1.0 ([CWD]/a) -[COMPILING] bar v0.1.0 ([CWD]/bar) -[COMPILING] foo v0.1.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] c v0.1.0 ([ROOT]/foo/c) +[COMPILING] b v0.1.0 ([ROOT]/foo/b) +[COMPILING] a v0.1.0 ([ROOT]/foo/a) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2927,16 +2982,15 @@ fn decouple_same_target_transitive_dep_from_artifact_dep_lib() { .build(); p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 4 packages to latest compatible versions -[COMPILING] b v0.1.0 ([CWD]/b) -[COMPILING] a v0.1.0 ([CWD]/a) -[COMPILING] bar v0.1.0 ([CWD]/bar) -[COMPILING] foo v0.1.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] b v0.1.0 ([ROOT]/foo/b) +[COMPILING] a v0.1.0 ([ROOT]/foo/a) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3054,17 +3108,19 @@ fn decouple_same_target_transitive_dep_from_artifact_dep_and_proc_macro() { p.cargo("build -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 6 packages to latest compatible versions -[COMPILING] d v0.1.0 ([CWD]/d) -[COMPILING] a v0.1.0 ([CWD]/a) -[COMPILING] b v0.1.0 ([CWD]/b) -[COMPILING] c v0.1.0 ([CWD]/c) -[COMPILING] bar v0.1.0 ([CWD]/bar) -[COMPILING] foo v0.1.0 ([CWD]) +[COMPILING] d v0.1.0 ([ROOT]/foo/d) +[COMPILING] a v0.1.0 ([ROOT]/foo/a) +[COMPILING] b v0.1.0 ([ROOT]/foo/b) +[COMPILING] c v0.1.0 ([ROOT]/foo/c) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", + +"#]] + .unordered(), ) .run(); } @@ -3120,15 +3176,14 @@ fn same_target_artifact_dep_sharing() { .build(); p.cargo(&format!("build -Z bindeps --target {target}")) .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 3 packages to latest compatible versions -[COMPILING] a v0.1.0 ([CWD]/a) -[COMPILING] bar v0.1.0 ([CWD]/bar) -[COMPILING] foo v0.1.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] a v0.1.0 ([ROOT]/foo/a) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3177,10 +3232,21 @@ fn check_transitive_artifact_dependency_with_different_target() { p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains( - "error: failed to determine target information for target `custom-target`.\n \ - Artifact dependency `baz` in package `bar v0.0.0 [..]` requires building for `custom-target`", - ) + .with_stderr_data(str![[r#" +[LOCKING] 3 packages to latest compatible versions +[ERROR] failed to determine target information for target `custom-target`. + Artifact dependency `baz` in package `bar v0.0.0 ([ROOT]/foo/bar)` requires building for `custom-target` + +Caused by: + failed to run `rustc` to learn about target-specific information + +Caused by: + process didn't exit successfully: `rustc [..] ([EXIT_STATUS]: 1) + --- stderr + [ERROR] Error loading target specification: Could not find specification for target "custom-target". Run `rustc --print target-list` for a list of built-in targets + + +"#]]) .with_status(101) .run(); } diff --git a/tests/testsuite/artifact_dir.rs b/tests/testsuite/artifact_dir.rs index 178bd13b118..8f82ece5f3d 100644 --- a/tests/testsuite/artifact_dir.rs +++ b/tests/testsuite/artifact_dir.rs @@ -1,8 +1,8 @@ //! Tests for --artifact-dir flag. -#![allow(deprecated)] - +use cargo_test_support::prelude::*; use cargo_test_support::sleep_ms; +use cargo_test_support::str; use cargo_test_support::{basic_manifest, project}; use std::env; use std::fs; @@ -190,7 +190,14 @@ fn artifact_dir_is_a_file() { p.cargo("build -Z unstable-options --artifact-dir out") .masquerade_as_nightly_cargo(&["artifact-dir"]) .with_status(101) - .with_stderr_contains("[ERROR] failed to create directory [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[ERROR] failed to create directory `[ROOT]/foo/out` + +Caused by: +... + +"#]]) .run(); } @@ -207,7 +214,10 @@ fn replaces_artifacts() { &p.root() .join(&format!("out/foo{}", env::consts::EXE_SUFFIX)), ) - .with_stdout("foo") + .with_stdout_data(str![[r#" +foo + +"#]]) .run(); sleep_ms(1000); @@ -220,7 +230,10 @@ fn replaces_artifacts() { &p.root() .join(&format!("out/foo{}", env::consts::EXE_SUFFIX)), ) - .with_stdout("bar") + .with_stdout_data(str![[r#" +bar + +"#]]) .run(); } @@ -245,8 +258,14 @@ fn avoid_build_scripts() { p.cargo("build -Z unstable-options --artifact-dir out -vv") .masquerade_as_nightly_cargo(&["artifact-dir"]) .enable_mac_dsym() - .with_stdout_contains("[a 0.0.1] hello-build-a") - .with_stdout_contains("[b 0.0.1] hello-build-b") + .with_stdout_data( + str![[r#" +[a 0.0.1] hello-build-a +[b 0.0.1] hello-build-b + +"#]] + .unordered(), + ) .run(); check_dir_contents( &p.root().join("out"), @@ -291,17 +310,16 @@ fn unsupported_short_artifact_dir_flag() { p.cargo("build -Z unstable-options -O") .masquerade_as_nightly_cargo(&["artifact-dir"]) - .with_stderr( - "\ -error: unexpected argument '-O' found + .with_stderr_data(str![[r#" +[ERROR] unexpected argument '-O' found tip: a similar argument exists: '--artifact-dir' Usage: cargo[EXE] build [OPTIONS] For more information, try '--help'. -", - ) + +"#]]) .with_status(1) .run(); } @@ -315,7 +333,12 @@ fn deprecated_out_dir() { p.cargo("build -Z unstable-options --out-dir out") .masquerade_as_nightly_cargo(&["out-dir"]) .enable_mac_dsym() - .with_stderr_contains("[WARNING] the --out-dir flag has been changed to --artifact-dir") + .with_stderr_data(str![[r#" +[WARNING] the --out-dir flag has been changed to --artifact-dir +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); check_dir_contents( &p.root().join("out"), @@ -342,9 +365,12 @@ fn cargo_build_deprecated_out_dir() { p.cargo("build -Z unstable-options") .masquerade_as_nightly_cargo(&["out-dir"]) .enable_mac_dsym() - .with_stderr_contains( - "[WARNING] the out-dir config option has been changed to artifact-dir", - ) + .with_stderr_data(str![[r#" +[WARNING] the out-dir config option has been changed to artifact-dir +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); check_dir_contents( &p.root().join("out"), diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index be3ee217531..f431fd9b5d5 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -1,9 +1,9 @@ //! Tests for some invalid .cargo/config files. -#![allow(deprecated)] - use cargo_test_support::git::cargo_uses_gitoxide; +use cargo_test_support::prelude::*; use cargo_test_support::registry::{self, Package}; +use cargo_test_support::str; use cargo_test_support::{basic_manifest, project, rustc_host}; #[cargo_test] @@ -20,12 +20,10 @@ fn bad1() { .build(); p.cargo("check -v --target=nonexistent-target") .with_status(101) - .with_stderr( - "\ -[ERROR] expected table for configuration key `target.nonexistent-target`, \ -but found string in [..]/config.toml -", - ) + .with_stderr_data(str![[r#" +[ERROR] expected table for configuration key `target.nonexistent-target`, but found string in [ROOT]/foo/.cargo/config.toml + +"#]]) .run(); } @@ -43,12 +41,11 @@ fn bad2() { .build(); p.cargo("publish -v") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] could not load Cargo configuration Caused by: - failed to load TOML configuration from `[..]config.toml` + failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml` Caused by: failed to parse key `http` @@ -58,8 +55,8 @@ Caused by: Caused by: found TOML configuration value of unknown type `float` -", - ) + +"#]]) .run(); } @@ -81,14 +78,13 @@ fn bad3() { p.cargo("publish -v") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -error: failed to update registry [..] + .with_stderr_data(str![[r#" +[ERROR] failed to update registry `crates-io` Caused by: - error in [..]config.toml: `http.proxy` expected a string, but found a boolean -", - ) + error in [ROOT]/foo/.cargo/config.toml: `http.proxy` expected a string, but found a boolean + +"#]]) .run(); } @@ -105,15 +101,14 @@ fn bad4() { .build(); p.cargo("new -v foo") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [CREATING] binary (application) `foo` package -[ERROR] Failed to create package `foo` at `[..]` +[ERROR] Failed to create package `foo` at `[ROOT]/foo/foo` Caused by: - error in [..]config.toml: `cargo-new.vcs` expected a string, but found a boolean -", - ) + error in [ROOT]/foo/.cargo/config.toml: `cargo-new.vcs` expected a string, but found a boolean + +"#]]) .run(); } @@ -135,14 +130,13 @@ fn bad6() { p.cargo("publish -v") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ -error: failed to update registry [..] + .with_stderr_data(str![[r#" +[ERROR] failed to update registry `crates-io` Caused by: - error in [..]config.toml: `http.user-agent` expected a string, but found a boolean -", - ) + error in [ROOT]/foo/.cargo/config.toml: `http.user-agent` expected a string, but found a boolean + +"#]]) .run(); } @@ -168,12 +162,11 @@ fn invalid_global_config() { p.cargo("check -v") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] could not load Cargo configuration Caused by: - could not parse TOML configuration in `[..]` + could not parse TOML configuration in `[ROOT]/foo/.cargo/config.toml` Caused by: TOML parse error at line 1, column 2 @@ -181,8 +174,8 @@ Caused by: 1 | 4 | ^ expected `.`, `=` -", - ) + +"#]]) .run(); } @@ -195,9 +188,8 @@ fn bad_cargo_lock() { p.cargo("check -v") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse lock file at: [..]Cargo.lock + .with_stderr_data(str![[r#" +[ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock Caused by: TOML parse error at line 1, column 1 @@ -205,8 +197,8 @@ Caused by: 1 | [[package]] | ^^^^^^^^^^^ missing field `name` -", - ) + +"#]]) .run(); } @@ -254,14 +246,13 @@ fn duplicate_packages_in_cargo_lock() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse lock file at: [..] + .with_stderr_data(str![[r#" +[ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock Caused by: package `bar` is specified twice in the lockfile -", - ) + +"#]]) .run(); } @@ -304,18 +295,17 @@ fn bad_source_in_cargo_lock() { p.cargo("check --verbose") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse lock file at: [..] + .with_stderr_data(str![[r#" +[ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock Caused by: TOML parse error at line 12, column 26 | - 12 | source = \"You shall not parse\" + 12 | source = "You shall not parse" | ^^^^^^^^^^^^^^^^^^^^^ invalid source `You shall not parse` -", - ) + +"#]]) .run(); } @@ -365,10 +355,12 @@ fn bad_git_dependency() { .file("src/lib.rs", "") .build(); - let expected_stderr = if cargo_uses_gitoxide() { - "\ + if cargo_uses_gitoxide() { + p.cargo("check -v") + .with_status(101) + .with_stderr_data(str![[r#" [UPDATING] git repository `git://host.xz` -[ERROR] failed to get `foo` as a dependency of package `foo v0.0.0 [..]` +[ERROR] failed to get `foo` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` Caused by: failed to load source for dependency `foo` @@ -377,15 +369,19 @@ Caused by: Unable to update git://host.xz Caused by: - failed to clone into: [..] + failed to clone into: [ROOT]/home/.cargo/git/db/_empty-[HASH] Caused by: - URL \"git://host.xz\" does not specify a path to a repository -" + URL "git://host.xz" does not specify a path to a repository + +"#]]) + .run(); } else { - "\ + p.cargo("check -v") + .with_status(101) + .with_stderr_data(str![[r#" [UPDATING] git repository `file:///` -[ERROR] failed to get `foo` as a dependency of package `foo v0.0.0 [..]` +[ERROR] failed to get `foo` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` Caused by: failed to load source for dependency `foo` @@ -394,16 +390,14 @@ Caused by: Unable to update file:/// Caused by: - failed to clone into: [..] + failed to clone into: [ROOT]/home/.cargo/git/db/_empty-[HASH] Caused by: - [..]'file:///' is not a valid local file URI[..] -" + 'file:///' is not a valid local file URI; class=Config (7) + +"#]]) + .run(); }; - p.cargo("check -v") - .with_status(101) - .with_stderr(expected_stderr) - .run(); } #[cargo_test] @@ -427,9 +421,16 @@ fn bad_crate_type() { p.cargo("build -v") .with_status(101) - .with_stderr_contains( - "error: failed to run `rustc` to learn about crate-type bad_type information", - ) + .with_stderr_data(str![[r#" +[ERROR] failed to run `rustc` to learn about crate-type bad_type information + +Caused by: + process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --crate-type bad_type` ([EXIT_STATUS]: 1) + --- stderr + [ERROR] unknown crate type: `bad_type` + + +"#]]) .run(); } @@ -456,8 +457,7 @@ fn malformed_override() { p.cargo("check") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid inline table expected `}` --> Cargo.toml:9:27 @@ -465,8 +465,8 @@ expected `}` 9 | native = { | ^ | -", - ) + +"#]]) .run(); } @@ -497,14 +497,13 @@ fn duplicate_binary_names() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: found duplicate binary name e, but all binary targets must have a unique name -", - ) + +"#]]) .run(); } @@ -535,14 +534,13 @@ fn duplicate_example_names() { p.cargo("check --example ex") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: found duplicate example name ex, but all example targets must have a unique name -", - ) + +"#]]) .run(); } @@ -573,14 +571,13 @@ fn duplicate_bench_names() { p.cargo("bench") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: found duplicate bench name ex, but all bench targets must have a unique name -", - ) + +"#]]) .run(); } @@ -612,15 +609,13 @@ fn duplicate_deps() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: - Dependency 'bar' has different source paths depending on the build target. Each dependency must \ -have a single canonical source path irrespective of build target. -", - ) + Dependency 'bar' has different source paths depending on the build target. Each dependency must have a single canonical source path irrespective of build target. + +"#]]) .run(); } @@ -652,15 +647,13 @@ fn duplicate_deps_diff_sources() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: - Dependency 'bar' has different source paths depending on the build target. Each dependency must \ -have a single canonical source path irrespective of build target. -", - ) + Dependency 'bar' has different source paths depending on the build target. Each dependency must have a single canonical source path irrespective of build target. + +"#]]) .run(); } @@ -684,13 +677,12 @@ fn unused_keys() { .build(); p.cargo("check") - .with_stderr( - "\ -warning: unused manifest key: target.foo.bar -[CHECKING] foo v0.1.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] unused manifest key: target.foo.bar +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let p = project() @@ -709,13 +701,12 @@ warning: unused manifest key: target.foo.bar .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("check") - .with_stderr( - "\ -warning: unused manifest key: package.bulid -[CHECKING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] unused manifest key: package.bulid +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let p = project() @@ -737,13 +728,12 @@ warning: unused manifest key: package.bulid .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("check") - .with_stderr( - "\ -warning: unused manifest key: lib.build -[CHECKING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] unused manifest key: lib.build +[CHECKING] foo v0.5.0 ([ROOT]/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -762,13 +752,12 @@ fn unused_keys_in_virtual_manifest() { .file("bar/src/lib.rs", "") .build(); p.cargo("check --workspace") - .with_stderr( - "\ -[WARNING] [..]/foo/Cargo.toml: unused manifest key: workspace.bulid -[CHECKING] bar [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[WARNING] [ROOT]/foo/Cargo.toml: unused manifest key: workspace.bulid +[CHECKING] bar v0.0.1 ([ROOT]/foo/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -795,14 +784,13 @@ fn empty_dependencies() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: dependency (bar) specified without providing a local path, Git repository, version, or workspace dependency to use -", - ) + +"#]]) .run(); } @@ -833,14 +821,14 @@ fn dev_dependencies2() { ) .file("a/src/lib.rs", "") .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition (in the `foo` package) -" - ) - .run(); +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test(nightly, reason = "edition2024 is not stable")] @@ -875,15 +863,14 @@ fn dev_dependencies2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `dev_dependencies` is unsupported as of the 2024 edition; instead use `dev-dependencies` (in the `foo` package) -", - ) + +"#]]) .run(); } @@ -916,13 +903,13 @@ fn dev_dependencies2_conflict() { ) .file("a/src/lib.rs", "") .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `dev_dependencies` is redundant with `dev-dependencies`, preferring `dev-dependencies` in the `foo` package -", - ) - .run(); +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -952,14 +939,14 @@ fn build_dependencies2() { ) .file("a/src/lib.rs", "") .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition (in the `foo` package) -" - ) - .run(); +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test(nightly, reason = "edition2024 is not stable")] @@ -994,15 +981,14 @@ fn build_dependencies2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `build_dependencies` is unsupported as of the 2024 edition; instead use `build-dependencies` (in the `foo` package) -", - ) + +"#]]) .run(); } @@ -1035,13 +1021,13 @@ fn build_dependencies2_conflict() { ) .file("a/src/lib.rs", "") .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `build_dependencies` is redundant with `build-dependencies`, preferring `build-dependencies` in the `foo` package -", - ) - .run(); +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -1064,12 +1050,13 @@ fn lib_crate_type2() { .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("check") - .with_stderr_contains( - "\ + .with_stderr_data(str![[r#" [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition (in the `foo` library target) -", - ) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1097,15 +1084,14 @@ fn lib_crate_type2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `crate_type` is unsupported as of the 2024 edition; instead use `crate-type` (in the `foo` library target) -", - ) + +"#]]) .run(); } @@ -1129,13 +1115,12 @@ fn lib_crate_type2_conflict() { ) .file("src/lib.rs", "pub fn foo() {}") .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `foo` library target -", - ) - .run(); +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -1159,14 +1144,13 @@ fn bin_crate_type2() { .file("src/main.rs", "fn main() {}") .build(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition (in the `foo` binary target) -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1195,15 +1179,14 @@ fn bin_crate_type2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `crate_type` is unsupported as of the 2024 edition; instead use `crate-type` (in the `foo` binary target) -", - ) + +"#]]) .run(); } @@ -1228,15 +1211,12 @@ fn bin_crate_type2_conflict() { ) .file("src/main.rs", "fn main() {}") .build(); - p.cargo("check") - .with_stderr( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `foo` binary target -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) - .run(); +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -1276,14 +1256,15 @@ fn examples_crate_type2() { ) .build(); p.cargo("check") - .with_stderr_contains( - "\ + .with_stderr_data(str![[r#" [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition (in the `ex` example target) [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition (in the `goodbye` example target) -", - ) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1328,15 +1309,14 @@ fn examples_crate_type2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `crate_type` is unsupported as of the 2024 edition; instead use `crate-type` (in the `ex` example target) -", - ) + +"#]]) .run(); } @@ -1378,14 +1358,13 @@ fn examples_crate_type2_conflict() { "#, ) .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `ex` example target [WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `goodbye` example target -", - ) - .run(); +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -1419,11 +1398,15 @@ fn cargo_platform_build_dependencies2() { .build(); p.cargo("check") - .with_stderr_contains( - format!("\ + .with_stderr_data(str![[r#" [WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition -(in the `{host}` platform target) -") +(in the `[HOST_TARGET]` platform target) +[LOCKING] 2 packages to latest compatible versions +[COMPILING] build v0.5.0 ([ROOT]/foo/build) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] ) .run(); } @@ -1463,15 +1446,14 @@ fn cargo_platform_build_dependencies2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr(format!( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `build_dependencies` is unsupported as of the 2024 edition; instead use `build-dependencies` - (in the `{host}` platform target) -" - )) + (in the `[HOST_TARGET]` platform target) + +"#]]) .run(); } @@ -1508,11 +1490,15 @@ fn cargo_platform_build_dependencies2_conflict() { .build(); p.cargo("check") - .with_stderr_contains(format!( - "\ -[WARNING] `build_dependencies` is redundant with `build-dependencies`, preferring `build-dependencies` in the `{host}` platform target -" - )) + .with_stderr_data(str![[r#" +[WARNING] `build_dependencies` is redundant with `build-dependencies`, preferring `build-dependencies` in the `[HOST_TARGET]` platform target +[LOCKING] 2 packages to latest compatible versions +[COMPILING] build v0.5.0 ([ROOT]/foo/build) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); } @@ -1546,12 +1532,14 @@ fn cargo_platform_dev_dependencies2() { .build(); p.cargo("check") - .with_stderr_contains( - format!("\ + .with_stderr_data(str![[r#" [WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition -(in the `{host}` platform target) -") - ) +(in the `[HOST_TARGET]` platform target) +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1589,15 +1577,14 @@ fn cargo_platform_dev_dependencies2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr(format!( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `dev_dependencies` is unsupported as of the 2024 edition; instead use `dev-dependencies` - (in the `{host}` platform target) -" - )) + (in the `[HOST_TARGET]` platform target) + +"#]]) .run(); } @@ -1633,11 +1620,13 @@ fn cargo_platform_dev_dependencies2_conflict() { .build(); p.cargo("check") - .with_stderr_contains(format!( - "\ -[WARNING] `dev_dependencies` is redundant with `dev-dependencies`, preferring `dev-dependencies` in the `{host}` platform target -" - )) + .with_stderr_data(str![[r#" +[WARNING] `dev_dependencies` is redundant with `dev-dependencies`, preferring `dev-dependencies` in the `[HOST_TARGET]` platform target +[LOCKING] 2 packages to latest compatible versions +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1675,14 +1664,15 @@ fn default_features2() { .file("a/src/lib.rs", "") .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition (in the `a` dependency) -" - ) - .run(); +[LOCKING] 2 packages to latest compatible versions +[CHECKING] a v0.1.0 ([ROOT]/foo/a) +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test(nightly, reason = "edition2024 is not stable")] @@ -1724,15 +1714,14 @@ fn default_features2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `default_features` is unsupported as of the 2024 edition; instead use `default-features` (in the `a` dependency) -", - ) + +"#]]) .run(); } @@ -1770,13 +1759,14 @@ fn default_features2_conflict() { .file("a/src/lib.rs", "") .build(); - p.cargo("check") - .with_stderr_contains( - "\ + p.cargo("check").with_stderr_data(str![[r#" [WARNING] `default_features` is redundant with `default-features`, preferring `default-features` in the `a` dependency -", - ) - .run(); +[LOCKING] 2 packages to latest compatible versions +[CHECKING] a v0.1.0 ([ROOT]/foo/a) +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -1846,17 +1836,19 @@ fn workspace_default_features2() { .build(); p.cargo("check") - .with_stderr_unordered( - "\ -warning: [CWD]/workspace_only/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition + .with_stderr_data( + str![[r#" +[WARNING] [ROOT]/foo/workspace_only/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition (in the `dep_workspace_only` dependency) - Locking 4 packages to latest compatible versions - Checking dep_package_only v0.1.0 ([CWD]/dep_package_only) - Checking dep_workspace_only v0.1.0 ([CWD]/dep_workspace_only) - Checking package_only v0.1.0 ([CWD]/package_only) - Checking workspace_only v0.1.0 ([CWD]/workspace_only) - Finished `dev` profile [unoptimized + debuginfo] target(s) in [..]s -" +[LOCKING] 4 packages to latest compatible versions +[CHECKING] dep_package_only v0.1.0 ([ROOT]/foo/dep_package_only) +[CHECKING] dep_workspace_only v0.1.0 ([ROOT]/foo/dep_workspace_only) +[CHECKING] package_only v0.1.0 ([ROOT]/foo/package_only) +[CHECKING] workspace_only v0.1.0 ([ROOT]/foo/workspace_only) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -1938,19 +1930,18 @@ fn workspace_default_features2_2024() { p.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to load manifest for workspace member `[CWD]/workspace_only` -referenced by workspace at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to load manifest for workspace member `[ROOT]/foo/workspace_only` +referenced by workspace at `[ROOT]/foo/Cargo.toml` Caused by: - failed to parse manifest at `[CWD]/workspace_only/Cargo.toml` + failed to parse manifest at `[ROOT]/foo/workspace_only/Cargo.toml` Caused by: `default_features` is unsupported as of the 2024 edition; instead use `default-features` (in the `dep_workspace_only` dependency) -", - ) + +"#]]) .run(); } @@ -1972,12 +1963,13 @@ fn lib_proc_macro2() { .build(); foo.cargo("check") - .with_stderr_contains( - "\ + .with_stderr_data(str![[r#" [WARNING] `proc_macro` is deprecated in favor of `proc-macro` and will not work in the 2024 edition (in the `foo` library target) -", - ) +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2003,15 +1995,14 @@ fn lib_proc_macro2_2024() { foo.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `proc_macro` is unsupported as of the 2024 edition; instead use `proc-macro` (in the `foo` library target) -", - ) + +"#]]) .run(); } @@ -2033,13 +2024,12 @@ fn lib_proc_macro2_conflict() { .file("src/lib.rs", "") .build(); - foo.cargo("check") - .with_stderr_contains( - "\ + foo.cargo("check").with_stderr_data(str![[r#" [WARNING] `proc_macro` is redundant with `proc-macro`, preferring `proc-macro` in the `foo` library target -", - ) - .run(); +[CHECKING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -2064,14 +2054,13 @@ fn bin_proc_macro2() { .build(); foo.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [WARNING] `proc_macro` is deprecated in favor of `proc-macro` and will not work in the 2024 edition (in the `foo` binary target) -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2101,15 +2090,14 @@ fn bin_proc_macro2_2024() { foo.cargo("check") .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: `proc_macro` is unsupported as of the 2024 edition; instead use `proc-macro` (in the `foo` binary target) -", - ) + +"#]]) .run(); } @@ -2135,15 +2123,12 @@ fn bin_proc_macro2_conflict() { .file("src/main.rs", "fn main() {}") .build(); - foo.cargo("check") - .with_stderr( - "\ + foo.cargo("check").with_stderr_data(str![[r#" [WARNING] `proc_macro` is redundant with `proc-macro`, preferring `proc-macro` in the `foo` binary target -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s -", - ) - .run(); +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -2155,12 +2140,11 @@ fn invalid_toml_historically_allowed_fails() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -error: could not load Cargo configuration + .with_stderr_data(str![[r#" +[ERROR] could not load Cargo configuration Caused by: - could not parse TOML configuration in `[..]` + could not parse TOML configuration in `[ROOT]/foo/.cargo/config.toml` Caused by: TOML parse error at line 1, column 7 @@ -2169,8 +2153,8 @@ Caused by: | ^ invalid table header expected newline, `#` -", - ) + +"#]]) .run(); } @@ -2197,14 +2181,13 @@ fn ambiguous_git_reference() { p.cargo("check -v") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: dependency (bar) specification is ambiguous. Only one of `branch`, `tag` or `rev` is allowed. -", - ) + +"#]]) .run(); } @@ -2229,13 +2212,26 @@ fn fragment_in_git_url() { p.cargo("check -v") .with_status(101) - .with_stderr_contains( - "\ -[WARNING] URL fragment `#foo` in git URL is ignored for dependency (bar). \ -If you were trying to specify a specific git revision, \ -use `rev = \"foo\"` in the dependency declaration. -", - ) + // the following is needed as gitoxide has a different error message + // ... + // [..]127.0.0.1[..] + .with_stderr_data(str![[r#" +[WARNING] URL fragment `#foo` in git URL is ignored for dependency (bar). If you were trying to specify a specific git revision, use `rev = "foo"` in the dependency declaration. +[UPDATING] git repository `http://127.0.0.1/#foo` +... +[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` + +Caused by: + failed to load source for dependency `bar` + +Caused by: + Unable to update http://127.0.0.1/#foo + +Caused by: + failed to clone into: [ROOT]/home/.cargo/git/db/_empty-[HASH] +... + +"#]]) .run(); } @@ -2248,7 +2244,10 @@ fn bad_source_config1() { p.cargo("check") .with_status(101) - .with_stderr("error: no source location specified for `source.foo`, need [..]") + .with_stderr_data(str![[r#" +[ERROR] no source location specified for `source.foo`, need `registry`, `local-registry`, `directory`, or `git` defined + +"#]]) .run(); } @@ -2281,9 +2280,8 @@ fn bad_source_config2() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 [..]` + .with_stderr_data(str![[r#" +[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` Caused by: failed to load source for dependency `bar` @@ -2292,10 +2290,9 @@ Caused by: Unable to update registry `crates-io` Caused by: - could not find a configured source with the name `bar` \ - when attempting to lookup `crates-io` (configuration in [..]) -", - ) + could not find a configured source with the name `bar` when attempting to lookup `crates-io` (configuration in `[ROOT]/foo/.cargo/config.toml`) + +"#]]) .run(); } @@ -2328,9 +2325,8 @@ fn bad_source_config3() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 [..]` + .with_stderr_data(str![[r#" +[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` Caused by: failed to load source for dependency `bar` @@ -2339,9 +2335,9 @@ Caused by: Unable to update registry `crates-io` Caused by: - detected a cycle of `replace-with` sources, [..] -", - ) + detected a cycle of `replace-with` sources, the source `crates-io` is eventually replaced with itself (configuration in `[ROOT]/foo/.cargo/config.toml`) + +"#]]) .run(); } @@ -2377,9 +2373,8 @@ fn bad_source_config4() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([..])` + .with_stderr_data(str![[r#" +[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)` Caused by: failed to load source for dependency `bar` @@ -2388,10 +2383,9 @@ Caused by: Unable to update registry `crates-io` Caused by: - detected a cycle of `replace-with` sources, the source `crates-io` is \ - eventually replaced with itself (configuration in [..]) -", - ) + detected a cycle of `replace-with` sources, the source `crates-io` is eventually replaced with itself (configuration in `[ROOT]/foo/.cargo/config.toml`) + +"#]]) .run(); } @@ -2427,14 +2421,13 @@ fn bad_source_config5() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -error: configuration key `source.bar.registry` specified an invalid URL (in [..]) + .with_stderr_data(str![[r#" +[ERROR] configuration key `source.bar.registry` specified an invalid URL (in [ROOT]/foo/.cargo/config.toml) Caused by: - invalid url `not a url`: [..] -", - ) + invalid url `not a url`: relative URL without a base + +"#]]) .run(); } @@ -2460,14 +2453,13 @@ fn both_git_and_path_specified() { foo.cargo("check -v") .with_status(101) - .with_stderr( - "\ -error: failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: dependency (bar) specification is ambiguous. Only one of `git` or `path` is allowed. -", - ) + +"#]]) .run(); } @@ -2500,14 +2492,13 @@ fn bad_source_config6() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] error in [..]/foo/.cargo/config.toml: could not load config key `source.crates-io.replace-with` + .with_stderr_data(str![[r#" +[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `source.crates-io.replace-with` Caused by: - error in [..]/foo/.cargo/config.toml: `source.crates-io.replace-with` expected a string, but found a array -" - ) + error in [ROOT]/foo/.cargo/config.toml: `source.crates-io.replace-with` expected a string, but found a array + +"#]]) .run(); } @@ -2531,15 +2522,15 @@ fn ignored_git_revision() { .file("src/lib.rs", "") .build(); - let err_msg = "\ -error: failed to parse manifest at `[..]` + foo.cargo("check -v") + .with_status(101) + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: key `branch` is ignored for dependency (bar). -"; - foo.cargo("check -v") - .with_status(101) - .with_stderr(err_msg) + +"#]]) .run(); // #11540, check that [target] dependencies fail the same way. @@ -2557,7 +2548,13 @@ Caused by: ); foo.cargo("check") .with_status(101) - .with_stderr(err_msg) + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` + +Caused by: + key `branch` is ignored for dependency (bar). + +"#]]) .run(); } @@ -2592,7 +2589,10 @@ fn bad_source_config7() { p.cargo("check") .with_status(101) - .with_stderr("error: more than one source location specified for `source.foo`") + .with_stderr_data(str![[r#" +[ERROR] more than one source location specified for `source.foo` + +"#]]) .run(); } @@ -2624,10 +2624,10 @@ fn bad_source_config8() { p.cargo("check") .with_status(101) - .with_stderr( - "[ERROR] source definition `source.foo` specifies `branch`, \ - but that requires a `git` key to be specified (in [..]/foo/.cargo/config.toml)", - ) + .with_stderr_data(str![[r#" +[ERROR] source definition `source.foo` specifies `branch`, but that requires a `git` key to be specified (in [ROOT]/foo/.cargo/config.toml) + +"#]]) .run(); } @@ -2652,16 +2652,15 @@ fn bad_dependency() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] invalid type: integer `3`, expected a version string like [..] + .with_stderr_data(str![[r#" +[ERROR] invalid type: integer `3`, expected a version string like "0.9.8" or a detailed dependency like { version = "0.9.8" } --> Cargo.toml:9:23 | 9 | bar = 3 | ^ | -", - ) + +"#]]) .run(); } @@ -2686,16 +2685,15 @@ fn bad_debuginfo() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] invalid value: string \"a\", expected a boolean, 0, 1, 2, \"line-tables-only\", or \"line-directives-only\" + .with_stderr_data(str![[r#" +[ERROR] invalid value: string "a", expected a boolean, 0, 1, 2, "line-tables-only", or "line-directives-only" --> Cargo.toml:9:25 | 9 | debug = 'a' | ^^^ | -", - ) + +"#]]) .run(); } @@ -2720,16 +2718,15 @@ fn bad_debuginfo2() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] invalid type: floating point `3.6`, expected a boolean, 0, 1, 2, \"line-tables-only\", or \"line-directives-only\" + .with_stderr_data(str![[r#" +[ERROR] invalid type: floating point `3.6`, expected a boolean, 0, 1, 2, "line-tables-only", or "line-directives-only" --> Cargo.toml:9:25 | 9 | debug = 3.6 | ^^^ | -", - ) + +"#]]) .run(); } @@ -2752,16 +2749,15 @@ fn bad_opt_level() { p.cargo("check") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid type: integer `3`, expected a boolean or string --> Cargo.toml:7:25 | 7 | build = 3 | ^ | -", - ) + +"#]]) .run(); } @@ -2783,9 +2779,17 @@ fn warn_semver_metadata() { ) .file("src/lib.rs", "") .build(); - p.cargo("check") - .with_stderr_contains("[WARNING] version requirement `1.0.0+1234` for dependency `bar`[..]") - .run(); + p.cargo("check").with_stderr_data(str![[r#" +[WARNING] version requirement `1.0.0+1234` for dependency `bar` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion +[UPDATING] `dummy-registry` index +[LOCKING] 2 packages to latest compatible versions +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`) +[CHECKING] bar v1.0.0 +[CHECKING] foo v1.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]).run(); } #[cargo_test] @@ -2804,14 +2808,13 @@ fn bad_http_ssl_version() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] error in [..]/config.toml: could not load config key `http.ssl-version` + .with_stderr_data(str![[r#" +[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `http.ssl-version` Caused by: invalid type: sequence, expected a string or map -", - ) + +"#]]) .run(); } @@ -2831,14 +2834,13 @@ fn bad_http_ssl_version_range() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] error in [..]/config.toml: could not load config key `http.ssl-version` + .with_stderr_data(str![[r#" +[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `http.ssl-version` Caused by: - error in [..]/config.toml: `http.ssl-version.min` expected a string, but found a boolean -", - ) + error in [ROOT]/foo/.cargo/config.toml: `http.ssl-version.min` expected a string, but found a boolean + +"#]]) .run(); } @@ -2858,14 +2860,13 @@ fn bad_build_jobs() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] error in [..]/config.toml: could not load config key `build.jobs` + .with_stderr_data(str![[r#" +[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `build.jobs` Caused by: invalid type: map, expected an integer or string -", - ) + +"#]]) .run(); } @@ -2885,17 +2886,16 @@ fn bad_build_target() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] error in [..]/config.toml: could not load config key `build.target` + .with_stderr_data(str![[r#" +[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `build.target` Caused by: - error in [..]/config.toml: could not load config key `build.target` + error in [ROOT]/foo/.cargo/config.toml: could not load config key `build.target` Caused by: invalid type: map, expected a string or array -", - ) + +"#]]) .run(); } @@ -2921,21 +2921,17 @@ fn bad_target_cfg() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] error in [..]/foo/.cargo/config.toml: \ -could not load config key `target.'cfg(not(target_os = \"none\"))'.runner` + .with_stderr_data(str![[r#" +[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `target.'cfg(not(target_os = "none"))'.runner` Caused by: - error in [..]/foo/.cargo/config.toml: \ - could not load config key `target.'cfg(not(target_os = \"none\"))'.runner` + error in [ROOT]/foo/.cargo/config.toml: could not load config key `target.'cfg(not(target_os = "none"))'.runner` Caused by: - invalid configuration for key `target.'cfg(not(target_os = \"none\"))'.runner` - expected a string or array of strings, but found a boolean for \ - `target.'cfg(not(target_os = \"none\"))'.runner` in [..]/foo/.cargo/config.toml -", - ) + invalid configuration for key `target.'cfg(not(target_os = "none"))'.runner` + expected a string or array of strings, but found a boolean for `target.'cfg(not(target_os = "none"))'.runner` in [ROOT]/foo/.cargo/config.toml + +"#]]) .run(); } @@ -2963,10 +2959,10 @@ fn bad_target_links_overrides() { p.cargo("check") .with_status(101) - .with_stderr( - "[ERROR] Only `-l` and `-L` flags are allowed in target config \ - `target.[..].rustc-flags` (in [..]foo/.cargo/config.toml): `foo`", - ) + .with_stderr_data(str![[r" +[ERROR] Only `-l` and `-L` flags are allowed in target config `target.[..].rustc-flags` (in [..]foo/.cargo/config.toml): `foo` + +"]]) .run(); p.change_file( @@ -2980,7 +2976,10 @@ fn bad_target_links_overrides() { ); p.cargo("check") .with_status(101) - .with_stderr("[ERROR] `warning` is not supported in build script overrides") + .with_stderr_data(str![[r#" +[ERROR] `warning` is not supported in build script overrides + +"#]]) .run(); } @@ -3000,13 +2999,11 @@ fn redefined_sources() { p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] source `foo` defines source registry `crates-io`, \ - but that source is already defined by `crates-io` -note: Sources are not allowed to be defined multiple times. -", - ) + .with_stderr_data(str![[r#" +[ERROR] source `foo` defines source registry `crates-io`, but that source is already defined by `crates-io` +[NOTE] Sources are not allowed to be defined multiple times. + +"#]]) .run(); p.change_file( @@ -3023,13 +3020,11 @@ note: Sources are not allowed to be defined multiple times. // Name is `[..]` because we can't guarantee the order. p.cargo("check") .with_status(101) - .with_stderr( - "\ -[ERROR] source `[..]` defines source dir [..]/foo/index, \ - but that source is already defined by `[..]` -note: Sources are not allowed to be defined multiple times. -", - ) + .with_stderr_data(str![[r#" +[ERROR] source `[..]` defines source dir [ROOT]/foo/index, but that source is already defined by `[..]` +[NOTE] Sources are not allowed to be defined multiple times. + +"#]]) .run(); } @@ -3054,14 +3049,14 @@ fn bad_trim_paths() { p.cargo("check -Ztrim-paths") .masquerade_as_nightly_cargo(&["trim-paths"]) .with_status(101) - .with_stderr("\ -[ERROR] expected a boolean, \"none\", \"diagnostics\", \"macro\", \"object\", \"all\", or an array with these options + .with_stderr_data(str![[r#" +[ERROR] expected a boolean, "none", "diagnostics", "macro", "object", "all", or an array with these options --> Cargo.toml:8:30 | -8 | trim-paths = \"split-debuginfo\" +8 | trim-paths = "split-debuginfo" | ^^^^^^^^^^^^^^^^^ | -", - ) + +"#]]) .run(); } diff --git a/tests/testsuite/bad_manifest_path.rs b/tests/testsuite/bad_manifest_path.rs index d6d09694df0..6a7613908cc 100644 --- a/tests/testsuite/bad_manifest_path.rs +++ b/tests/testsuite/bad_manifest_path.rs @@ -1,8 +1,7 @@ //! Tests for invalid --manifest-path arguments. -#![allow(deprecated)] - -use cargo_test_support::{basic_bin_manifest, main_file, project}; +use cargo_test_support::prelude::*; +use cargo_test_support::{basic_bin_manifest, main_file, project, str}; #[track_caller] fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) { @@ -16,10 +15,7 @@ fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) { .arg(manifest_path_argument) .cwd(p.root().parent().unwrap()) .with_status(101) - .with_stderr( - "[ERROR] the manifest-path must be a path \ - to a Cargo.toml file", - ) + .with_stderr_data("[ERROR] the manifest-path must be a path to a Cargo.toml file\n") .run(); } @@ -36,8 +32,8 @@ fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) { .arg(manifest_path_argument) .cwd(p.root().parent().unwrap()) .with_status(101) - .with_stderr(format!( - "[ERROR] manifest path `{}` does not exist", + .with_stderr_data(format!( + "[ERROR] manifest path `{}` does not exist\n", expected_path )) .run(); @@ -333,9 +329,12 @@ fn verify_project_dir_containing_cargo_toml() { p.cargo("verify-project --manifest-path foo") .cwd(p.root().parent().unwrap()) .with_status(1) - .with_stdout( - "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ - ", + .with_stdout_data( + str![[r#" +{"invalid":"the manifest-path must be a path to a Cargo.toml file"} + +"#]] + .json_lines(), ) .run(); } @@ -350,9 +349,12 @@ fn verify_project_dir_plus_file() { p.cargo("verify-project --manifest-path foo/bar") .cwd(p.root().parent().unwrap()) .with_status(1) - .with_stdout( - "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ - ", + .with_stdout_data( + str![[r#" +{"invalid":"the manifest-path must be a path to a Cargo.toml file"} + +"#]] + .json_lines(), ) .run(); } @@ -367,9 +369,12 @@ fn verify_project_dir_plus_path() { p.cargo("verify-project --manifest-path foo/bar/baz") .cwd(p.root().parent().unwrap()) .with_status(1) - .with_stdout( - "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ - ", + .with_stdout_data( + str![[r#" +{"invalid":"the manifest-path must be a path to a Cargo.toml file"} + +"#]] + .json_lines(), ) .run(); } @@ -380,9 +385,12 @@ fn verify_project_dir_to_nonexistent_cargo_toml() { p.cargo("verify-project --manifest-path foo/bar/baz/Cargo.toml") .cwd(p.root().parent().unwrap()) .with_status(1) - .with_stdout( - "{\"invalid\":\"manifest path `foo[..]bar[..]baz[..]Cargo.toml` does not exist\"}\ - ", + .with_stdout_data( + str![[r#" +{"invalid":"manifest path `foo/bar/baz/Cargo.toml` does not exist"} + +"#]] + .json_lines(), ) .run(); } diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 1cb3f8c19a0..2b3554de75f 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1,9 +1,8 @@ //! Tests for the `cargo bench` command. -#![allow(deprecated)] - use cargo_test_support::paths::CargoPathExt; -use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; +use cargo_test_support::prelude::*; +use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project, str}; #[cargo_test(nightly, reason = "bench")] fn cargo_bench_simple() { @@ -35,16 +34,29 @@ fn cargo_bench_simple() { p.cargo("build").run(); assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("hello\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +hello + +"#]]) + .run(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] foo v0.5.0 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) - .with_stdout_contains("test bench_hello ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/main.rs (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test bench_hello ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -80,15 +92,28 @@ fn bench_bench_implicit() { .build(); p.cargo("bench --benches") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/mybench-[..][EXE]) -", - ) - .with_stdout_contains("test run2 ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) +[RUNNING] [..] (target/release/deps/mybench-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test run1 ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test run2 ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -124,14 +149,21 @@ fn bench_bin_implicit() { .build(); p.cargo("bench --bins") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -", - ) - .with_stdout_contains("test run1 ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test run1 ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -157,14 +189,21 @@ fn bench_tarname() { .build(); p.cargo("bench --bench bin2") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/bin2-[..][EXE]) -", - ) - .with_stdout_contains("test run2 ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/bin2-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test run2 ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -197,10 +236,15 @@ fn bench_multiple_targets() { ) .build(); + // This should not have anything about `run3` in it. p.cargo("bench --bench bin1 --bench bin2") - .with_stdout_contains("test run1 ... bench: [..]") - .with_stdout_contains("test run2 ... bench: [..]") - .with_stdout_does_not_contain("[..]run3[..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] benches/bin1.rs (target/release/deps/bin1-[HASH][EXE]) +[RUNNING] benches/bin2.rs (target/release/deps/bin2-[HASH][EXE]) + +"#]]) .run(); } @@ -221,14 +265,22 @@ fn cargo_bench_verbose() { .build(); p.cargo("bench -v hello") - .with_stderr( - "\ -[COMPILING] foo v0.5.0 ([CWD]) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) [RUNNING] `rustc [..] src/main.rs [..]` -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] `[..]target/release/deps/foo-[..][EXE] hello --bench`", - ) - .with_stdout_contains("test bench_hello ... bench: [..]") +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] `[..]target/release/deps/foo-[HASH][EXE] hello --bench` + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test bench_hello ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -269,9 +321,27 @@ fn many_similar_names() { .build(); p.cargo("bench") - .with_stdout_contains("test bin_bench ... bench:[..]") - .with_stdout_contains("test lib_bench ... bench:[..]") - .with_stdout_contains("test bench_bench ... bench:[..]") + .with_stdout_data(str![[r#" + +running 1 test +test lib_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bin_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -304,22 +374,44 @@ fn cargo_bench_failing_test() { p.cargo("build").run(); assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("hello\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +hello + +"#]]) + .run(); // Force libtest into serial execution so that the test header will be printed. p.cargo("bench -- --test-threads=1") - .with_stdout_contains("test bench_hello ...[..]") - .with_stderr_contains( - "\ -[COMPILING] foo v0.5.0 ([CWD])[..] -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) - .with_stdout_contains("[..]thread '[..]' panicked at[..]") - .with_stdout_contains("[..]assertion [..]failed[..]") - .with_stdout_contains("[..]left: [..]\"hello\"[..]") - .with_stdout_contains("[..]right: [..]\"nope\"[..]") - .with_stdout_contains("[..]src/main.rs:15[..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) +[ERROR] bench failed, to rerun pass `--bin foo` + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test bench_hello ... FAILED + +failures: + +---- bench_hello stdout ---- +thread 'main' panicked at src/main.rs:15:17: +assertion `left == right` failed + left: "hello" + right: "nope" +[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace + + +failures: + bench_hello + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .with_status(101) .run(); } @@ -377,15 +469,28 @@ fn bench_with_lib_dep() { .build(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/baz-[..][EXE])", - ) - .with_stdout_contains("test lib_bench ... bench: [..]") - .with_stdout_contains("test bin_bench ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) +[RUNNING] [..] (target/release/deps/baz-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test lib_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bin_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -438,15 +543,23 @@ fn bench_with_deep_lib_dep() { .build(); p.cargo("bench") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] foo v0.0.1 ([..]) -[COMPILING] bar v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/bar-[..][EXE])", - ) - .with_stdout_contains("test bar_bench ... bench: [..]") +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[COMPILING] bar v0.0.1 ([ROOT]/bar) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/bar-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test bar_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -494,15 +607,28 @@ fn external_bench_explicit() { .build(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/bench-[..][EXE])", - ) - .with_stdout_contains("test internal_bench ... bench: [..]") - .with_stdout_contains("test external_bench ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) +[RUNNING] [..] (target/release/deps/bench-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test internal_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test external_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -537,15 +663,28 @@ fn external_bench_implicit() { .build(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/external-[..][EXE])", - ) - .with_stdout_contains("test internal_bench ... bench: [..]") - .with_stdout_contains("test external_bench ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) +[RUNNING] [..] (target/release/deps/external-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test internal_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test external_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -597,9 +736,8 @@ fn bench_autodiscover_2015() { .build(); p.cargo("bench bench_basic") - .with_stderr( - "warning: \ -An explicit [[bench]] section is specified in Cargo.toml which currently + .with_stderr_data(str![[r#" +[WARNING] An explicit [[bench]] section is specified in Cargo.toml which currently disables Cargo from automatically inferring other benchmark targets. This inference behavior will change in the Rust 2018 edition and the following files will be included as a benchmark target: @@ -614,11 +752,11 @@ automatically infer them to be a target, such as in subfolders. For more information on this warning you can consult https://github.com/rust-lang/cargo/issues/5330 -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -", - ) +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) + +"#]]) .run(); } @@ -651,21 +789,38 @@ fn pass_through_command_line() { .build(); p.cargo("bench bar") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) - .with_stdout_contains("test bar ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test bar ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 1 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); p.cargo("bench foo") - .with_stderr( - "[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) - .with_stdout_contains("test foo ... bench: [..]") + .with_stderr_data(str![[r#" +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 1 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -737,14 +892,28 @@ fn lib_bin_same_name() { .build(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) - .with_stdout_contains_n("test [..] ... bench: [..]", 2) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test lib_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bin_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -782,15 +951,28 @@ fn lib_with_standard_name() { .build(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/syntax-[..][EXE]) -[RUNNING] [..] (target/release/deps/bench-[..][EXE])", - ) - .with_stdout_contains("test foo_bench ... bench: [..]") - .with_stdout_contains("test bench ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] syntax v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/syntax-[HASH][EXE]) +[RUNNING] [..] (target/release/deps/bench-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test foo_bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -831,13 +1013,21 @@ fn lib_with_standard_name2() { .build(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/syntax-[..][EXE])", - ) - .with_stdout_contains("test bench ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] syntax v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/syntax-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test bench ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -904,33 +1094,61 @@ fn bench_dylib() { .build(); p.cargo("bench -v") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.0.1 ([CWD]/bar) +[COMPILING] bar v0.0.1 ([ROOT]/foo/bar) [RUNNING] [..] -C opt-level=3 [..] -[COMPILING] foo v0.0.1 ([CWD]) +[COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` -[RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", - ) - .with_stdout_contains_n("test foo ... bench: [..]", 2) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] `[..]target/release/deps/foo-[HASH][EXE] --bench` +[RUNNING] `[..]target/release/deps/bench-[HASH][EXE] --bench` + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); p.root().move_into_the_past(); p.cargo("bench -v") - .with_stderr( - "\ -[FRESH] bar v0.0.1 ([CWD]/bar) -[FRESH] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` -[RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", - ) - .with_stdout_contains_n("test foo ... bench: [..]", 2) + .with_stderr_data(str![[r#" +[FRESH] bar v0.0.1 ([ROOT]/foo/bar) +[FRESH] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] `[..]target/release/deps/foo-[HASH][EXE] --bench` +[RUNNING] `[..]target/release/deps/bench-[HASH][EXE] --bench` + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -962,21 +1180,38 @@ fn bench_twice_with_build_cmd() { .build(); p.cargo("bench") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) - .with_stdout_contains("test foo ... bench: [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); p.cargo("bench") - .with_stderr( - "[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) - .with_stdout_contains("test foo ... bench: [..]") + .with_stderr_data(str![[r#" +[FINISHED] `bench` profile [optimized] target(s) in [..] +[RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1049,18 +1284,31 @@ fn bench_with_examples() { .build(); p.cargo("bench -v") - .with_stderr( - "\ -[COMPILING] foo v6.6.6 ([CWD]) + .with_stderr_data(str![[r#" +[COMPILING] foo v6.6.6 ([ROOT]/foo) [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` -[FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] `[CWD]/target/release/deps/foo-[..][EXE] --bench` -[RUNNING] `[CWD]/target/release/deps/testb1-[..][EXE] --bench`", - ) - .with_stdout_contains("test bench_bench1 ... bench: [..]") - .with_stdout_contains("test bench_bench2 ... bench: [..]") +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] `[ROOT]/foo/target/release/deps/foo-[HASH][EXE] --bench` +[RUNNING] `[ROOT]/foo/target/release/deps/testb1-[HASH][EXE] --bench` + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test bench_bench1 ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_bench2 ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1091,13 +1339,21 @@ fn test_a_bench() { .build(); p.cargo("test") - .with_stderr( - "\ -[COMPILING] foo v0.1.0 ([..]) -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/b-[..][EXE])", - ) - .with_stdout_contains("test foo ... ok") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] [..] (target/debug/deps/b-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test foo ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1121,14 +1377,13 @@ fn test_bench_no_run() { .build(); p.cargo("bench --no-run") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([..]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -[EXECUTABLE] benches src/lib.rs (target/release/deps/foo-[..][EXE]) -[EXECUTABLE] benches/bbaz.rs (target/release/deps/bbaz-[..][EXE]) -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[EXECUTABLE] benches src/lib.rs (target/release/deps/foo-[HASH][EXE]) +[EXECUTABLE] benches/bbaz.rs (target/release/deps/bbaz-[HASH][EXE]) + +"#]]) .run(); } @@ -1152,12 +1407,11 @@ fn test_bench_no_run_emit_json() { .build(); p.cargo("bench --no-run --message-format json") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([..]) -[FINISHED] `bench` profile [optimized] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1203,23 +1457,60 @@ fn test_bench_no_fail_fast() { p.cargo("bench --no-fail-fast -- --test-threads=1") .with_status(101) - .with_stderr( - "\ -[COMPILING] foo v0.5.0 [..] -[FINISHED] `bench` profile [..] -[RUNNING] unittests src/main.rs (target/release/deps/foo[..]) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/main.rs (target/release/deps/foo-[HASH][EXE]) [ERROR] bench failed, to rerun pass `--bin foo` -[RUNNING] benches/b1.rs (target/release/deps/b1[..]) +[RUNNING] benches/b1.rs (target/release/deps/b1-[HASH][EXE]) [ERROR] bench failed, to rerun pass `--bench b1` [ERROR] 2 targets failed: `--bin foo` `--bench b1` -", - ) - .with_stdout_contains("running 2 tests") - .with_stdout_contains("test bench_hello [..]") - .with_stdout_contains("test bench_nope [..]") - .with_stdout_contains("test b1_fail [..]") + +"#]]) + .with_stdout_data(str![[r#" + +running 2 tests +test bench_hello ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) +test bench_nope ... FAILED + +failures: + +---- bench_nope stdout ---- +thread 'main' panicked at src/main.rs:20:17: +assertion `left == right` failed + left: "nope" + right: "hello" +[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace + + +failures: + bench_nope + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test b1_fail ... FAILED + +failures: + +---- b1_fail stdout ---- +thread 'main' panicked at benches/b1.rs:5:54: +assertion `left == right` failed + left: 1 + right: 2 +[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace + + +failures: + b1_fail + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1308,10 +1599,25 @@ fn test_bench_multiple_packages() { .build(); p.cargo("bench -p bar -p baz") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bbaz-[..][EXE])") - .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bbar-[..][EXE])") - .with_stdout_contains("test bench_bar ... bench: [..]") + .with_stderr_data(str![[r#" +[RUNNING] [..] (target/release/deps/bbaz-[HASH][EXE]) +[RUNNING] [..] (target/release/deps/bbar-[HASH][EXE]) + +"#]]) + .with_stderr_data( + str![[r#" +[LOCKING] 3 packages to latest compatible versions +[COMPILING] bar v0.1.0 ([ROOT]/bar) +[COMPILING] baz v0.1.0 ([ROOT]/baz) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/release/deps/bar-[HASH][EXE]) +[RUNNING] benches/bbar.rs (target/release/deps/bbar-[HASH][EXE]) +[RUNNING] unittests src/lib.rs (target/release/deps/baz-[HASH][EXE]) +[RUNNING] benches/bbaz.rs (target/release/deps/bbaz-[HASH][EXE]) + +"#]] + .unordered(), + ) .run(); } @@ -1362,10 +1668,42 @@ fn bench_all_workspace() { .build(); p.cargo("bench --workspace") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") - .with_stdout_contains("test bench_bar ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/foo-[..][EXE])") - .with_stdout_contains("test bench_foo ... bench: [..]") + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/release/deps/bar-[HASH][EXE]) +[RUNNING] benches/bar.rs (target/release/deps/bar-[HASH][EXE]) +[RUNNING] unittests src/main.rs (target/release/deps/foo-[HASH][EXE]) +[RUNNING] benches/foo.rs (target/release/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_bar ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_foo ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1407,11 +1745,20 @@ fn bench_all_exclude() { .build(); p.cargo("bench --workspace --exclude baz") - .with_stdout_contains( - "\ + .with_stdout_data(str![[r#" + running 1 test -test bar ... bench: [..] ns/iter (+/- [..])", - ) +test bar ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1453,11 +1800,20 @@ fn bench_all_exclude_glob() { .build(); p.cargo("bench --workspace --exclude '*z'") - .with_stdout_contains( - "\ + .with_stdout_data(str![[r#" + running 1 test -test bar ... bench: [..] ns/iter (+/- [..])", - ) +test bar ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1503,10 +1859,45 @@ fn bench_all_virtual_manifest() { // The order in which bar and baz are built is not guaranteed p.cargo("bench --workspace") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/baz-[..][EXE])") - .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") - .with_stdout_contains("test bench_bar ... bench: [..]") + .with_stderr_data( + str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] baz v0.1.0 ([ROOT]/foo/baz) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/release/deps/bar-[HASH][EXE]) +[RUNNING] benches/bar.rs (target/release/deps/bar-[HASH][EXE]) +[RUNNING] unittests src/lib.rs (target/release/deps/baz-[HASH][EXE]) +[RUNNING] benches/baz.rs (target/release/deps/baz-[HASH][EXE]) + +"#]] + .unordered(), + ) + .with_stdout_data(str![[r#" + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_bar ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_baz ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1550,12 +1941,30 @@ fn bench_virtual_manifest_glob() { ) .build(); - // The order in which bar and baz are built is not guaranteed + // This should not have `bar` built or benched p.cargo("bench -p '*z'") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/baz-[..][EXE])") - .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_does_not_contain("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") - .with_stdout_does_not_contain("test bench_bar ... bench: [..]") + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] baz v0.1.0 ([ROOT]/foo/baz) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/release/deps/baz-[HASH][EXE]) +[RUNNING] benches/baz.rs (target/release/deps/baz-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_baz ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1591,11 +2000,15 @@ fn legacy_bench_name() { .build(); p.cargo("bench") - .with_stderr_contains( - "\ -[WARNING] path `[..]src/bench.rs` was erroneously implicitly accepted for benchmark `bench`, -please set bench.path in Cargo.toml", - ) + .with_stderr_data(str![[r#" +[WARNING] path `src/bench.rs` was erroneously implicitly accepted for benchmark `bench`, +please set bench.path in Cargo.toml +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/release/deps/foo-[HASH][EXE]) +[RUNNING] src/bench.rs (target/release/deps/bench-[HASH][EXE]) + +"#]]) .run(); } @@ -1638,10 +2051,45 @@ fn bench_virtual_manifest_all_implied() { // The order in which bar and baz are built is not guaranteed p.cargo("bench") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/baz-[..][EXE])") - .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") - .with_stdout_contains("test bench_bar ... bench: [..]") + .with_stderr_data( + str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] baz v0.1.0 ([ROOT]/foo/baz) +[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/release/deps/bar-[HASH][EXE]) +[RUNNING] benches/bar.rs (target/release/deps/bar-[HASH][EXE]) +[RUNNING] unittests src/lib.rs (target/release/deps/baz-[HASH][EXE]) +[RUNNING] benches/baz.rs (target/release/deps/baz-[HASH][EXE]) + +"#]] + .unordered(), + ) + .with_stdout_data(str![[r#" + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_bar ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test bench_baz ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1663,31 +2111,13 @@ fn json_artifact_includes_executable_for_benchmark() { .build(); p.cargo("bench --no-run --message-format=json") - .with_json( - r#" - { - "executable": "[..]/foo/target/release/deps/benchmark-[..][EXE]", - "features": [], - "filenames": "{...}", - "fresh": false, - "package_id": "path+file:///[..]/foo#0.0.1", - "manifest_path": "[..]", - "profile": "{...}", - "reason": "compiler-artifact", - "target": { - "crate_types": [ "bin" ], - "kind": [ "bench" ], - "doc": false, - "doctest": false, - "edition": "2015", - "name": "benchmark", - "src_path": "[..]/foo/benches/benchmark.rs", - "test": false - } - } + .with_stdout_data( + str![[r#" +{"executable":"[ROOT]/foo/target/release/deps/benchmark-[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":["bin"],"doc":false,"doctest":false,"edition":"2015","kind":["bench"],"name":"benchmark","src_path":"[ROOT]/foo/benches/benchmark.rs","test":false}} +{"reason":"build-finished","success":true} - {"reason": "build-finished", "success": true} - "#, +"#]] + .json_lines(), ) .run(); } @@ -1719,12 +2149,12 @@ fn cargo_bench_print_env_verbose() { ) .build(); p.cargo("bench -vv") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] rustc[..]` + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `[..]CARGO_MANIFEST_DIR=[ROOT]/foo[..] rustc[..]` [FINISHED] `bench` profile [optimized] target(s) in [..] -[RUNNING] `[..]CARGO_MANIFEST_DIR=[CWD][..] [CWD]/target/release/deps/foo-[..][EXE] --bench`", - ) +[RUNNING] `[..]CARGO_MANIFEST_DIR=[ROOT]/foo[..] [ROOT]/foo/target/release/deps/foo-[HASH][EXE] --bench` + +"#]]) .run(); }