From ba537d73b9477d08677b5547cbd7368a86d60e40 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 21 Apr 2018 09:50:55 -0700 Subject: [PATCH] Add test for profile override on non-dev/release. --- src/cargo/util/toml/mod.rs | 4 +-- tests/testsuite/profiles.rs | 49 ++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 6 deletions(-) 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`. +", + ), + ); } -- 2.30.2