mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
test: migrate tool_paths to snapbox
This commit is contained in:
parent
8bdb52fb82
commit
2d01f408ec
@ -1,8 +1,6 @@
|
||||
//! Tests for configuration values that point to programs.
|
||||
|
||||
#![allow(deprecated)]
|
||||
|
||||
use cargo_test_support::{basic_lib_manifest, project, rustc_host, rustc_host_env};
|
||||
use cargo_test_support::{basic_lib_manifest, project, rustc_host, rustc_host_env, str};
|
||||
|
||||
#[cargo_test]
|
||||
fn pathless_tools() {
|
||||
@ -24,13 +22,12 @@ fn pathless_tools() {
|
||||
.build();
|
||||
|
||||
foo.cargo("build --verbose")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo v0.5.0 ([CWD])
|
||||
[RUNNING] `rustc [..] -C linker=nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -50,13 +47,12 @@ fn custom_linker_cfg() {
|
||||
.build();
|
||||
|
||||
foo.cargo("build --verbose")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo v0.5.0 ([CWD])
|
||||
[RUNNING] `rustc [..] -C linker=nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -83,13 +79,12 @@ fn custom_linker_cfg_precedence() {
|
||||
.build();
|
||||
|
||||
foo.cargo("build --verbose")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo v0.5.0 ([CWD])
|
||||
[RUNNING] `rustc [..] -C linker=nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -111,13 +106,12 @@ fn custom_linker_cfg_collision() {
|
||||
|
||||
foo.cargo("build --verbose")
|
||||
.with_status(101)
|
||||
.with_stderr(&format!(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] several matching instances of `target.'cfg(..)'.linker` in configurations
|
||||
first match `cfg(not(target_arch = \"avr\"))` located in [..]/foo/.cargo/config.toml
|
||||
second match `cfg(not(target_os = \"none\"))` located in [..]/foo/.cargo/config.toml
|
||||
",
|
||||
))
|
||||
first match `cfg(not(target_arch = "avr"))` located in [ROOT]/foo/.cargo/config.toml
|
||||
second match `cfg(not(target_os = "none"))` located in [ROOT]/foo/.cargo/config.toml
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -149,13 +143,12 @@ fn absolute_tools() {
|
||||
.build();
|
||||
|
||||
foo.cargo("build --verbose")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo v0.5.0 ([CWD])
|
||||
[RUNNING] `rustc [..] -C linker=[..]bogus/nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
)
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]-C linker=[..]/bogus/nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -189,18 +182,14 @@ fn relative_tools() {
|
||||
)
|
||||
.build();
|
||||
|
||||
let prefix = p.root().into_os_string().into_string().unwrap();
|
||||
|
||||
p.cargo("build --verbose")
|
||||
.cwd("bar")
|
||||
.with_stderr(&format!(
|
||||
"\
|
||||
[COMPILING] bar v0.5.0 ([CWD])
|
||||
[RUNNING] `rustc [..] -C linker={prefix}/./tools/nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
prefix = prefix,
|
||||
))
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
|
||||
[RUNNING] `rustc [..]-C linker=[ROOT]/foo/./tools/nonexistent-linker [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -226,38 +215,35 @@ fn custom_runner() {
|
||||
|
||||
p.cargo("run -- --param")
|
||||
.with_status(101)
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[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
|
||||
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
|
||||
",
|
||||
)
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
p.cargo("test --test test --verbose -- --param")
|
||||
.with_status(101)
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[RUNNING] `nonexistent-runner -r [..]/target/debug/deps/test-[..][EXE] --param`
|
||||
",
|
||||
)
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] `nonexistent-runner -r [ROOT]/foo/target/debug/deps/test-[HASH][EXE] --param`
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
p.cargo("bench --bench bench --verbose -- --param")
|
||||
.with_status(101)
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `bench` profile [optimized] target(s) in [..]
|
||||
[RUNNING] `nonexistent-runner -r [..]/target/release/deps/bench-[..][EXE] --param --bench`
|
||||
",
|
||||
)
|
||||
[FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s
|
||||
[RUNNING] `nonexistent-runner -r [ROOT]/foo/target/release/deps/bench-[HASH][EXE] --param --bench`
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -277,13 +263,12 @@ fn custom_runner_cfg() {
|
||||
|
||||
p.cargo("run -- --param")
|
||||
.with_status(101)
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[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
|
||||
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
|
||||
",
|
||||
)
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -311,13 +296,12 @@ fn custom_runner_cfg_precedence() {
|
||||
|
||||
p.cargo("run -- --param")
|
||||
.with_status(101)
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[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
|
||||
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
|
||||
",
|
||||
)
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -339,13 +323,12 @@ fn custom_runner_cfg_collision() {
|
||||
|
||||
p.cargo("run -- --param")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] several matching instances of `target.'cfg(..)'.runner` in configurations
|
||||
first match `cfg(not(target_arch = \"avr\"))` located in [..]/foo/.cargo/config.toml
|
||||
second match `cfg(not(target_os = \"none\"))` located in [..]/foo/.cargo/config.toml
|
||||
",
|
||||
)
|
||||
first match `cfg(not(target_arch = "avr"))` located in [ROOT]/foo/.cargo/config.toml
|
||||
second match `cfg(not(target_os = "none"))` located in [ROOT]/foo/.cargo/config.toml
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -361,17 +344,16 @@ fn custom_runner_env() {
|
||||
// FIXME: Update "Caused by" error message once rust/pull/87704 is merged.
|
||||
// On Windows, changing to a custom executable resolver has changed the
|
||||
// error messages.
|
||||
.with_stderr(&format!(
|
||||
"\
|
||||
[COMPILING] foo [..]
|
||||
[FINISHED] `dev` profile [..]
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] `nonexistent-runner --foo target/debug/foo[EXE]`
|
||||
[ERROR] could not execute process `nonexistent-runner --foo target/debug/foo[EXE]` (never executed)
|
||||
|
||||
Caused by:
|
||||
[..]
|
||||
"
|
||||
))
|
||||
[NOT_FOUND]
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -397,7 +379,11 @@ fn custom_runner_env_overrides_config() {
|
||||
p.cargo("run")
|
||||
.env(&key, "should-run --foo")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[RUNNING] `should-run --foo target/debug/foo[EXE]`")
|
||||
.with_stderr_data(str![[r#"
|
||||
...
|
||||
[RUNNING] `should-run --foo target/debug/foo[EXE]`
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -412,7 +398,12 @@ fn custom_runner_env_true() {
|
||||
|
||||
p.cargo("run")
|
||||
.env(&key, "true")
|
||||
.with_stderr_contains("[RUNNING] `true target/debug/foo[EXE]`")
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] `true target/debug/foo[EXE]`
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -425,7 +416,11 @@ fn custom_linker_env() {
|
||||
p.cargo("build -v")
|
||||
.env(&key, "nonexistent-linker")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[RUNNING] `rustc [..]-C linker=nonexistent-linker [..]")
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
@ -442,11 +437,13 @@ fn target_in_environment_contains_lower_case() {
|
||||
p.cargo("build -v --target")
|
||||
.arg(target)
|
||||
.env(&env_key, "nonexistent-linker")
|
||||
.with_stderr_contains(format!(
|
||||
"warning: environment variables are expected to use uppercase \
|
||||
letters and underscores, the variable `{}` will be ignored and \
|
||||
have no effect",
|
||||
env_key
|
||||
.with_stderr_data(format!("\
|
||||
[WARNING] environment variables are expected to use uppercase letters and underscores, the variable `{env_key}` will be ignored and have no effect
|
||||
[WARNING] environment variables are expected to use uppercase letters and underscores, the variable `{env_key}` will be ignored and have no effect
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
"
|
||||
))
|
||||
.run();
|
||||
}
|
||||
@ -476,15 +473,14 @@ fn cfg_ignored_fields() {
|
||||
.build();
|
||||
|
||||
p.cargo("check")
|
||||
.with_stderr(
|
||||
"\
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] unused key `somelib` in [target] config table `cfg(not(bar))`
|
||||
[WARNING] unused key `ar` in [target] config table `cfg(not(target_os = \"none\"))`
|
||||
[WARNING] unused key `foo` in [target] config table `cfg(not(target_os = \"none\"))`
|
||||
[WARNING] unused key `invalid` in [target] config table `cfg(not(target_os = \"none\"))`
|
||||
[CHECKING] foo v0.0.1 ([..])
|
||||
[FINISHED] [..]
|
||||
",
|
||||
)
|
||||
[WARNING] unused key `ar` in [target] config table `cfg(not(target_os = "none"))`
|
||||
[WARNING] unused key `foo` in [target] config table `cfg(not(target_os = "none"))`
|
||||
[WARNING] unused key `invalid` in [target] config table `cfg(not(target_os = "none"))`
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user