diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index 0db2a3de6e6..1a51d20b0eb 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -2,7 +2,7 @@ use std::env; -use cargo_test_support::project; +use cargo_test_support::{is_nightly, project}; #[cargo_test] fn profile_overrides() { @@ -471,6 +471,10 @@ fn thin_lto_works() { #[cargo_test] fn strip_works() { + if !is_nightly() { + return; + } + let p = project() .file( "Cargo.toml", @@ -499,3 +503,76 @@ fn strip_works() { ) .run(); } + +#[cargo_test] +fn strip_requires_cargo_feature() { + if !is_nightly() { + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [profile.release] + strip = 'symbols' + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("build --release -v") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + +Caused by: + feature `strip` is required + +consider adding `cargo-features = [\"strip\"]` to the manifest +", + ) + .run(); +} +#[cargo_test] +fn strip_rejects_invalid_option() { + if !is_nightly() { + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["strip"] + + [package] + name = "foo" + version = "0.1.0" + + [profile.release] + strip = 'wrong' + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("build --release -v") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + +Caused by: + unknown variant `wrong`, expected one of `debuginfo`, `none`, `symbols` for key [..] +", + ) + .run(); +}