From: Eric Huss Date: Sat, 21 Apr 2018 16:50:55 +0000 (-0700) Subject: Add test for profile override on non-dev/release. X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~41^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ba537d73b9477d08677b5547cbd7368a86d60e40;p=cargo.git Add test for profile override on non-dev/release. --- diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index acd4b0af2..76f54de91 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -407,8 +407,8 @@ impl TomlProfile { _ => { if self.overrides.is_some() || self.build_override.is_some() { bail!( - "Profile overrides may only be specified for `dev` - or `release` profile, not {}.", + "Profile overrides may only be specified for \ + `dev` or `release` profile, not `{}`.", name ); } diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index be5c6b615..9452c1417 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -474,13 +474,16 @@ fn profile_override_bad_name() { assert_that( p.cargo("build").masquerade_as_nightly_cargo(), - execs().with_status(0).with_stderr_contains("\ + execs().with_status(0).with_stderr_contains( + "\ [WARNING] package `bart` for profile override not found Did you mean `bar`? [WARNING] package `no-suggestion` for profile override not found [COMPILING] [..] -")); +", + ), + ); } #[test] @@ -505,8 +508,46 @@ fn profile_panic_test_bench() { assert_that( p.cargo("build"), - execs().with_status(0).with_stderr_contains("\ + execs().with_status(0).with_stderr_contains( + "\ [WARNING] `panic` setting is ignored for `test` profile [WARNING] `panic` setting is ignored for `bench` profile -")); +", + ), + ); +} + +#[test] +fn profile_override_dev_release_only() { + let p = project("foo") + .file( + "Cargo.toml", + r#" + cargo-features = ["profile-overrides"] + + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + bar = {path = "bar"} + + [profile.test.overrides.bar] + opt-level = 3 + "#, + ) + .file("src/lib.rs", "") + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) + .file("bar/src/lib.rs", "") + .build(); + + assert_that( + p.cargo("build").masquerade_as_nightly_cargo(), + execs().with_status(101).with_stderr_contains( + "\ +Caused by: + Profile overrides may only be specified for `dev` or `release` profile, not `test`. +", + ), + ); }