diff --git a/tests/testsuite/credential_process.rs b/tests/testsuite/credential_process.rs index a09fa073e81..2ee3a133342 100644 --- a/tests/testsuite/credential_process.rs +++ b/tests/testsuite/credential_process.rs @@ -1,9 +1,7 @@ //! Tests for credential-process. -#![allow(deprecated)] - use cargo_test_support::registry::{Package, TestRegistry}; -use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, Project}; +use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, str, Project}; fn toml_bin(proj: &Project, name: &str) -> String { proj.bin(name).display().to_string().replace('\\', "\\\\") @@ -72,19 +70,19 @@ fn publish() { let (p, _t) = get_token_test(); p.cargo("publish --no-verify --registry alternative") - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index {"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read"} -[PACKAGING] foo v0.1.0 [..] -[PACKAGED] [..] +[PACKAGING] foo v0.1.0 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) {"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.0","cksum":"[..]"} -[UPLOADING] foo v0.1.0 [..] -[UPLOADED] foo v0.1.0 [..] -[NOTE] waiting [..] +[UPLOADING] foo v0.1.0 ([ROOT]/foo) +[UPLOADED] foo v0.1.0 to registry `alternative` +[NOTE] waiting for `foo v0.1.0` to be available at registry `alternative`. You may press ctrl-c [..] -[PUBLISHED] foo v0.1.0 [..] -"#, - ) +[PUBLISHED] foo v0.1.0 at registry `alternative` + +"#]]) .run(); } @@ -99,28 +97,26 @@ fn basic_unsupported() { cargo_process("login abcdefg") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index [ERROR] credential provider `cargo:token-from-stdout false` failed action `login` Caused by: requested operation not supported -", - ) + +"#]]) .run(); cargo_process("logout") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] credential provider `cargo:token-from-stdout false` failed action `logout` Caused by: requested operation not supported -", - ) + +"#]]) .run(); } @@ -137,11 +133,11 @@ fn login() { cargo_process("login abcdefg -- cmd3 --cmd4") .replace_crates_io(registry.index_url()) - .with_stderr( - r#"[UPDATING] [..] -{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]","args":["cfg1","--cfg2","cmd3","--cmd4"]} -"#, - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[ROOTURL]/api/me","args":["cfg1","--cfg2","cmd3","--cmd4"]} + +"#]]) .run(); } @@ -157,10 +153,10 @@ fn logout() { cargo_process("logout") .replace_crates_io(server.index_url()) - .with_stderr( - r#"{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"logout"} -"#, - ) + .with_stderr_data(str![[r#" +{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"logout"} + +"#]]) .run(); } @@ -169,13 +165,13 @@ fn yank() { let (p, _t) = get_token_test(); p.cargo("yank --version 0.1.0 --registry alternative") - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index {"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read"} {"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"yank","name":"foo","vers":"0.1.0"} [YANK] foo@0.1.0 -"#, - ) + +"#]]) .run(); } @@ -184,13 +180,13 @@ fn owner() { let (p, _t) = get_token_test(); p.cargo("owner --add username --registry alternative") - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index {"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read"} {"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"owners","name":"foo"} [OWNER] completed! -"#, - ) + +"#]]) .run(); } @@ -219,15 +215,14 @@ fn invalid_token_output() { p.cargo("publish --no-verify --registry alternative") .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] `alternative` index [ERROR] credential provider `[..]test-cred[EXE]` failed action `get` Caused by: process `[..]` returned more than one line of output; expected a single token -", - ) + +"#]]) .run(); } @@ -274,13 +269,13 @@ fn not_found() { cargo_process("install -v foo") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [CREDENTIAL] [..]not_found[..] get crates-io {"v":1[..] [ERROR] no token found, please run `cargo login` -"#, - ) + +"#]]) .run(); } @@ -310,13 +305,13 @@ fn all_not_found() { cargo_process("install -v foo") .replace_crates_io(server.index_url()) .with_status(101) - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [CREDENTIAL] [..]not_found[..] get crates-io -{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=\"https://test-registry-login/me\""[..]]},"kind":"get","operation":"read"} +{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=/"https://test-registry-login/me/""[..]]},"kind":"get","operation":"read"} [ERROR] no token found, please run `cargo login` -"#, - ) + +"#]]) .run(); } @@ -346,13 +341,13 @@ fn all_not_supported() { cargo_process("install -v foo") .replace_crates_io(server.index_url()) .with_status(101) - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [CREDENTIAL] [..]not_supported[..] get crates-io -{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=\"https://test-registry-login/me\""[..]]},"kind":"get","operation":"read"} +{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=/"https://test-registry-login/me/""[..]]},"kind":"get","operation":"read"} [ERROR] no credential providers could handle the request -"#, - ) + +"#]]) .run(); } @@ -389,14 +384,14 @@ fn multiple_providers() { cargo_process("login -v abcdefg") .replace_crates_io(server.index_url()) - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [CREDENTIAL] [..]url_not_supported[..] login crates-io -{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]"} +{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[ROOTURL]/api/me"} [CREDENTIAL] [..]success_provider[..] login crates-io -{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]"} -"#, - ) +{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[ROOTURL]/api/me"} + +"#]]) .run(); } @@ -409,12 +404,12 @@ fn both_token_and_provider() { cargo_process("login -Z asymmetric-token") .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(server.index_url()) - .with_stderr( - r#"[UPDATING] [..] -[WARNING] registry `crates-io` has a token configured in [..] that will be ignored because this registry is configured to use credential-provider `cargo:paseto` + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] registry `crates-io` has a token configured in [ROOT]/home/.cargo/credentials.toml that will be ignored because this registry is configured to use credential-provider `cargo:paseto` k3.public[..] -"#, - ) + +"#]]) .run(); } @@ -436,12 +431,12 @@ fn registry_provider_overrides_global() { cargo_process("login -v abcdefg") .env("CARGO_REGISTRY_CREDENTIAL_PROVIDER", "cargo:token") .replace_crates_io(server.index_url()) - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [CREDENTIAL] cargo:token login crates-io [LOGIN] token for `crates-io` saved -"#, - ) + +"#]]) .run(); let credentials = std::fs::read_to_string(paths::home().join(".cargo/credentials.toml")).unwrap(); @@ -467,13 +462,13 @@ fn both_asymmetric_and_token() { cargo_process("login -Zasymmetric-token -v abcdefg") .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(server.index_url()) - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [WARNING] registry `crates-io` has a `secret_key` configured in [..]config.toml that will be ignored because a `token` is also configured, and the `cargo:token` provider is configured with higher precedence [CREDENTIAL] cargo:token login crates-io [LOGIN] token for `crates-io` saved -"#, - ) + +"#]]) .run(); } @@ -531,21 +526,21 @@ fn token_caching() { let output = r#"[UPDATING] `alternative` index {"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"read"} -[PACKAGING] foo v0.1.0 [..] -[PACKAGED] [..] +[PACKAGING] foo v0.1.0 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) {"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.0","cksum":"[..]"} -[UPLOADING] foo v0.1.0 [..] -[UPLOADED] foo v0.1.0 [..] +[UPLOADING] foo v0.1.0 ([ROOT]/foo) +[UPLOADED] foo v0.1.0 to registry `alternative` [NOTE] waiting [..] You may press ctrl-c [..] -[PUBLISHED] foo v0.1.0 [..] +[PUBLISHED] foo v0.1.0 at registry `alternative` "#; // The output should contain two JSON messages from the provider in both cases: // The first because the credential is expired, the second because the provider // indicated that the token was non-operation-independent. p.cargo("publish --registry alternative --no-verify") - .with_stderr(output) + .with_stderr_data(output) .run(); p.change_file( @@ -561,7 +556,7 @@ You may press ctrl-c [..] ); p.cargo("publish --registry alternative --no-verify") - .with_stderr(output) + .with_stderr_data(output) .run(); } @@ -612,20 +607,19 @@ fn basic_provider() { Package::new("bar", "0.0.1").alternative(true).publish(); p.cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] `alternative` index [LOCKING] 2 packages to latest compatible versions CARGO=Some([..]) -CARGO_REGISTRY_NAME_OPT=Some(\"alternative\") -CARGO_REGISTRY_INDEX_URL=Some([..]) +CARGO_REGISTRY_NAME_OPT=Some("alternative") +CARGO_REGISTRY_INDEX_URL=Some("[ROOTURL]/alternative-registry") [DOWNLOADING] crates ... [DOWNLOADED] bar v0.0.1 (registry `alternative`) [CHECKING] bar v0.0.1 (registry `alternative`) -[CHECKING] foo v0.0.1 ([..]) -[FINISHED] [..] -", - ) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -658,14 +652,14 @@ fn unsupported_version() { cargo_process("login abcdefg") .replace_crates_io(registry.index_url()) .with_status(101) - .with_stderr( - r#"[UPDATING] [..] + .with_stderr_data(str![[r#" +[UPDATING] crates.io index [ERROR] credential provider `[..]` failed action `login` Caused by: credential provider supports protocol versions [998, 999], while Cargo supports [1] -"#, - ) + +"#]]) .run(); } @@ -689,12 +683,12 @@ fn alias_builtin_warning() { cargo_process("login abcdefg") .replace_crates_io(registry.index_url()) - .with_stderr( - r#"[UPDATING] [..] -[WARNING] credential-alias `cargo:token` (defined in `[..]`) will be ignored because it would shadow a built-in credential-provider + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[WARNING] credential-alias `cargo:token` (defined in `[ROOT]/home/.cargo/config.toml`) will be ignored because it would shadow a built-in credential-provider [LOGIN] token for `crates-io` saved -"#, - ) + +"#]]) .run(); } @@ -709,10 +703,10 @@ fn login_token_from_stdin() { cargo_process("login") .replace_crates_io(registry.index_url()) .with_stdin("abcdefg\n") - .with_stderr( - r#"[UPDATING] [..] -{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]"} -"#, - ) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[ROOTURL]/api/me"} + +"#]]) .run(); } diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 765cd6da2cc..c13601352d5 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -2,9 +2,9 @@ //! //! See `cargo_test_support::cross_compile` for more detail. -#![allow(deprecated)] - +use cargo_test_support::prelude::*; use cargo_test_support::rustc_host; +use cargo_test_support::str; use cargo_test_support::{basic_bin_manifest, basic_manifest, cross_compile, project}; #[cargo_test] @@ -402,20 +402,14 @@ fn linker() { p.cargo("build -v --target") .arg(&target) .with_status(101) - .with_stderr_contains(&format!( - "\ -[COMPILING] foo v0.5.0 ([CWD]) -[RUNNING] `rustc --crate-name foo --edition=2015 src/foo.rs [..]--crate-type bin \ - --emit=[..]link[..]-C debuginfo=2 [..]\ - -C metadata=[..] \ - --out-dir [CWD]/target/{target}/debug/deps \ - --target {target} \ - -C linker=my-linker-tool \ - -L dependency=[CWD]/target/{target}/debug/deps \ - -L dependency=[CWD]/target/debug/deps` -", - target = target, - )) + .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 --crate-name foo --edition=2015 src/foo.rs [..]--crate-type bin --emit=[..]link[..]-C debuginfo=2 [..] -C metadata=[..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps --target [ALT_TARGET] -C linker=my-linker-tool -L dependency=[ROOT]/foo/target/[ALT_TARGET]/debug/deps -L dependency=[ROOT]/foo/target/debug/deps` +[ERROR] linker `my-linker-tool` not found +... +"#]]) .run(); } @@ -470,16 +464,28 @@ fn cross_tests() { let target = cross_compile::alternate(); p.cargo("test --target") .arg(&target) - .with_stderr(&format!( - "\ -[COMPILING] foo v0.0.0 ([CWD]) -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/{triple}/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/{triple}/debug/deps/bar-[..][EXE])", - triple = target - )) - .with_stdout_contains("test test_foo ... ok") - .with_stdout_contains("test test ... ok") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/[ALT_TARGET]/debug/deps/foo-[HASH][EXE]) +[RUNNING] unittests src/bin/bar.rs (target/[ALT_TARGET]/debug/deps/bar-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" + +running 1 test +test test_foo ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +running 1 test +test test ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s + + +"#]]) .run(); } @@ -502,45 +508,47 @@ fn no_cross_doctests() { .build(); let host_output = "\ -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[COMPILING] foo v0.0.1 ([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 "; println!("a"); - p.cargo("test").with_stderr(&host_output).run(); + p.cargo("test").with_stderr_data(host_output).run(); println!("b"); let target = rustc_host(); p.cargo("test -v --target") .arg(&target) // Unordered since the two `rustc` invocations happen concurrently. - .with_stderr_unordered(&format!( - "\ -[COMPILING] foo v0.0.1 ([CWD]) + .with_stderr_data( + str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo [..]--crate-type lib[..] [RUNNING] `rustc --crate-name foo [..]--test[..] -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[CWD]/target/{target}/debug/deps/foo-[..][EXE]` +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] `[ROOT]/foo/target/[HOST_TARGET]/debug/deps/foo-[HASH][EXE]` [DOCTEST] foo -[RUNNING] `rustdoc [..]--target {target}[..]` -", - )) - .with_stdout( - " +[RUNNING] `rustdoc [..]--target [HOST_TARGET][..]` + +"#]] + .unordered(), + ) + .with_stdout_data(str![[r#" + running 0 tests -test result: ok. 0 passed[..] +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s running 1 test test src/lib.rs - (line 2) ... ok -test result: ok. 1 passed[..] +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s -", - ) + +"#]]) .run(); println!("c"); @@ -550,17 +558,14 @@ test result: ok. 1 passed[..] // This should probably be a warning or error. p.cargo("test -v --doc --target") .arg(&target) - .with_stderr( - "\ -[COMPILING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo [..] -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[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. -", - ) +[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() { @@ -570,19 +575,15 @@ for more information. // This tests the library, but does not run the doc tests. p.cargo("test -v --target") .arg(&target) - .with_stderr(&format!( - "\ -[COMPILING] foo v0.0.1 ([CWD]) + .with_stderr_data(str![[r#" +[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]` -[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. -", - 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(); } @@ -661,16 +662,14 @@ fn cross_with_a_build_script() { p.cargo("build -v --target") .arg(&target) - .with_stderr(&format!( - "\ -[COMPILING] foo v0.0.0 ([CWD]) -[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/debug/build/foo-[..]` -[RUNNING] `[CWD]/target/debug/build/foo-[..]/build-script-build` -[RUNNING] `rustc [..] src/main.rs [..] --target {target} [..]` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - target = target, - )) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[RUNNING] `rustc [..] build.rs [..] --out-dir [ROOT]/foo/target/debug/build/foo-[HASH] [..] +[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` +[RUNNING] `rustc [..] src/main.rs [..] --target [ALT_TARGET] [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -681,7 +680,6 @@ fn build_script_needed_for_host_and_target() { } let target = cross_compile::alternate(); - let host = rustc_host(); let p = project() .file( "Cargo.toml", @@ -762,28 +760,23 @@ fn build_script_needed_for_host_and_target() { p.cargo("build -v --target") .arg(&target) - .with_stderr_contains(&"[COMPILING] d1 v0.0.0 ([CWD]/d1)") - .with_stderr_contains( - "[RUNNING] `rustc [..] d1/build.rs [..] --out-dir [CWD]/target/debug/build/d1-[..]`", - ) - .with_stderr_contains("[RUNNING] `[CWD]/target/debug/build/d1-[..]/build-script-build`") - .with_stderr_contains("[RUNNING] `rustc [..] d1/src/lib.rs [..]`") - .with_stderr_contains("[COMPILING] d2 v0.0.0 ([CWD]/d2)") - .with_stderr_contains(&format!( - "[RUNNING] `rustc [..] d2/src/lib.rs [..] -L /path/to/{host}`", - host = host - )) - .with_stderr_contains("[COMPILING] foo v0.0.0 ([CWD])") - .with_stderr_contains(&format!( - "[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/debug/build/foo-[..] \ - -L /path/to/{host}`", - host = host - )) - .with_stderr_contains(&format!( - "[RUNNING] `rustc [..] src/main.rs [..] --target {target} [..] \ - -L /path/to/{target}`", - target = target - )) + .with_stderr_data(str![[r#" +[LOCKING] 3 packages to latest compatible versions +[COMPILING] d1 v0.0.0 ([ROOT]/foo/d1) +[RUNNING] `rustc [..] d1/build.rs [..] --out-dir [ROOT]/foo/target/debug/build/d1-[HASH] [..] +[RUNNING] `[ROOT]/foo/target/debug/build/d1-[HASH]/build-script-build` +[RUNNING] `[ROOT]/foo/target/debug/build/d1-[HASH]/build-script-build` +[RUNNING] `rustc [..] d1/src/lib.rs [..] --out-dir [ROOT]/foo/target/debug/deps [..] +[RUNNING] `rustc [..] d1/src/lib.rs [..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps [..] +[COMPILING] d2 v0.0.0 ([ROOT]/foo/d2) +[RUNNING] `rustc [..] d2/src/lib.rs [..] --out-dir [ROOT]/foo/target/debug/deps [..] +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[RUNNING] `rustc [..] build.rs [..] --out-dir [ROOT]/foo/target/debug/build/foo-[HASH] [..] +[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` +[RUNNING] `rustc [..] src/main.rs [..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps --target [ALT_TARGET] [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]].unordered()) .run(); } @@ -943,21 +936,19 @@ fn build_script_with_platform_specific_dependencies() { p.cargo("build -v --target") .arg(&target) - .with_stderr(&format!( - "\ + .with_stderr_data(str![[r#" [LOCKING] 3 packages to latest compatible versions -[COMPILING] d2 v0.0.0 ([..]) +[COMPILING] d2 v0.0.0 ([ROOT]/foo/d2) [RUNNING] `rustc [..] d2/src/lib.rs [..]` -[COMPILING] d1 v0.0.0 ([..]) +[COMPILING] d1 v0.0.0 ([ROOT]/foo/d1) [RUNNING] `rustc [..] d1/src/lib.rs [..]` -[COMPILING] foo v0.0.1 ([..]) +[COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc [..] build.rs [..]` -[RUNNING] `[CWD]/target/debug/build/foo-[..]/build-script-build` -[RUNNING] `rustc [..] src/lib.rs [..] --target {target} [..]` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - target = target - )) +[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` +[RUNNING] `rustc [..] src/lib.rs [..] --target [ALT_TARGET] [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1013,7 +1004,11 @@ fn platform_specific_dependencies_do_not_leak() { p.cargo("build -v --target") .arg(&target) .with_status(101) - .with_stderr_contains("[..] can't find crate for `d2`[..]") + .with_stderr_data(str![[r#" +... +error[E0463]: can't find crate for `d2` +... +"#]]) .run(); } @@ -1192,17 +1187,30 @@ fn cross_test_dylib() { p.cargo("test --target") .arg(&target) - .with_stderr(&format!( - "\ + .with_stderr_data(str![[r#" [LOCKING] 2 packages to latest compatible versions -[COMPILING] bar v0.0.1 ([CWD]/bar) -[COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/{arch}/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/{arch}/debug/deps/test-[..][EXE])", - arch = cross_compile::alternate() - )) - .with_stdout_contains_n("test foo ... ok", 2) +[COMPILING] bar v0.0.1 ([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/[ALT_TARGET]/debug/deps/foo-[HASH][EXE]) +[RUNNING] tests/test.rs (target/[ALT_TARGET]/debug/deps/test-[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 + + +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(); } @@ -1241,12 +1249,14 @@ fn doctest_xcompile_linker() { .arg(&target) .with_status(101) .masquerade_as_nightly_cargo(&["doctest-xcompile"]) - .with_stderr_contains(&format!( - "\ -[RUNNING] `rustdoc --edition=2015 --crate-type lib --crate-name foo --test [..]\ - --target {target} [..] -C linker=my-linker-tool[..] -", - target = target, - )) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps --target [ALT_TARGET] [..] +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[DOCTEST] foo +[RUNNING] `rustdoc [..] src/lib.rs [..] +[ERROR] doctest failed, to rerun pass `--doc` + +"#]]) .run(); } diff --git a/tests/testsuite/cross_publish.rs b/tests/testsuite/cross_publish.rs index a1fe08f5473..fcf7a0697b8 100644 --- a/tests/testsuite/cross_publish.rs +++ b/tests/testsuite/cross_publish.rs @@ -1,10 +1,8 @@ //! Tests for publishing using the `--target` flag. -#![allow(deprecated)] - use std::fs::File; -use cargo_test_support::{cross_compile, project, publish, registry}; +use cargo_test_support::{cross_compile, project, publish, registry, str}; #[cargo_test] fn simple_cross_package() { @@ -43,15 +41,14 @@ fn simple_cross_package() { p.cargo("package --target") .arg(&target) - .with_stderr( - "\ -[PACKAGING] foo v0.0.0 ([CWD]) -[PACKAGED] 4 files, [..] ([..] compressed) -[VERIFYING] foo v0.0.0 ([CWD]) -[COMPILING] foo v0.0.0 ([CWD]/target/package/foo-0.0.0) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[PACKAGING] foo v0.0.0 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.0 ([ROOT]/foo) +[COMPILING] foo v0.0.0 ([ROOT]/foo/target/package/foo-0.0.0) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Check that the tarball contains the files @@ -107,20 +104,19 @@ fn publish_with_target() { .replace_crates_io(registry.index_url()) .arg("--target") .arg(&target) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [UPDATING] crates.io index -[PACKAGING] foo v0.0.0 ([CWD]) -[PACKAGED] [..] -[VERIFYING] foo v0.0.0 ([CWD]) -[COMPILING] foo v0.0.0 ([CWD]/target/package/foo-0.0.0) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -[UPLOADING] foo v0.0.0 ([CWD]) +[PACKAGING] foo v0.0.0 ([ROOT]/foo) +[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +[VERIFYING] foo v0.0.0 ([ROOT]/foo) +[COMPILING] foo v0.0.0 ([ROOT]/foo/target/package/foo-0.0.0) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[UPLOADING] foo v0.0.0 ([ROOT]/foo) [UPLOADED] foo v0.0.0 to registry `crates-io` -[NOTE] waiting [..] -You may press ctrl-c [..] +[NOTE] waiting for `foo v0.0.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.0.0 at registry `crates-io` -", - ) + +"#]]) .run(); } diff --git a/tests/testsuite/custom_target.rs b/tests/testsuite/custom_target.rs index 3bfd7cd8e91..7c116221da8 100644 --- a/tests/testsuite/custom_target.rs +++ b/tests/testsuite/custom_target.rs @@ -1,8 +1,6 @@ //! Tests for custom json target specifications. -#![allow(deprecated)] - -use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{basic_manifest, project, str}; use std::fs; const MINIMAL_LIB: &str = r#" @@ -60,7 +58,13 @@ fn custom_target_minimal() { // Ensure that the correct style of flag is passed to --target with doc tests. p.cargo("test --doc --target src/../custom-target.json -v -Zdoctest-xcompile") .masquerade_as_nightly_cargo(&["doctest-xcompile", "no_core", "lang_items"]) - .with_stderr_contains("[RUNNING] `rustdoc [..]--target [..]foo/custom-target.json[..]") + .with_stderr_data(str![[r#" +[FRESH] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[DOCTEST] foo +[RUNNING] `rustdoc [..]--target [..]foo/custom-target.json[..] + +"#]]) .run(); } @@ -157,12 +161,11 @@ fn changing_spec_rebuilds() { p.cargo("build --lib --target custom-target.json -v").run(); p.cargo("build --lib --target custom-target.json -v") - .with_stderr( - "\ -[FRESH] foo [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[FRESH] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); let spec_path = p.root().join("custom-target.json"); let spec = fs::read_to_string(&spec_path).unwrap(); @@ -170,13 +173,12 @@ fn changing_spec_rebuilds() { let spec = spec.replace('{', "{\n\"vendor\": \"unknown\",\n"); fs::write(&spec_path, spec).unwrap(); p.cargo("build --lib --target custom-target.json -v") - .with_stderr( - "\ -[COMPILING] foo v0.0.1 [..] -[RUNNING] `rustc [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -204,7 +206,10 @@ fn changing_spec_relearns_crate_types() { p.cargo("build --lib --target custom-target.json -v") .with_status(101) - .with_stderr("error: cannot produce cdylib for `foo [..]") + .with_stderr_data(str![[r#" +[ERROR] cannot produce cdylib for `foo v0.1.0 ([ROOT]/foo)` [..] + +"#]]) .run(); // Enable dynamic linking. @@ -214,13 +219,12 @@ fn changing_spec_relearns_crate_types() { fs::write(&spec_path, spec).unwrap(); p.cargo("build --lib --target custom-target.json -v") - .with_stderr( - "\ -[COMPILING] foo [..] -[RUNNING] `rustc [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.1.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -245,16 +249,18 @@ fn custom_target_ignores_filepath() { // Should build the library the first time. p.cargo("build --lib --target a/custom-target.json") - .with_stderr( - "\ -[..]Compiling foo v0.0.1 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // But not the second time, even though the path to the custom target is dfferent. p.cargo("build --lib --target b/custom-target.json") - .with_stderr("[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); }