mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
test: migrate profile_config to snapbox
This commit is contained in:
parent
bc89bffa59
commit
f58bb77033
@ -1,10 +1,9 @@
|
|||||||
//! Tests for profiles defined in config files.
|
//! Tests for profiles defined in config files.
|
||||||
|
|
||||||
#![allow(deprecated)]
|
|
||||||
|
|
||||||
use cargo_test_support::paths::CargoPathExt;
|
use cargo_test_support::paths::CargoPathExt;
|
||||||
|
use cargo_test_support::prelude::*;
|
||||||
use cargo_test_support::registry::Package;
|
use cargo_test_support::registry::Package;
|
||||||
use cargo_test_support::{basic_lib_manifest, paths, project};
|
use cargo_test_support::{basic_lib_manifest, paths, project, str};
|
||||||
use cargo_util_schemas::manifest::TomlDebugInfo;
|
use cargo_util_schemas::manifest::TomlDebugInfo;
|
||||||
|
|
||||||
// TODO: this should be remove once -Zprofile-rustflags is stabilized
|
// TODO: this should be remove once -Zprofile-rustflags is stabilized
|
||||||
@ -33,18 +32,23 @@ fn rustflags_works_with_zflag() {
|
|||||||
p.cargo("check -v")
|
p.cargo("check -v")
|
||||||
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr_contains("[..]feature `profile-rustflags` is required[..]")
|
.with_stderr_data(str![[r#"
|
||||||
|
[ERROR] config profile `dev` is not valid (defined in `[ROOT]/foo/.cargo/config.toml`)
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
feature `profile-rustflags` is required
|
||||||
|
...
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.cargo("check -v -Zprofile-rustflags")
|
p.cargo("check -v -Zprofile-rustflags")
|
||||||
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||||
[CHECKING] foo [..]
|
[RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..]`
|
||||||
[RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
[FINISHED] [..]
|
|
||||||
",
|
"#]])
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
p.change_file(
|
p.change_file(
|
||||||
@ -60,12 +64,11 @@ fn rustflags_works_with_zflag() {
|
|||||||
|
|
||||||
p.cargo("check -v")
|
p.cargo("check -v")
|
||||||
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||||
[FRESH] foo [..]
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
[FINISHED] [..]
|
|
||||||
",
|
"#]])
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,17 +98,14 @@ fn profile_config_validate_warnings() {
|
|||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("build")
|
p.cargo("build").with_stderr_data(str![[r#"
|
||||||
.with_stderr_unordered(
|
[WARNING] unused config key `profile.dev.bad-key` in `[ROOT]/foo/.cargo/config.toml`
|
||||||
"\
|
[WARNING] unused config key `profile.dev.build-override.bad-key-bo` in `[ROOT]/foo/.cargo/config.toml`
|
||||||
[WARNING] unused config key `profile.dev.bad-key` in `[..].cargo/config.toml`
|
[WARNING] unused config key `profile.dev.package.bar.bad-key-bar` in `[ROOT]/foo/.cargo/config.toml`
|
||||||
[WARNING] unused config key `profile.dev.package.bar.bad-key-bar` in `[..].cargo/config.toml`
|
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||||
[WARNING] unused config key `profile.dev.build-override.bad-key-bo` in `[..].cargo/config.toml`
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
[COMPILING] foo [..]
|
|
||||||
[FINISHED] [..]
|
"#]].unordered()).run();
|
||||||
",
|
|
||||||
)
|
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
@ -132,14 +132,13 @@ fn profile_config_error_paths() {
|
|||||||
|
|
||||||
p.cargo("build")
|
p.cargo("build")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `profile.dev`
|
||||||
[ERROR] error in [..]/foo/.cargo/config.toml: could not load config key `profile.dev`
|
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
error in [..]/home/.cargo/config.toml: `profile.dev.rpath` expected true/false, but found a string
|
error in [ROOT]/home/.cargo/config.toml: `profile.dev.rpath` expected true/false, but found a string
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +158,13 @@ fn profile_config_validate_errors() {
|
|||||||
|
|
||||||
p.cargo("build")
|
p.cargo("build")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[ERROR] config profile `dev` is not valid (defined in `[ROOT]/foo/.cargo/config.toml`)
|
||||||
[ERROR] config profile `dev` is not valid (defined in `[..]/foo/.cargo/config.toml`)
|
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
`panic` may not be specified in a `package` profile
|
`panic` may not be specified in a `package` profile
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,14 +184,13 @@ fn profile_config_syntax_errors() {
|
|||||||
|
|
||||||
p.cargo("build")
|
p.cargo("build")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `profile.dev`
|
||||||
[ERROR] error in [..]/.cargo/config.toml: could not load config key `profile.dev`
|
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
error in [..]/foo/.cargo/config.toml: `profile.dev.codegen-units` expected an integer, but found a string
|
error in [ROOT]/foo/.cargo/config.toml: `profile.dev.codegen-units` expected an integer, but found a string
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,12 +228,12 @@ fn profile_config_override_spec_multiple() {
|
|||||||
// much of a problem.
|
// much of a problem.
|
||||||
p.cargo("build -v")
|
p.cargo("build -v")
|
||||||
.with_status(101)
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([..])`
|
[ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([ROOT]/foo/bar)`
|
||||||
found package specs: bar, bar@0.5.0",
|
found package specs: bar, bar@0.5.0
|
||||||
)
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,22 +261,12 @@ fn profile_config_all_options() {
|
|||||||
|
|
||||||
p.cargo("build --release -v")
|
p.cargo("build --release -v")
|
||||||
.env_remove("CARGO_INCREMENTAL")
|
.env_remove("CARGO_INCREMENTAL")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||||
[COMPILING] foo [..]
|
[RUNNING] `rustc --crate-name foo [..] -C opt-level=1 -C panic=abort -C lto[..]-C codegen-units=2 -C debuginfo=2 [..]-C debug-assertions=on -C overflow-checks=off [..]-C rpath --out-dir [ROOT]/foo/target/release/deps -C incremental=[ROOT]/foo/target/release/incremental[..]`
|
||||||
[RUNNING] `rustc --crate-name foo [..] \
|
[FINISHED] `release` profile [optimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
-C opt-level=1 \
|
|
||||||
-C panic=abort \
|
"#]])
|
||||||
-C lto[..]\
|
|
||||||
-C codegen-units=2 \
|
|
||||||
-C debuginfo=2 [..]\
|
|
||||||
-C debug-assertions=on \
|
|
||||||
-C overflow-checks=off [..]\
|
|
||||||
-C rpath [..]\
|
|
||||||
-C incremental=[..]
|
|
||||||
[FINISHED] `release` profile [optimized + debuginfo] [..]
|
|
||||||
",
|
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,18 +305,19 @@ fn profile_config_override_precedence() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("build -v")
|
p.cargo("build -v")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[COMPILING] bar [..]
|
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
|
||||||
[RUNNING] `rustc --crate-name bar [..] -C opt-level=2[..]-C codegen-units=2 [..]
|
[RUNNING] `rustc --crate-name bar [..] -C opt-level=2[..]-C codegen-units=2 [..]`
|
||||||
[COMPILING] foo [..]
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||||
[RUNNING] `rustc --crate-name foo [..]-C codegen-units=2 [..]
|
[RUNNING] `rustc --crate-name foo [..]-C codegen-units=2 [..]`
|
||||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]",
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
)
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn profile_config_no_warn_unknown_override() {
|
fn profile_config_no_warn_unknown_override() {
|
||||||
let p = project()
|
let p = project()
|
||||||
@ -371,7 +359,12 @@ fn profile_config_mixed_types() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("build -v")
|
p.cargo("build -v")
|
||||||
.with_stderr_contains("[..]-C opt-level=3 [..]")
|
.with_stderr_data(str![[r#"
|
||||||
|
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||||
|
[RUNNING] `rustc [..]-C opt-level=3 [..]`
|
||||||
|
[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,10 +479,16 @@ fn named_env_profile() {
|
|||||||
p.cargo("build -v --profile=other")
|
p.cargo("build -v --profile=other")
|
||||||
.env("CARGO_PROFILE_OTHER_CODEGEN_UNITS", "1")
|
.env("CARGO_PROFILE_OTHER_CODEGEN_UNITS", "1")
|
||||||
.env("CARGO_PROFILE_OTHER_INHERITS", "dev")
|
.env("CARGO_PROFILE_OTHER_INHERITS", "dev")
|
||||||
.with_stderr_contains("[..]-C codegen-units=1 [..]")
|
.with_stderr_data(str![[r#"
|
||||||
|
[COMPILING] foo v0.1.0 ([ROOT]/foo)
|
||||||
|
[RUNNING] `rustc [..]-C codegen-units=1 [..]`
|
||||||
|
[FINISHED] `other` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||||
|
|
||||||
|
"#]])
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn test_with_dev_profile() {
|
fn test_with_dev_profile() {
|
||||||
// The `test` profile inherits from `dev` for both local crates and
|
// The `test` profile inherits from `dev` for both local crates and
|
||||||
@ -512,20 +511,19 @@ fn test_with_dev_profile() {
|
|||||||
.build();
|
.build();
|
||||||
p.cargo("test --lib --no-run -v")
|
p.cargo("test --lib --no-run -v")
|
||||||
.env("CARGO_PROFILE_DEV_DEBUG", "0")
|
.env("CARGO_PROFILE_DEV_DEBUG", "0")
|
||||||
.with_stderr(
|
.with_stderr_data(str![[r#"
|
||||||
"\
|
[UPDATING] `dummy-registry` index
|
||||||
[UPDATING] [..]
|
|
||||||
[LOCKING] 2 packages to latest compatible versions
|
[LOCKING] 2 packages to latest compatible versions
|
||||||
[DOWNLOADING] [..]
|
[DOWNLOADING] crates ...
|
||||||
[DOWNLOADED] [..]
|
[DOWNLOADED] somedep v1.0.0 (registry `dummy-registry`)
|
||||||
[COMPILING] somedep v1.0.0
|
[COMPILING] somedep v1.0.0
|
||||||
[RUNNING] `rustc --crate-name somedep [..]
|
[RUNNING] `rustc --crate-name somedep [..]`
|
||||||
[COMPILING] foo v0.1.0 [..]
|
[COMPILING] foo v0.1.0 ([ROOT]/foo)
|
||||||
[RUNNING] `rustc --crate-name foo [..]
|
[RUNNING] `rustc --crate-name foo [..]`
|
||||||
[FINISHED] [..]
|
[FINISHED] `test` profile [unoptimized] target(s) in [ELAPSED]s
|
||||||
[EXECUTABLE] `[..]/target/debug/deps/foo-[..][EXE]`
|
[EXECUTABLE] `[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`
|
||||||
",
|
|
||||||
)
|
"#]])
|
||||||
.with_stdout_does_not_contain("[..] -C debuginfo=0[..]")
|
.with_stdout_does_not_contain("[..] -C debuginfo=0[..]")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user