From c667fc231dd789852ad583a1ea5d404488827c9a Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 21 Apr 2018 10:03:23 -0700 Subject: [PATCH] Add more profile override validation tests. --- tests/testsuite/profiles.rs | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index 9452c1417..c53354075 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -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)), + ); + } +} -- 2.30.2