Add more profile override validation tests.
authorEric Huss <eric@huss.org>
Sat, 21 Apr 2018 17:03:23 +0000 (10:03 -0700)
committerEric Huss <eric@huss.org>
Fri, 27 Apr 2018 20:42:30 +0000 (13:42 -0700)
tests/testsuite/profiles.rs

index 9452c1417890244e6feb0a2c0a4a4afb7d36d22a..c53354075aa6d578c03aa59643c1b1d9ca8d9ce6 100644 (file)
@@ -551,3 +551,55 @@ Caused by:
         ),
     );
 }
+
+#[test]
+fn profile_override_bad_settings() {
+    let bad_values = [
+        (
+            "panic = \"abort\"",
+            "`panic` may not be specified in a profile override.",
+        ),
+        (
+            "lto = true",
+            "`lto` may not be specified in a profile override.",
+        ),
+        (
+            "rpath = true",
+            "`rpath` may not be specified in a profile override.",
+        ),
+        ("overrides = {}", "Profile overrides cannot be nested."),
+    ];
+    for &(ref snippet, ref expected) in bad_values.iter() {
+        let p = project("foo")
+            .file(
+                "Cargo.toml",
+                &format!(
+                    r#"
+                cargo-features = ["profile-overrides"]
+
+                [package]
+                name = "foo"
+                version = "0.0.1"
+
+                [dependencies]
+                bar = {{path = "bar"}}
+
+                [profile.dev.overrides.bar]
+                {}
+            "#,
+                    snippet
+                ),
+            )
+            .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(format!("Caused by:\n  {}", expected)),
+        );
+    }
+}