diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 3352ee3fed85..1bbe75a75dc7 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1,7 +1,5 @@ //! Tests for the `cargo build` command. -#![allow(deprecated)] - use cargo::{ core::compiler::CompileMode, core::{Shell, Workspace}, @@ -34,7 +32,12 @@ fn cargo_compile_simple() { p.cargo("build").run(); assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("i am foo\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +i am foo + +"#]]) + .run(); } #[cargo_test] @@ -81,6 +84,7 @@ fn build_with_symlink_to_path_dependency_with_build_script_in_git() { cargo_process("build").run() } +#[allow(deprecated)] #[cargo_test] fn cargo_fail_with_no_stderr() { let p = project() @@ -104,19 +108,31 @@ fn cargo_compile_incremental() { p.cargo("build -v") .env("CARGO_INCREMENTAL", "1") - .with_stderr_contains( - "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", - ) + .with_stderr_data(str![[r#" +[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`, +please set bin.path in Cargo.toml +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `rustc [..] -C incremental=[ROOT]/foo/target/debug/incremental[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("test -v") .env("CARGO_INCREMENTAL", "1") - .with_stderr_contains( - "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", - ) + .with_stderr_data(str![[r#" +[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`, +please set bin.path in Cargo.toml +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `rustc [..] -C incremental=[ROOT]/foo/target/debug/incremental[..]` +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH]` + +"#]]) .run(); } +#[allow(deprecated)] #[cargo_test] fn incremental_profile() { let p = project() @@ -146,12 +162,22 @@ fn incremental_profile() { p.cargo("build -v") .env("CARGO_INCREMENTAL", "1") - .with_stderr_contains("[..]C incremental=[..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `rustc [..] -C incremental=[ROOT]/foo/target/debug/incremental[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("build --release -v") .env_remove("CARGO_INCREMENTAL") - .with_stderr_contains("[..]C incremental=[..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `rustc [..] -C incremental=[ROOT]/foo/target/release/incremental[..]` +[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("build --release -v") @@ -160,6 +186,7 @@ fn incremental_profile() { .run(); } +#[allow(deprecated)] #[cargo_test] fn incremental_config() { let p = project() @@ -192,17 +219,16 @@ fn cargo_compile_with_redundant_default_mode() { .build(); p.cargo("build --debug") - .with_stderr( - "\ -error: unexpected argument '--debug' found + .with_stderr_data(str![[r#" +[ERROR] unexpected argument '--debug' found tip: `--debug` is the default for `cargo build`; instead `--release` is supported Usage: cargo[EXE] build [OPTIONS] For more information, try '--help'. -", - ) + +"#]]) .with_status(1) .run(); } @@ -215,21 +241,21 @@ fn cargo_compile_with_unsupported_short_config_flag() { .build(); p.cargo("build -c net.git-fetch-with-cli=true") - .with_stderr( - "\ -error: unexpected argument '-c' found + .with_stderr_data(str![[r#" +[ERROR] unexpected argument '-c' found tip: a similar argument exists: '--config' Usage: cargo[EXE] build [OPTIONS] For more information, try '--help'. -", - ) + +"#]]) .with_status(1) .run(); } +#[allow(deprecated)] #[cargo_test] fn cargo_compile_with_workspace_excluded() { let p = project().file("src/main.rs", "fn main() {}").build(); @@ -263,17 +289,16 @@ fn cargo_compile_with_wrong_manifest_path_flag() { p.cargo("build --path foo/Cargo.toml") .cwd(p.root().parent().unwrap()) - .with_stderr( - "\ -error: unexpected argument '--path' found + .with_stderr_data(str![[r#" +[ERROR] unexpected argument '--path' found tip: a similar argument exists: '--manifest-path' Usage: cargo[EXE] build [OPTIONS] For more information, try '--help'. -", - ) + +"#]]) .with_status(1) .run(); } @@ -285,19 +310,19 @@ fn chdir_gated() { .build(); p.cargo("-C foo build") .cwd(p.root().parent().unwrap()) - .with_stderr( - "error: the `-C` flag is unstable, \ - pass `-Z unstable-options` on the nightly channel to enable it", - ) + .with_stderr_data(str![[r#" +[ERROR] the `-C` flag is unstable, pass `-Z unstable-options` on the nightly channel to enable it + +"#]]) .with_status(101) .run(); // No masquerade should also fail. p.cargo("-C foo -Z unstable-options build") .cwd(p.root().parent().unwrap()) - .with_stderr( - "error: the `-C` flag is unstable, \ - pass `-Z unstable-options` on the nightly channel to enable it", - ) + .with_stderr_data(str![[r#" +[ERROR] the `-C` flag is unstable, pass `-Z unstable-options` on the nightly channel to enable it + +"#]]) .with_status(101) .run(); } @@ -328,18 +353,17 @@ fn cargo_compile_with_unsupported_short_unstable_feature_flag() { p.cargo("-zunstable-options -C foo build") .masquerade_as_nightly_cargo(&["chdir"]) .cwd(p.root().parent().unwrap()) - .with_stderr( - "\ -error: unexpected argument '-z' found + .with_stderr_data(str![[r#" +[ERROR] unexpected argument '-z' found tip: a similar argument exists: '-Z' -Usage: cargo [..][OPTIONS] [COMMAND] - cargo [..][OPTIONS] -Zscript [ARGS]... +Usage: cargo[EXE] [+toolchain] [OPTIONS] [COMMAND] + cargo[EXE] [+toolchain] [OPTIONS] -Zscript [ARGS]... For more information, try '--help'. -", - ) + +"#]]) .with_status(1) .run(); } @@ -356,16 +380,20 @@ fn cargo_compile_directory_not_cwd_with_invalid_config() { .masquerade_as_nightly_cargo(&["chdir"]) .cwd(p.root().parent().unwrap()) .with_status(101) - .with_stderr_contains( - "\ + .with_stderr_data(str![[r#" +[ERROR] could not load Cargo configuration + +Caused by: + could not parse TOML configuration in `[ROOT]/foo/.cargo/config.toml` + Caused by: TOML parse error at line 1, column 1 | 1 | ! | ^ invalid key -", - ) + +"#]]) .run(); } @@ -375,14 +403,13 @@ fn cargo_compile_with_invalid_manifest() { p.cargo("build") .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: virtual manifests must be configured with [workspace] -", - ) + +"#]]) .run(); } @@ -400,17 +427,16 @@ fn cargo_compile_with_invalid_manifest2() { p.cargo("build") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid string -expected `\"`, `'` +expected `"`, `'` --> Cargo.toml:3:23 | 3 | foo = bar | ^ | -", - ) + +"#]]) .run(); } @@ -420,17 +446,16 @@ fn cargo_compile_with_invalid_manifest3() { p.cargo("build --manifest-path src/Cargo.toml") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid string -expected `\"`, `'` +expected `"`, `'` --> src/Cargo.toml:1:5 | 1 | a = bar | ^ | -", - ) + +"#]]) .run(); } @@ -458,15 +483,14 @@ fn cargo_compile_duplicate_build_targets() { .build(); p.cargo("build") - .with_stderr( - "\ -warning: file `[..]main.rs` found to be present in multiple build targets: + .with_stderr_data(str![[r#" +[WARNING] file `[ROOT]/foo/src/main.rs` found to be present in multiple build targets: * `lib` target `main` * `bin` target `foo` -[COMPILING] foo v0.0.1 ([..]) -[FINISHED] [..] -", - ) +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -478,16 +502,15 @@ fn cargo_compile_with_invalid_version() { p.cargo("build") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] unexpected end of input while parsing minor version number --> Cargo.toml:4:19 | -4 | version = \"1.0\" +4 | version = "1.0" | ^^^^^ | -", - ) + +"#]]) .run(); } @@ -499,16 +522,15 @@ fn cargo_compile_with_empty_package_name() { p.cargo("build") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] package name cannot be empty --> Cargo.toml:3:16 | -3 | name = \"\" +3 | name = "" | ^^ | -", - ) + +"#]]) .run(); } @@ -520,16 +542,15 @@ fn cargo_compile_with_invalid_package_name() { p.cargo("build") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid character `@` in package name: `foo@bar`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters) --> Cargo.toml:3:16 | -3 | name = \"foo@bar\" +3 | name = "foo@bar" | ^^^^^^^^^ | -", - ) + +"#]]) .run(); } @@ -553,14 +574,13 @@ fn cargo_compile_with_invalid_bin_target_name() { p.cargo("build") .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: binary target names cannot be empty -", - ) + +"#]]) .run(); } @@ -584,14 +604,13 @@ fn cargo_compile_with_forbidden_bin_target_name() { p.cargo("build") .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: the binary target name `build` is forbidden, it conflicts with cargo's build directory names -", - ) + +"#]]) .run(); } @@ -618,14 +637,13 @@ fn cargo_compile_with_bin_and_crate_type() { p.cargo("build") .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: - the target `the_foo_bin` is a binary and can't have any crate-types set \ -(currently \"cdylib, rlib\")", - ) + the target `the_foo_bin` is a binary and can't have any crate-types set (currently "cdylib, rlib") + +"#]]) .run(); } @@ -703,13 +721,13 @@ fn cargo_compile_with_bin_and_proc() { p.cargo("build") .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: - the target `the_foo_bin` is a binary and can't have `proc-macro` set `true`", - ) + the target `the_foo_bin` is a binary and can't have `proc-macro` set `true` + +"#]]) .run(); } @@ -733,14 +751,13 @@ fn cargo_compile_with_invalid_lib_target_name() { p.cargo("build") .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: library target names cannot be empty -", - ) + +"#]]) .run(); } @@ -764,17 +781,16 @@ fn cargo_compile_with_invalid_non_numeric_dep_version() { p.cargo("build") .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: failed to parse the version requirement `y` for dependency `crossbeam` Caused by: unexpected character 'y' while parsing major version number -", - ) + +"#]]) .run(); } @@ -784,7 +800,10 @@ fn cargo_compile_without_manifest() { p.cargo("build") .with_status(101) - .with_stderr("[ERROR] could not find `Cargo.toml` in `[..]` or any parent directory") + .with_stderr_data(str![[r#" +[ERROR] could not find `Cargo.toml` in `[ROOT]/foo` or any parent directory + +"#]]) .run(); } @@ -799,10 +818,10 @@ fn cargo_compile_with_lowercase_cargo_toml() { p.cargo("build") .with_status(101) - .with_stderr( - "[ERROR] could not find `Cargo.toml` in `[..]` or any parent directory, \ - but found cargo.toml please try to rename it to Cargo.toml", - ) + .with_stderr_data(str![[r#" +[ERROR] could not find `Cargo.toml` in `[ROOT]/foo` or any parent directory, but found cargo.toml please try to rename it to Cargo.toml + +"#]]) .run(); } @@ -815,13 +834,20 @@ fn cargo_compile_with_invalid_code() { p.cargo("build") .with_status(101) - .with_stderr_contains( - "[ERROR] could not compile `foo` (bin \"foo\") due to 1 previous error\n", - ) + .with_stderr_data(str![[r#" +[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`, +please set bin.path in Cargo.toml +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[ERROR] [..] +... +[ERROR] could not compile `foo` (bin "foo") due to 1 previous error + +"#]]) .run(); assert!(p.root().join("Cargo.lock").is_file()); } +#[allow(deprecated)] #[cargo_test] fn cargo_compile_with_invalid_code_in_deps() { let p = project() @@ -867,7 +893,16 @@ fn cargo_compile_with_warnings_in_the_root_package() { .build(); p.cargo("build") - .with_stderr_contains("[WARNING] [..]dead[..]") + .with_stderr_data(str![[r#" +[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`, +please set bin.path in Cargo.toml +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[WARNING] [..]dead[..] +... +[WARNING] `foo` (bin "foo") generated 1 warning +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -907,12 +942,28 @@ fn cargo_compile_with_warnings_in_a_dep_package() { .build(); p.cargo("build") - .with_stderr_contains("[WARNING] [..]dead[..]") + .with_stderr_data(str![[r#" +[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`, +please set bin.path in Cargo.toml +[LOCKING] 2 packages to latest compatible versions +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[WARNING] [..]dead[..] +... +[WARNING] `bar` (lib) generated 1 warning +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("test passed\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +test passed + +"#]]) + .run(); } #[cargo_test] @@ -977,7 +1028,12 @@ fn cargo_compile_with_nested_deps_inferred() { assert!(!p.bin("libbar.rlib").is_file()); assert!(!p.bin("libbaz.rlib").is_file()); - p.process(&p.bin("foo")).with_stdout("test passed\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +test passed + +"#]]) + .run(); } #[cargo_test] @@ -1042,7 +1098,12 @@ fn cargo_compile_with_nested_deps_correct_bin() { assert!(!p.bin("libbar.rlib").is_file()); assert!(!p.bin("libbaz.rlib").is_file()); - p.process(&p.bin("foo")).with_stdout("test passed\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +test passed + +"#]]) + .run(); } #[cargo_test] @@ -1108,7 +1169,12 @@ fn cargo_compile_with_nested_deps_shorthand() { assert!(!p.bin("libbar.rlib").is_file()); assert!(!p.bin("libbaz.rlib").is_file()); - p.process(&p.bin("foo")).with_stdout("test passed\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +test passed + +"#]]) + .run(); } #[cargo_test] @@ -1182,7 +1248,12 @@ fn cargo_compile_with_nested_deps_longhand() { assert!(!p.bin("libbar.rlib").is_file()); assert!(!p.bin("libbaz.rlib").is_file()); - p.process(&p.bin("foo")).with_stdout("test passed\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +test passed + +"#]]) + .run(); } // Check that Cargo gives a sensible error if a dependency can't be found @@ -1216,13 +1287,12 @@ fn cargo_compile_with_dep_name_mismatch() { p.cargo("build") .with_status(101) - .with_stderr( - "\ -error: no matching package named `notquitebar` found -location searched: [CWD]/bar -required by package `foo v0.0.1 ([CWD])` -", - ) + .with_stderr_data(str![[r#" +[ERROR] no matching package named `notquitebar` found +location searched: [ROOT]/foo/bar +required by package `foo v0.0.1 ([ROOT]/foo)` + +"#]]) .run(); } @@ -1247,16 +1317,15 @@ fn cargo_compile_with_invalid_dep_rename() { p.cargo("build") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid character ` ` in package name: `haha this isn't a valid name 🐛`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters) --> Cargo.toml:8:17 | -8 | \"haha this isn't a valid name 🐛\" = { package = \"libc\", version = \"0.1\" } +8 | "haha this isn't a valid name 🐛" = { package = "libc", version = "0.1" } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -", - ) + +"#]]) .run(); } @@ -1276,46 +1345,44 @@ fn cargo_compile_with_filename() { p.cargo("build --bin bin.rs") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] no bin target named `bin.rs`. Available bin targets: a -", - ) + +"#]]) .run(); p.cargo("build --bin a.rs") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] no bin target named `a.rs` -Did you mean `a`?", - ) + Did you mean `a`? + +"#]]) .run(); p.cargo("build --example example.rs") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] no example target named `example.rs`. Available example targets: a -", - ) + +"#]]) .run(); p.cargo("build --example a.rs") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] no example target named `a.rs` -Did you mean `a`?", - ) + Did you mean `a`? + +"#]]) .run(); } @@ -1352,21 +1419,22 @@ fn incompatible_dependencies() { p.cargo("build") .with_status(101) - .with_stderr_contains( - "\ -error: failed to select a version for `bad`. + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for `bad`. ... required by package `qux v0.1.0` - ... which satisfies dependency `qux = \"^0.1.0\"` of package `foo v0.0.1 ([..])` + ... which satisfies dependency `qux = "^0.1.0"` of package `foo v0.0.1 ([ROOT]/foo)` versions that meet the requirements `>=1.0.1` are: 1.0.2, 1.0.1 all possible versions conflict with previously selected packages. previously selected package `bad v1.0.0` - ... which satisfies dependency `bad = \"=1.0.0\"` of package `baz v0.1.0` - ... which satisfies dependency `baz = \"^0.1.0\"` of package `foo v0.0.1 ([..])` + ... which satisfies dependency `bad = "=1.0.0"` of package `baz v0.1.0` + ... which satisfies dependency `baz = "^0.1.0"` of package `foo v0.0.1 ([ROOT]/foo)` -failed to select a version for `bad` which could resolve this conflict", - ) +failed to select a version for `bad` which could resolve this conflict + +"#]]) .run(); } @@ -1399,24 +1467,25 @@ fn incompatible_dependencies_with_multi_semver() { p.cargo("build") .with_status(101) - .with_stderr_contains( - "\ -error: failed to select a version for `bad`. - ... required by package `foo v0.0.1 ([..])` + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for `bad`. + ... required by package `foo v0.0.1 ([ROOT]/foo)` versions that meet the requirements `>=1.0.1, <=2.0.0` are: 2.0.0, 1.0.1 all possible versions conflict with previously selected packages. previously selected package `bad v2.0.1` - ... which satisfies dependency `bad = \">=2.0.1\"` of package `baz v0.1.0` - ... which satisfies dependency `baz = \"^0.1.0\"` of package `foo v0.0.1 ([..])` + ... which satisfies dependency `bad = ">=2.0.1"` of package `baz v0.1.0` + ... which satisfies dependency `baz = "^0.1.0"` of package `foo v0.0.1 ([ROOT]/foo)` previously selected package `bad v1.0.0` - ... which satisfies dependency `bad = \"=1.0.0\"` of package `bar v0.1.0` - ... which satisfies dependency `bar = \"^0.1.0\"` of package `foo v0.0.1 ([..])` + ... which satisfies dependency `bad = "=1.0.0"` of package `bar v0.1.0` + ... which satisfies dependency `bar = "^0.1.0"` of package `foo v0.0.1 ([ROOT]/foo)` -failed to select a version for `bad` which could resolve this conflict", - ) +failed to select a version for `bad` which could resolve this conflict + +"#]]) .run(); } @@ -1462,6 +1531,7 @@ fn ignores_carriage_return_in_lockfile() { p.cargo("build").run(); } +#[allow(deprecated)] #[cargo_test] fn cargo_default_env_metadata_env_var() { // Ensure that path dep + dylib + env_var get metadata @@ -1759,7 +1829,10 @@ fn crate_env_vars() { println!("bin"); p.process(&p.bin("foo-bar")) - .with_stdout("0-5-1 @ alpha.1 in [CWD]") + .with_stdout_data(str![[r#" +0-5-1 @ alpha.1 in [ROOT]/foo + +"#]]) .run(); println!("example"); @@ -1863,11 +1936,47 @@ fn cargo_rustc_current_dir_foreign_workspace_dep() { // Verify it works from a different workspace foo.cargo("test -p baz") .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) - .with_stdout_contains("running 1 test\ntest baz_env ... ok") + .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 baz_env ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 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(); foo.cargo("test -p baz_member") .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) - .with_stdout_contains("running 1 test\ntest baz_member_env ... ok") + .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 baz_member_env ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 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(); } @@ -1912,7 +2021,15 @@ fn cargo_rustc_current_dir_non_local_dep() { p.cargo("test -p bar") .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) - .with_stdout_contains("running 1 test\ntest bar_env ... ok") + .with_stdout_data(str![[r#" + +running 1 test +test bar_env ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -1981,7 +2098,10 @@ fn crate_authors_env_vars() { println!("bin"); p.process(&p.bin("foo")) - .with_stdout("wycats@example.com:neikos@example.com") + .with_stdout_data(str![[r#" +wycats@example.com:neikos@example.com + +"#]]) .run(); println!("test"); @@ -2006,18 +2126,25 @@ fn vv_prints_rustc_env_vars() { let mut b = p.cargo("build -vv"); - if cfg!(windows) { + #[cfg(windows)] + { + b.with_stderr_data(str![]); b.with_stderr_contains( "[RUNNING] `[..]set CARGO_PKG_NAME=foo&& [..]rustc [..]`" ).with_stderr_contains( r#"[RUNNING] `[..]set CARGO_PKG_AUTHORS="escape='\"@example.com"&& [..]rustc [..]`"# - ) - } else { - b.with_stderr_contains("[RUNNING] `[..]CARGO_PKG_NAME=foo [..]rustc [..]`") - .with_stderr_contains( - r#"[RUNNING] `[..]CARGO_PKG_AUTHORS='escape='\''"@example.com' [..]rustc [..]`"#, - ) - }; + ); + } + + #[cfg(not(windows))] + { + b.with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `[..] CARGO_PKG_AUTHORS='escape='/''"@example.com' [..] CARGO_PKG_NAME=foo [..] rustc --crate-name foo [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]); + } b.run(); } @@ -2091,11 +2218,13 @@ fn many_crate_types_old_style_lib_location() { .file("src/foo.rs", "pub fn foo() {}") .build(); p.cargo("build") - .with_stderr_contains( - "\ -[WARNING] path `[..]src/foo.rs` was erroneously implicitly accepted for library `foo`, -please rename the file to `src/lib.rs` or set lib.path in Cargo.toml", - ) + .with_stderr_data(str![[r#" +[WARNING] path `src/foo.rs` was erroneously implicitly accepted for library `foo`, +please rename the file to `src/lib.rs` or set lib.path in Cargo.toml +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.root().join("target/debug/libfoo.rlib").is_file()); @@ -2154,14 +2283,13 @@ fn set_both_dylib_and_cdylib_crate_types() { .build(); p.cargo("build") .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: library `foo` cannot set the crate type of both `dylib` and `cdylib` -", - ) + +"#]]) .run(); } @@ -2191,12 +2319,12 @@ fn self_dependency() { .build(); p.cargo("build") .with_status(101) - .with_stderr( - "\ -[ERROR] cyclic package dependency: package `test v0.0.0 ([CWD])` depends on itself. Cycle: -package `test v0.0.0 ([CWD])` - ... which satisfies path dependency `test` of package `test v0.0.0 ([..])`", - ) + .with_stderr_data(str![[r#" +[ERROR] cyclic package dependency: package `test v0.0.0 ([ROOT]/foo)` depends on itself. Cycle: +package `test v0.0.0 ([ROOT]/foo)` + ... which satisfies path dependency `test` of package `test v0.0.0 ([ROOT]/foo)` + +"#]]) .run(); } @@ -2221,13 +2349,23 @@ fn ignore_broken_symlinks() { .build(); p.cargo("build") - .with_stderr_contains( - "[WARNING] File system loop found: [..]/a/b/c/d/foo points to an ancestor [..]/a/b", - ) + .with_stderr_data(str![[r#" +[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`, +please set bin.path in Cargo.toml +[WARNING] File system loop found: [ROOT]/foo/a/b/c/d/foo points to an ancestor [ROOT]/foo/a/b +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("i am foo\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +i am foo + +"#]]) + .run(); } #[cargo_test] @@ -2235,14 +2373,14 @@ fn missing_lib_and_bin() { let p = project().build(); p.cargo("build") .with_status(101) - .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: no targets specified in the manifest - either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n", - ) + either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present + +"#]]) .run(); } @@ -2266,138 +2404,12 @@ fn lto_build() { .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -v --release") - .with_stderr( - "\ -[COMPILING] test v0.0.0 ([CWD]) -[RUNNING] `rustc --crate-name test --edition=2015 src/main.rs [..]--crate-type bin \ - --emit=[..]link \ - -C opt-level=3 \ - -C lto \ - [..] -[FINISHED] `release` profile [optimized] target(s) in [..] -", - ) - .run(); -} - -#[cargo_test] -fn verbose_build() { - let p = project().file("src/lib.rs", "").build(); - p.cargo("build -v") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 [..]\ - -C metadata=[..] \ - --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) - .run(); -} - -#[cargo_test] -fn verbose_release_build() { - let p = project().file("src/lib.rs", "").build(); - p.cargo("build -v --release") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]\ - -C opt-level=3[..]\ - -C metadata=[..] \ - --out-dir [..] \ - -L dependency=[CWD]/target/release/deps` -[FINISHED] `release` profile [optimized] target(s) in [..] -", - ) - .run(); -} + .with_stderr_data(str![[r#" +[COMPILING] test v0.0.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name test --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C lto [..]` +[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s -#[cargo_test] -fn verbose_release_build_short() { - let p = project().file("src/lib.rs", "").build(); - p.cargo("build -v -r") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]\ - -C opt-level=3[..]\ - -C metadata=[..] \ - --out-dir [..] \ - -L dependency=[CWD]/target/release/deps` -[FINISHED] `release` profile [optimized] target(s) in [..] -", - ) - .run(); -} - -#[cargo_test] -fn verbose_release_build_deps() { - let p = project() - .file( - "Cargo.toml", - r#" - [package] - - name = "test" - version = "0.0.0" - edition = "2015" - authors = [] - - [dependencies.foo] - path = "foo" - "#, - ) - .file("src/lib.rs", "") - .file( - "foo/Cargo.toml", - r#" - [package] - - name = "foo" - version = "0.0.0" - edition = "2015" - authors = [] - - [lib] - name = "foo" - crate-type = ["dylib", "rlib"] - "#, - ) - .file("foo/src/lib.rs", "") - .build(); - p.cargo("build -v --release") - .with_stderr(&format!( - "\ -[LOCKING] 2 packages to latest compatible versions -[COMPILING] foo v0.0.0 ([CWD]/foo) -[RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]\ - --crate-type dylib --crate-type rlib \ - --emit=[..]link \ - -C prefer-dynamic[..]\ - -C opt-level=3[..]\ - -C metadata=[..] \ - --out-dir [..] \ - -L dependency=[CWD]/target/release/deps` -[COMPILING] test v0.0.0 ([CWD]) -[RUNNING] `rustc --crate-name test --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]\ - -C opt-level=3[..]\ - -C metadata=[..] \ - --out-dir [..] \ - -L dependency=[CWD]/target/release/deps \ - --extern foo=[CWD]/target/release/deps/{prefix}foo{suffix} \ - --extern foo=[CWD]/target/release/deps/libfoo.rlib` -[FINISHED] `release` profile [optimized] target(s) in [..] -", - prefix = env::consts::DLL_PREFIX, - suffix = env::consts::DLL_SUFFIX - )) +"#]]) .run(); } @@ -2452,10 +2464,16 @@ fn explicit_examples() { p.cargo("build --examples").run(); p.process(&p.bin("examples/hello")) - .with_stdout("Hello, World!\n") + .with_stdout_data(str![[r#" +Hello, World! + +"#]]) .run(); p.process(&p.bin("examples/goodbye")) - .with_stdout("Goodbye, World!\n") + .with_stdout_data(str![[r#" +Goodbye, World! + +"#]]) .run(); } @@ -2483,14 +2501,13 @@ fn non_existing_test() { p.cargo("build --tests -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: - can't find `hello` test at `tests/hello.rs` or `tests/hello/main.rs`. \ - Please specify test.path if you want to use a non-default path.", - ) + can't find `hello` test at `tests/hello.rs` or `tests/hello/main.rs`. Please specify test.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2518,14 +2535,13 @@ fn non_existing_example() { p.cargo("build --examples -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: - can't find `hello` example at `examples/hello.rs` or `examples/hello/main.rs`. \ - Please specify example.path if you want to use a non-default path.", - ) + can't find `hello` example at `examples/hello.rs` or `examples/hello/main.rs`. Please specify example.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2553,14 +2569,13 @@ fn non_existing_benchmark() { p.cargo("build --benches -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: - can't find `hello` bench at `benches/hello.rs` or `benches/hello/main.rs`. \ - Please specify bench.path if you want to use a non-default path.", - ) + can't find `hello` bench at `benches/hello.rs` or `benches/hello/main.rs`. Please specify bench.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2574,14 +2589,13 @@ fn non_existing_binary() { p.cargo("build -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: - can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. \ - Please specify bin.path if you want to use a non-default path.", - ) + can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. Please specify bin.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2610,15 +2624,14 @@ fn commonly_wrong_path_of_test() { p.cargo("build --tests -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: can't find `foo` test at default paths, but found a file at `test/foo.rs`. - Perhaps rename the file to `tests/foo.rs` for target auto-discovery, \ - or specify test.path if you want to use a non-default path.", - ) + Perhaps rename the file to `tests/foo.rs` for target auto-discovery, or specify test.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2647,15 +2660,14 @@ fn commonly_wrong_path_of_example() { p.cargo("build --examples -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: can't find `foo` example at default paths, but found a file at `example/foo.rs`. - Perhaps rename the file to `examples/foo.rs` for target auto-discovery, \ - or specify example.path if you want to use a non-default path.", - ) + Perhaps rename the file to `examples/foo.rs` for target auto-discovery, or specify example.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2684,15 +2696,14 @@ fn commonly_wrong_path_of_benchmark() { p.cargo("build --benches -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: can't find `foo` bench at default paths, but found a file at `bench/foo.rs`. - Perhaps rename the file to `benches/foo.rs` for target auto-discovery, \ - or specify bench.path if you want to use a non-default path.", - ) + Perhaps rename the file to `benches/foo.rs` for target auto-discovery, or specify bench.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2706,15 +2717,14 @@ fn commonly_wrong_path_binary() { p.cargo("build -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: can't find `foo` bin at default paths, but found a file at `src/bins/foo.rs`. - Perhaps rename the file to `src/bin/foo.rs` for target auto-discovery, \ - or specify bin.path if you want to use a non-default path.", - ) + Perhaps rename the file to `src/bin/foo.rs` for target auto-discovery, or specify bin.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2728,15 +2738,14 @@ fn commonly_wrong_path_subdir_binary() { p.cargo("build -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: can't find `foo` bin at default paths, but found a file at `src/bins/foo/main.rs`. - Perhaps rename the file to `src/bin/foo/main.rs` for target auto-discovery, \ - or specify bin.path if you want to use a non-default path.", - ) + Perhaps rename the file to `src/bin/foo/main.rs` for target auto-discovery, or specify bin.path if you want to use a non-default path. + +"#]]) .run(); } @@ -2752,15 +2761,14 @@ fn found_multiple_target_files() { p.cargo("build -v") .with_status(101) // Don't assert the inferred paths since the order is non-deterministic. - .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: cannot infer path for `foo` bin - Cargo doesn't know which to use because multiple target files found \ - at `src/bin/foo[..].rs` and `src/bin/foo[..].rs`.", - ) + Cargo doesn't know which to use because multiple target files found at `src/bin/foo[..]rs` and `src/bin/foo[..].rs`. + +"#]]) .run(); } @@ -2785,11 +2793,30 @@ fn legacy_binary_paths_warnings() { .build(); p.cargo("build -v") - .with_stderr_contains( - "\ -[WARNING] path `[..]src/main.rs` was erroneously implicitly accepted for binary `bar`, -please set bin.path in Cargo.toml", - ) + .with_stderr_data(str![[r#" +[WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently +disables Cargo from automatically inferring other binary targets. +This inference behavior will change in the Rust 2018 edition and the following +files will be included as a binary target: + +* src/main.rs + +This is likely to break cargo build or cargo test as these files may not be +ready to be compiled as a binary target today. You can future-proof yourself +and disable this warning by adding `autobins = false` to your [package] +section. You may also move the files to a location where Cargo would not +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 +[WARNING] path `src/main.rs` was erroneously implicitly accepted for binary `bar`, +please set bin.path in Cargo.toml +[COMPILING] foo v1.0.0 ([ROOT]/foo) +[RUNNING] `rustc [..]` +[RUNNING] `rustc [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let p = project() @@ -2811,11 +2838,30 @@ please set bin.path in Cargo.toml", .build(); p.cargo("build -v") - .with_stderr_contains( - "\ -[WARNING] path `[..]src/bin/main.rs` was erroneously implicitly accepted for binary `bar`, -please set bin.path in Cargo.toml", - ) + .with_stderr_data(str![[r#" +[WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently +disables Cargo from automatically inferring other binary targets. +This inference behavior will change in the Rust 2018 edition and the following +files will be included as a binary target: + +* src/bin/main.rs + +This is likely to break cargo build or cargo test as these files may not be +ready to be compiled as a binary target today. You can future-proof yourself +and disable this warning by adding `autobins = false` to your [package] +section. You may also move the files to a location where Cargo would not +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 +[WARNING] path `src/bin/main.rs` was erroneously implicitly accepted for binary `bar`, +please set bin.path in Cargo.toml +[COMPILING] foo v1.0.0 ([ROOT]/foo) +[RUNNING] `rustc [..]` +[RUNNING] `rustc [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let p = project() @@ -2836,11 +2882,14 @@ please set bin.path in Cargo.toml", .build(); p.cargo("build -v") - .with_stderr_contains( - "\ -[WARNING] path `[..]src/bar.rs` was erroneously implicitly accepted for binary `bar`, -please set bin.path in Cargo.toml", - ) + .with_stderr_data(str![[r#" +[WARNING] path `src/bar.rs` was erroneously implicitly accepted for binary `bar`, +please set bin.path in Cargo.toml +[COMPILING] foo v1.0.0 ([ROOT]/foo) +[RUNNING] `rustc [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2877,10 +2926,16 @@ fn implicit_examples() { p.cargo("build --examples").run(); p.process(&p.bin("examples/hello")) - .with_stdout("Hello, World!\n") + .with_stdout_data(str![[r#" +Hello, World! + +"#]]) .run(); p.process(&p.bin("examples/goodbye")) - .with_stdout("Goodbye, World!\n") + .with_stdout_data(str![[r#" +Goodbye, World! + +"#]]) .run(); } @@ -2903,7 +2958,12 @@ fn standard_build_no_ndebug() { .build(); p.cargo("build").run(); - p.process(&p.bin("foo")).with_stdout("slow\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +slow + +"#]]) + .run(); } #[cargo_test] @@ -2925,7 +2985,12 @@ fn release_build_ndebug() { .build(); p.cargo("build --release").run(); - p.process(&p.release_bin("foo")).with_stdout("fast\n").run(); + p.process(&p.release_bin("foo")) + .with_stdout_data(str![[r#" +fast + +"#]]) + .run(); } #[cargo_test] @@ -2961,7 +3026,13 @@ fn deletion_causes_failure() { p.change_file("Cargo.toml", &basic_manifest("foo", "0.0.1")); p.cargo("build") .with_status(101) - .with_stderr_contains("[..]can't find crate for `bar`") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +error[E0463]: can't find crate for `bar` +... +[ERROR] could not compile `foo` (bin "foo") due to 1 previous error + +"#]]) .run(); } @@ -2988,12 +3059,11 @@ fn lib_with_standard_name() { .build(); p.cargo("build") - .with_stderr( - "\ -[COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] syntax v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3109,22 +3179,31 @@ fn freshness_ignores_excluded() { foo.root().move_into_the_past(); foo.cargo("build") - .with_stderr( - "\ -[COMPILING] foo v0.0.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Smoke test to make sure it doesn't compile again println!("first pass"); - foo.cargo("build").with_stderr("[FINISHED] [..]").run(); + foo.cargo("build") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); // Modify an ignored file and make sure we don't rebuild println!("second pass"); foo.change_file("src/bar.rs", ""); - foo.cargo("build").with_stderr("[FINISHED] [..]").run(); + foo.cargo("build") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); } #[cargo_test] @@ -3164,22 +3243,20 @@ fn rebuild_preserves_out_dir() { foo.cargo("build") .env("FIRST", "1") - .with_stderr( - "\ -[COMPILING] foo v0.0.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); foo.change_file("src/bar.rs", ""); foo.cargo("build") - .with_stderr( - "\ -[COMPILING] foo v0.0.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3227,7 +3304,12 @@ fn recompile_space_in_name() { .build(); foo.cargo("build").run(); foo.root().move_into_the_past(); - foo.cargo("build").with_stderr("[FINISHED] [..]").run(); + foo.cargo("build") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); } #[cfg(unix)] @@ -3285,12 +3367,11 @@ fn bad_cargo_config() { .build(); foo.cargo("build -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 6 @@ -3298,8 +3379,8 @@ Caused by: 1 | this is not valid toml | ^ expected `.`, `=` -", - ) + +"#]]) .run(); } @@ -3378,7 +3459,14 @@ fn bad_platform_specific_dependency() { p.cargo("build") .with_status(101) - .with_stderr_contains("[..]can't find crate for `bar`") + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[COMPILING] foo v0.5.0 ([ROOT]/foo) +error[E0463]: can't find crate for `bar` +... +[ERROR] could not compile `foo` (bin "foo") due to 1 previous error + +"#]]) .run(); } @@ -3601,7 +3689,22 @@ fn transitive_dependencies_not_available() { p.cargo("build -v") .with_status(101) - .with_stderr_contains("[..] can't find crate for `bbbbb`[..]") + .with_stderr_data(str![[r#" +[LOCKING] 3 packages to latest compatible versions +[COMPILING] bbbbb v0.0.1 ([ROOT]/foo/b) +[RUNNING] `rustc [..] +[COMPILING] aaaaa v0.0.1 ([ROOT]/foo/a) +[RUNNING] `rustc [..]` +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc [..]` +error[E0463]: can't find crate for `bbbbb` +... +[ERROR] could not compile `foo` (bin "foo") due to 1 previous error + +Caused by: + process didn't exit successfully: `rustc [..]` ([EXIT_STATUS]: 1) + +"#]]) .run(); } @@ -3640,12 +3743,14 @@ fn cyclic_deps_rejected() { p.cargo("build -v") .with_status(101) - .with_stderr( -"[ERROR] cyclic package dependency: package `a v0.0.1 ([CWD]/a)` depends on itself. Cycle: -package `a v0.0.1 ([CWD]/a)` - ... which satisfies path dependency `a` of package `foo v0.0.1 ([CWD])` - ... which satisfies path dependency `foo` of package `a v0.0.1 ([..])`", - ).run(); + .with_stderr_data(str![[r#" +[ERROR] cyclic package dependency: package `a v0.0.1 ([ROOT]/foo/a)` depends on itself. Cycle: +package `a v0.0.1 ([ROOT]/foo/a)` + ... which satisfies path dependency `a` of package `foo v0.0.1 ([ROOT]/foo)` + ... which satisfies path dependency `foo` of package `a v0.0.1 ([ROOT]/foo/a)` + +"#]]) + .run(); } #[cargo_test] @@ -3708,14 +3813,13 @@ fn dashes_in_crate_name_bad() { p.cargo("build -v") .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: library target names cannot contain hyphens: foo-bar -", - ) + +"#]]) .run(); } @@ -3726,14 +3830,13 @@ fn rustc_env_var() { p.cargo("build -v") .env("RUSTC", "rustc-that-does-not-exist") .with_status(101) - .with_stderr( - "\ -[ERROR] could not execute process `rustc-that-does-not-exist -vV` ([..]) + .with_stderr_data(str![[r#" +[ERROR] could not execute process `rustc-that-does-not-exist -vV` (never executed) Caused by: -[..] -", - ) + No such file or directory (os error 2) + +"#]]) .run(); assert!(!p.bin("a").is_file()); } @@ -3937,7 +4040,12 @@ fn build_multiple_packages() { p.cargo("build -p d1 -p d2 -p foo").run(); assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("i am foo\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +i am foo + +"#]]) + .run(); let d1_path = &p .build_dir() @@ -3949,10 +4057,20 @@ fn build_multiple_packages() { .join(format!("d2{}", env::consts::EXE_SUFFIX)); assert!(d1_path.is_file()); - p.process(d1_path).with_stdout("d1").run(); + p.process(d1_path) + .with_stdout_data(str![[r#" +d1 + +"#]]) + .run(); assert!(d2_path.is_file()); - p.process(d2_path).with_stdout("d2").run(); + p.process(d2_path) + .with_stdout_data(str![[r#" +d2 + +"#]]) + .run(); } #[cargo_test] @@ -3982,16 +4100,19 @@ fn invalid_spec() { p.cargo("build -p notAValidDep") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[ERROR] package ID specification `notAValidDep` did not match any packages", - ) +[ERROR] package ID specification `notAValidDep` did not match any packages + +"#]]) .run(); p.cargo("build -p d1 -p notAValidDep") .with_status(101) - .with_stderr("[ERROR] package ID specification `notAValidDep` did not match any packages") + .with_stderr_data(str![[r#" +[ERROR] package ID specification `notAValidDep` did not match any packages + +"#]]) .run(); } @@ -4032,10 +4153,16 @@ fn panic_abort_compiles_with_panic_abort() { .file("src/lib.rs", "") .build(); p.cargo("build -v") - .with_stderr_contains("[..] -C panic=abort [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc [..] -C panic=abort [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } +#[allow(deprecated)] #[cargo_test] fn compiler_json_error_format() { let p = project() @@ -4218,14 +4345,14 @@ fn wrong_message_format_option() { p.cargo("build --message-format XML") .with_status(101) - .with_stderr_contains( - "\ -error: invalid message format specifier: `xml` -", - ) + .with_stderr_data(str![[r#" +[ERROR] invalid message format specifier: `xml` + +"#]]) .run(); } +#[allow(deprecated)] #[cargo_test] fn message_format_json_forward_stderr() { let p = project() @@ -4310,10 +4437,11 @@ fn no_warn_about_package_metadata() { .file("src/lib.rs", "") .build(); p.cargo("build") - .with_stderr( - "[..] foo v0.0.1 ([..])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -4348,10 +4476,11 @@ fn no_warn_about_workspace_metadata() { .build(); p.cargo("build") - .with_stderr( - "[..] foo v0.0.1 ([..])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -4365,7 +4494,10 @@ fn cargo_build_empty_target() { p.cargo("build --target") .arg("") .with_status(101) - .with_stderr_contains("[..] target was empty") + .with_stderr_data(str![[r#" +[ERROR] target was empty + +"#]]) .run(); } @@ -4378,17 +4510,16 @@ fn cargo_build_with_unsupported_short_target_flag() { p.cargo("build -t") .arg("") - .with_stderr( - "\ -error: unexpected argument '-t' found + .with_stderr_data(str![[r#" +[ERROR] unexpected argument '-t' found tip: a similar argument exists: '--target' Usage: cargo[EXE] build [OPTIONS] For more information, try '--help'. -", - ) + +"#]]) .with_status(1) .run(); } @@ -4416,14 +4547,13 @@ fn build_all_workspace() { .build(); p.cargo("build --workspace") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.1.0 ([..]) -[COMPILING] foo v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[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(); } @@ -4450,14 +4580,15 @@ fn build_all_exclude() { .build(); p.cargo("build --workspace --exclude baz") - .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 3 packages to latest compatible versions -[COMPILING] foo v0.1.0 ([..]) -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -4485,17 +4616,16 @@ fn cargo_build_with_unsupported_short_exclude_flag() { .build(); p.cargo("build --workspace -x baz") - .with_stderr( - "\ -error: unexpected argument '-x' found + .with_stderr_data(str![[r#" +[ERROR] unexpected argument '-x' found tip: a similar argument exists: '--exclude' Usage: cargo[EXE] build [OPTIONS] For more information, try '--help'. -", - ) + +"#]]) .with_status(1) .run(); } @@ -4521,15 +4651,16 @@ fn build_all_exclude_not_found() { .build(); p.cargo("build --workspace --exclude baz") - .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" +[WARNING] excluded package(s) `baz` not found in workspace `[ROOT]/foo` [LOCKING] 2 packages to latest compatible versions -[WARNING] excluded package(s) `baz` not found in workspace [..] -[COMPILING] foo v0.1.0 ([..]) -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -4557,14 +4688,15 @@ fn build_all_exclude_glob() { .build(); p.cargo("build --workspace --exclude '*z'") - .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 3 packages to latest compatible versions -[COMPILING] foo v0.1.0 ([..]) -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", +[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 + +"#]] + .unordered(), ) .run(); } @@ -4590,15 +4722,16 @@ fn build_all_exclude_glob_not_found() { .build(); p.cargo("build --workspace --exclude '*z'") - .with_stderr_does_not_contain("[COMPILING] baz v0.1.0 [..]") - .with_stderr( - "\ -[WARNING] excluded package pattern(s) `*z` not found in workspace [..] + .with_stderr_data( + str![[r#" +[WARNING] excluded package pattern(s) `*z` not found in workspace `[ROOT]/foo` [LOCKING] 2 packages to latest compatible versions -[COMPILING] [..] v0.1.0 ([..]) -[COMPILING] [..] v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", +[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 + +"#]] + .unordered(), ) .run(); } @@ -4609,7 +4742,13 @@ fn build_all_exclude_broken_glob() { p.cargo("build --workspace --exclude '[*z'") .with_status(101) - .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") + .with_stderr_data(str![[r#" +[ERROR] cannot build glob pattern from `[*z` + +Caused by: +... + +"#]]) .run(); } @@ -4644,12 +4783,13 @@ fn build_all_workspace_implicit_examples() { .build(); p.cargo("build --workspace --examples") - .with_stderr( - "[LOCKING] 2 packages to latest compatible versions\n\ - [..] Compiling bar v0.1.0 ([..])\n\ - [..] Compiling foo v0.1.0 ([..])\n\ - [..] Finished `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) + .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] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(!p.bin("a").is_file()); assert!(!p.bin("b").is_file()); @@ -4679,13 +4819,15 @@ fn build_all_virtual_manifest() { // The order in which bar and baz are built is not guaranteed p.cargo("build --workspace") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] baz v0.1.0 ([..]) -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] baz v0.1.0 ([ROOT]/foo/baz) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -4708,13 +4850,15 @@ fn build_virtual_manifest_all_implied() { // The order in which `bar` and `baz` are built is not guaranteed. p.cargo("build") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] baz v0.1.0 ([..]) -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] baz v0.1.0 ([ROOT]/foo/baz) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); } @@ -4736,14 +4880,12 @@ fn build_virtual_manifest_one_project() { .build(); p.cargo("build -p bar") - .with_stderr_does_not_contain("[..]baz[..]") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -4764,14 +4906,12 @@ fn build_virtual_manifest_glob() { .build(); p.cargo("build -p '*z'") - .with_stderr_does_not_contain("[..]bar[..]") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] baz v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] baz v0.1.0 ([ROOT]/foo/baz) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -4791,7 +4931,10 @@ fn build_virtual_manifest_glob_not_found() { p.cargo("build -p bar -p '*z'") .with_status(101) - .with_stderr("[ERROR] package pattern(s) `*z` not found in workspace [..]") + .with_stderr_data(str![[r#" +[ERROR] package pattern(s) `*z` not found in workspace `[ROOT]/foo` + +"#]]) .run(); } @@ -4811,7 +4954,13 @@ fn build_virtual_manifest_broken_glob() { p.cargo("build -p '[*z'") .with_status(101) - .with_stderr_contains("[ERROR] cannot build glob pattern from `[*z`") + .with_stderr_data(str![[r#" +[ERROR] cannot build glob pattern from `[*z` + +Caused by: +... + +"#]]) .run(); } @@ -4841,13 +4990,15 @@ fn build_all_virtual_manifest_implicit_examples() { // The order in which bar and baz are built is not guaranteed p.cargo("build --workspace --examples") - .with_stderr_unordered( - "\ + .with_stderr_data( + str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] baz v0.1.0 ([..]) -[COMPILING] bar v0.1.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", +[COMPILING] baz v0.1.0 ([ROOT]/foo/baz) +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); assert!(!p.bin("a").is_file()); @@ -4888,15 +5039,16 @@ fn build_all_member_dependency_same_name() { Package::new("a", "0.1.0").publish(); p.cargo("build --workspace") - .with_stderr( - "[UPDATING] `[..]` index\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [DOWNLOADING] crates ...\n\ - [DOWNLOADED] a v0.1.0 ([..])\n\ - [COMPILING] a v0.1.0\n\ - [COMPILING] a v0.1.0 ([..])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index +[LOCKING] 2 packages to latest compatible versions +[DOWNLOADING] crates ... +[DOWNLOADED] a v0.1.0 (registry `dummy-registry`) +[COMPILING] a v0.1.0 +[COMPILING] a v0.1.0 ([ROOT]/foo/a) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -4961,8 +5113,18 @@ fn run_proper_alias_binary_from_src() { .build(); p.cargo("build --workspace").run(); - p.process(&p.bin("foo")).with_stdout("foo\n").run(); - p.process(&p.bin("bar")).with_stdout("bar\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +foo + +"#]]) + .run(); + p.process(&p.bin("bar")) + .with_stdout_data(str![[r#" +bar + +"#]]) + .run(); } #[cargo_test] @@ -4986,8 +5148,18 @@ fn run_proper_alias_binary_main_rs() { .build(); p.cargo("build --workspace").run(); - p.process(&p.bin("foo")).with_stdout("main\n").run(); - p.process(&p.bin("bar")).with_stdout("main\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +main + +"#]]) + .run(); + p.process(&p.bin("bar")) + .with_stdout_data(str![[r#" +main + +"#]]) + .run(); } #[cargo_test] @@ -5008,18 +5180,26 @@ fn run_proper_binary_main_rs_as_foo() { fn rustc_wrapper() { let p = project().file("src/lib.rs", "").build(); let wrapper = tools::echo_wrapper(); - let running = format!( - "[RUNNING] `{} rustc --crate-name foo [..]", - wrapper.display() - ); p.cargo("build -v") .env("RUSTC_WRAPPER", &wrapper) - .with_stderr_contains(&running) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `[..]/rustc-echo-wrapper rustc --crate-name foo [..]` +WRAPPER CALLED: rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.build_dir().rm_rf(); p.cargo("build -v") .env("RUSTC_WORKSPACE_WRAPPER", &wrapper) - .with_stderr_contains(&running) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `[..]/rustc-echo-wrapper rustc --crate-name foo [..]` +WRAPPER CALLED: rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -5032,18 +5212,21 @@ fn rustc_wrapper_precendence() { assert_ne!(rustc_wrapper, ws_wrapper); std::fs::hard_link(&rustc_wrapper, &ws_wrapper).unwrap(); - let running = format!( - "[RUNNING] `{} {} rustc --crate-name foo [..]", - rustc_wrapper.display(), - ws_wrapper.display(), - ); p.cargo("build -v") .env("RUSTC_WRAPPER", &rustc_wrapper) .env("RUSTC_WORKSPACE_WRAPPER", &ws_wrapper) - .with_stderr_contains(running) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `[..]/rustc-echo-wrapper [..]/rustc-ws-wrapper rustc --crate-name foo [..]` +WRAPPER CALLED: [..]/rustc-ws-wrapper rustc --crate-name foo [..] +WRAPPER CALLED: rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } +#[allow(deprecated)] #[cargo_test] fn rustc_wrapper_queries() { // Check that the invocations querying rustc for information are done with the wrapper. @@ -5090,15 +5273,35 @@ fn rustc_wrapper_relative() { let exe_name = wrapper.file_name().unwrap().to_str().unwrap(); let relative_path = format!("./{}", exe_name); fs::hard_link(&wrapper, p.root().join(exe_name)).unwrap(); - let running = format!("[RUNNING] `[ROOT]/foo/./{} rustc[..]", exe_name); p.cargo("build -v") .env("RUSTC_WRAPPER", &relative_path) - .with_stderr_contains(&running) + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index +[LOCKING] 2 packages to latest compatible versions +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`) +[COMPILING] bar v1.0.0 +[RUNNING] `[ROOT]/foo/./rustc-echo-wrapper rustc --crate-name bar [..]` +WRAPPER CALLED: rustc --crate-name bar [..] +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `[ROOT]/foo/./rustc-echo-wrapper rustc --crate-name foo [..]` +WRAPPER CALLED: rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.build_dir().rm_rf(); p.cargo("build -v") .env("RUSTC_WORKSPACE_WRAPPER", &relative_path) - .with_stderr_contains(&running) + .with_stderr_data(str![[r#" +[COMPILING] bar v1.0.0 +[RUNNING] `rustc --crate-name bar [..]` +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `[ROOT]/foo/./rustc-echo-wrapper rustc --crate-name foo [..]` +WRAPPER CALLED: rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.build_dir().rm_rf(); p.change_file( @@ -5110,7 +5313,18 @@ fn rustc_wrapper_relative() { exe_name ), ); - p.cargo("build -v").with_stderr_contains(&running).run(); + p.cargo("build -v") + .with_stderr_data(str![[r#" +[COMPILING] bar v1.0.0 +[RUNNING] `[ROOT]/foo/./rustc-echo-wrapper rustc --crate-name bar [..]` +WRAPPER CALLED: rustc --crate-name bar [..] +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `[ROOT]/foo/./rustc-echo-wrapper rustc --crate-name foo [..]` +WRAPPER CALLED: rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); } #[cargo_test] @@ -5119,13 +5333,25 @@ fn rustc_wrapper_from_path() { p.cargo("build -v") .env("RUSTC_WRAPPER", "wannabe_sccache") .with_status(101) - .with_stderr_contains("[..]`wannabe_sccache rustc [..]") + .with_stderr_data(str![[r#" +[ERROR] could not execute process `wannabe_sccache rustc -vV` (never executed) + +Caused by: + No such file or directory (os error 2) + +"#]]) .run(); p.build_dir().rm_rf(); p.cargo("build -v") .env("RUSTC_WORKSPACE_WRAPPER", "wannabe_sccache") .with_status(101) - .with_stderr_contains("[..]`wannabe_sccache rustc [..]") + .with_stderr_data(str![[r#" +[ERROR] could not execute process `wannabe_sccache rustc -vV` (never executed) + +Caused by: + No such file or directory (os error 2) + +"#]]) .run(); } @@ -5230,13 +5456,15 @@ fn no_dep_info_collision_when_cdylib_and_bin_coexist() { .build(); p.cargo("build -v") - .with_stderr_unordered( - "\ -[COMPILING] foo v1.0.0 ([CWD]) + .with_stderr_data( + str![[r#" +[COMPILING] foo v1.0.0 ([ROOT]/foo) [RUNNING] `rustc [..] --crate-type bin [..] -C metadata=[..]` [RUNNING] `rustc [..] --crate-type cdylib [..] -C metadata=[..]` -[FINISHED] [..] -", +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), ) .run(); @@ -5295,17 +5523,14 @@ fn deterministic_cfg_flags() { .build(); p.cargo("build -v") - .with_stderr( - "\ -[COMPILING] foo v0.1.0 [..] -[RUNNING] [..] -[RUNNING] [..] -[RUNNING] `rustc --crate-name foo [..] \ ---cfg[..]default[..]--cfg[..]f_a[..]--cfg[..]f_b[..]\ ---cfg[..]f_c[..]--cfg[..]f_d[..] \ ---cfg cfg_a --cfg cfg_b --cfg cfg_c --cfg cfg_d --cfg cfg_e` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `rustc [..]` +[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` +[RUNNING] `rustc --crate-name foo [..] --cfg[..]default[..]--cfg[..]f_a[..]--cfg[..]f_b[..] --cfg[..]f_c[..]--cfg[..]f_d[..] --cfg cfg_a --cfg cfg_b --cfg cfg_c --cfg cfg_d --cfg cfg_e` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -5346,13 +5571,13 @@ fn no_bin_in_src_with_lib() { p.cargo("build") .with_status(101) - .with_stderr_contains( - "\ -[ERROR] failed to parse manifest at `[..]` + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: - can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. [..]", - ) + can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. Please specify bin.path if you want to use a non-default path. + +"#]]) .run(); } @@ -5379,9 +5604,15 @@ fn inferred_bins_duplicate_name() { .file("src/bin/bar/main.rs", "fn main() {}") .build(); - p.cargo("build").with_status(101).with_stderr_contains( - "[..]found duplicate binary name bar, but all binary targets must have a unique name[..]", - ) + p.cargo("build") + .with_status(101) + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` + +Caused by: + found duplicate binary name bar, but all binary targets must have a unique name + +"#]]) .run(); } @@ -5475,12 +5706,12 @@ fn target_edition() { .build(); p.cargo("build -v") - .with_stderr_contains( - "\ -[COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc [..]--edition=2018 [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc [..]--edition=2018 [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -5513,6 +5744,7 @@ fn target_edition_override() { p.cargo("build -v").run(); } +#[allow(deprecated)] #[cargo_test] fn same_metadata_different_directory() { // A top-level crate built in two different workspaces should have the @@ -5577,9 +5809,20 @@ fn building_a_dependent_crate_without_bin_should_fail() { p.cargo("build") .with_status(101) - .with_stderr_contains( - "[..]can't find `a_bin` bin at `src/bin/a_bin.rs` or `src/bin/a_bin/main.rs`[..]", - ) + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index +[LOCKING] 2 packages to latest compatible versions +[DOWNLOADING] crates ... +[DOWNLOADED] testless v0.1.0 (registry `dummy-registry`) +[ERROR] failed to download replaced source registry `crates-io` + +Caused by: + failed to parse manifest at `[ROOT]/home/.cargo/registry/src/-[HASH]/testless-0.1.0/Cargo.toml` + +Caused by: + can't find `a_bin` bin at `src/bin/a_bin.rs` or `src/bin/a_bin/main.rs`. Please specify bin.path if you want to use a non-default path. + +"#]]) .run(); } @@ -5689,51 +5932,42 @@ fn build_filter_infer_profile() { .build(); p.cargo("build -v") - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin \ - --emit=[..]link[..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]` +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]].unordered()) .run(); p.root().join("target").rm_rf(); p.cargo("build -v --test=t1") - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 [..]", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name t1 --edition=2015 tests/t1.rs [..]--emit=[..]link[..]\ - -C debuginfo=2 [..]", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin \ - --emit=[..]link[..]-C debuginfo=2 [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..] -C debuginfo=2 [..]` +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..] -C debuginfo=2 [..]` +[RUNNING] `rustc --crate-name t1 --edition=2015 tests/t1.rs [..]--emit=[..]link[..] -C debuginfo=2 [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]].unordered()) .run(); p.root().join("target").rm_rf(); // Bench uses test profile without `--release`. p.cargo("build -v --bench=b1") - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 [..]", - ) - .with_stderr_contains( - "[RUNNING] `rustc --crate-name b1 --edition=2015 benches/b1.rs [..]--emit=[..]link[..]\ - -C debuginfo=2 [..]", - ) - .with_stderr_does_not_contain("opt-level") - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin \ - --emit=[..]link[..]-C debuginfo=2 [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link [..]-C debuginfo=2 [..]` +[RUNNING] `rustc --crate-name b1 --edition=2015 benches/b1.rs [..]--emit=[..]link[..] -C embed-bitcode=no -C debuginfo=2 [..]--test [..]` +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link [..]-C debuginfo=2 [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]].unordered()) .run(); } +#[allow(deprecated)] #[cargo_test] fn targets_selected_default() { let p = project().file("src/main.rs", "fn main() {}").build(); @@ -5759,34 +5993,32 @@ fn targets_selected_default() { #[cargo_test] fn targets_selected_all() { let p = project().file("src/main.rs", "fn main() {}").build(); + // The first RUNNING is for unit tests + // The second RUNNING is for binaries p.cargo("build -v --all-targets") - // Binaries. - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin \ - --emit=[..]link[..]", - ) - // Unit tests. - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--emit=[..]link[..]\ - -C debuginfo=2 [..]--test [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--emit=[..]link [..]-C debuginfo=2 -[..]-test[..]` +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]].unordered()) .run(); } #[cargo_test] fn all_targets_no_lib() { let p = project().file("src/main.rs", "fn main() {}").build(); + // The first RUNNING is for unit tests + // The second RUNNING is for binaries p.cargo("build -v --all-targets") - // Binaries. - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin \ - --emit=[..]link[..]", - ) - // Unit tests. - .with_stderr_contains( - "[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--emit=[..]link[..]\ - -C debuginfo=2 [..]--test [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--emit=[..]link[..] -C debuginfo=2 [..]--test [..]` +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]].unordered()) .run(); } @@ -5822,10 +6054,14 @@ fn no_linkable_target() { .file("the_lib/src/lib.rs", "pub fn foo() {}") .build(); p.cargo("build") - .with_stderr_contains( - "[WARNING] The package `the_lib` provides no linkable [..] \ - while compiling `foo`. [..] in `the_lib`'s Cargo.toml. [..]", - ) + .with_stderr_data(str![[r#" +[LOCKING] 2 packages to latest compatible versions +[WARNING] The package `the_lib` provides no linkable target. The compiler might raise an error while compiling `foo`. Consider adding 'dylib' or 'rlib' to key `crate-type` in `the_lib`'s Cargo.toml. This warning might turn into a hard error in the future. +[COMPILING] the_lib v0.1.0 ([ROOT]/foo/the_lib) +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -5851,14 +6087,13 @@ fn avoid_dev_deps() { p.cargo("build") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] `dummy-registry` index [ERROR] no matching package named `baz` found location searched: registry `crates-io` -required by package `bar v0.1.0 ([..]/foo)` -", - ) +required by package `bar v0.1.0 ([ROOT]/foo)` + +"#]]) .run(); p.cargo("build -Zavoid-dev-deps") .masquerade_as_nightly_cargo(&["avoid-dev-deps"]) @@ -5923,7 +6158,10 @@ fn invalid_cargo_config_jobs() { .build(); p.cargo("build -v") .with_status(101) - .with_stderr_contains("error: jobs may not be 0") + .with_stderr_data(str![[r#" +[ERROR] jobs may not be 0 + +"#]]) .run(); } @@ -5936,12 +6174,18 @@ fn invalid_jobs() { p.cargo("build --jobs 0") .with_status(101) - .with_stderr_contains("error: jobs may not be 0") + .with_stderr_data(str![[r#" +[ERROR] jobs may not be 0 + +"#]]) .run(); p.cargo("build --jobs over9000") .with_status(101) - .with_stderr("error: could not parse `over9000`. Number of parallel jobs should be `default` or a number.") + .with_stderr_data(str![[r#" +[ERROR] could not parse `over9000`. Number of parallel jobs should be `default` or a number. + +"#]]) .run(); } @@ -5966,32 +6210,46 @@ fn target_filters_workspace() { ws.cargo("build -v --example ex") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions [ERROR] no example target named `ex` -Did you mean `ex1`?", - ) + Did you mean `ex1`? + +"#]]) .run(); ws.cargo("build -v --example 'ex??'") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] no example target matches pattern `ex??` -Did you mean `ex1`?", - ) + Did you mean `ex1`? + +"#]]) .run(); ws.cargo("build -v --lib") - .with_stderr_contains("[RUNNING] `rustc [..]a/src/lib.rs[..]") - .with_stderr_contains("[RUNNING] `rustc [..]b/src/lib.rs[..]") + .with_stderr_data( + str![[r#" +[COMPILING] a v0.5.0 ([ROOT]/ws/a) +[COMPILING] b v0.5.0 ([ROOT]/ws/b) +[RUNNING] `rustc [..]a/src/lib.rs[..]` +[RUNNING] `rustc [..]b/src/lib.rs[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]] + .unordered(), + ) .run(); ws.cargo("build -v --example ex1") - .with_stderr_contains("[RUNNING] `rustc [..]a/examples/ex1.rs[..]") + .with_stderr_data(str![[r#" +[COMPILING] a v0.5.0 ([ROOT]/ws/a) +[RUNNING] `rustc [..]a/examples/ex1.rs[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -6014,11 +6272,11 @@ fn target_filters_workspace_not_found() { ws.cargo("build -v --lib") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[ERROR] no library targets found in packages: a, b", - ) +[ERROR] no library targets found in packages: a, b + +"#]]) .run(); } @@ -6074,17 +6332,16 @@ fn signal_display() { .build(); foo.cargo("build") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] pm [..] -[COMPILING] foo [..] -[ERROR] could not compile `foo` [..] +[COMPILING] pm v0.1.0 ([ROOT]/foo/pm) +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[ERROR] could not compile `foo` (lib) Caused by: process didn't exit successfully: `rustc [..]` (signal: 6, SIGABRT: process abort signal) -", - ) + +"#]]) .with_status(101) .run(); } @@ -6132,15 +6389,14 @@ fn pipelining_works() { .build(); foo.cargo("build") - .with_stdout("") - .with_stderr( - "\ + .with_stdout_data(str![]) + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] [..] -[COMPILING] [..] -[FINISHED] [..] -", - ) +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -6198,7 +6454,19 @@ fn pipelining_big_graph() { .build(); foo.cargo("build -p foo") .with_status(101) - .with_stderr_contains("[ERROR] could not compile `a30`[..]") + .with_stderr_data( + str![[r#" +[LOCKING] 61 packages to latest compatible versions +[COMPILING] b30 v0.5.0 ([ROOT]/foo/b30) +[COMPILING] a30 v0.5.0 ([ROOT]/foo/a30) +[ERROR] don't actually build me +... +[ERROR] could not compile `a30` (lib) due to 1 previous error +... + +"#]] + .unordered(), + ) .run(); } @@ -6249,18 +6517,22 @@ fn forward_rustc_output() { .build(); foo.cargo("build") - .with_stdout("a\nb\n{}") - .with_stderr( - "\ + .with_stdout_data(str![[r#" +a +b +{} + +"#]]) + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] [..] -[COMPILING] [..] +[COMPILING] bar v0.1.0 ([ROOT]/foo/bar) +[COMPILING] foo v0.1.0 ([ROOT]/foo) c d {a -[FINISHED] [..] -", - ) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -6272,16 +6544,12 @@ fn build_lib_only() { .build(); p.cargo("build --lib -v") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \ - --emit=[..]link[..]-C debuginfo=2 [..]\ - -C metadata=[..] \ - --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..] -L dependency=[ROOT]/foo/target/debug/deps` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -6294,7 +6562,10 @@ fn build_with_no_lib() { p.cargo("build --lib") .with_status(101) - .with_stderr("[ERROR] no library targets found in package `foo`") + .with_stderr_data(str![[r#" +[ERROR] no library targets found in package `foo` + +"#]]) .run(); } @@ -6629,15 +6900,32 @@ fn simple_terminal_width() { p.cargo("build -v") .env("__CARGO_TEST_TTY_WIDTH_DO_NOT_USE_THIS", "20") .with_status(101) - .with_stderr_contains("[RUNNING] `rustc [..]--diagnostic-width=20[..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc [..]--diagnostic-width=20[..] +error[E0308][..] +... +[ERROR] could not compile `foo` (lib) due to 1 previous error + +Caused by: + process didn't exit successfully: `rustc [..]` ([EXIT_STATUS]: 1) + +"#]]) .run(); p.cargo("doc -v") .env("__CARGO_TEST_TTY_WIDTH_DO_NOT_USE_THIS", "20") - .with_stderr_contains("[RUNNING] `rustdoc [..]--diagnostic-width=20[..]") + .with_stderr_data(str![[r#" +[DOCUMENTING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustdoc [..]--diagnostic-width=20[..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[GENERATED] [ROOT]/foo/target/doc/foo/index.html + +"#]]) .run(); } +#[allow(deprecated)] #[cargo_test] fn build_script_o0_default() { let p = project() @@ -6650,6 +6938,7 @@ fn build_script_o0_default() { .run(); } +#[allow(deprecated)] #[cargo_test] fn build_script_o0_default_even_with_release() { let p = project()