Add test for profile override on non-dev/release.
authorEric Huss <eric@huss.org>
Sat, 21 Apr 2018 16:50:55 +0000 (09:50 -0700)
committerEric Huss <eric@huss.org>
Fri, 27 Apr 2018 20:42:30 +0000 (13:42 -0700)
src/cargo/util/toml/mod.rs
tests/testsuite/profiles.rs

index acd4b0af20827e4ece56601a488960672c65f8ae..76f54de916f6f3a6e85de44149040272701a0e42 100644 (file)
@@ -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
                     );
                 }
index be5c6b615b2f97654f1eb6356d105df6eeacccac..9452c1417890244e6feb0a2c0a4a4afb7d36d22a 100644 (file)
@@ -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`.
+",
+        ),
+    );
 }