Skip to content

Commit

Permalink
Added failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadravid committed Mar 8, 2019
1 parent 37a4555 commit 6bf75c4
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/testsuite/rustflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,3 +1359,68 @@ fn env_rustflags_misspelled_build_script() {
.with_stderr_contains("[WARNING] Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?")
.run();
}

#[test]
fn env_rustflags_with_crt_static_sets_env_var() {
// The CARGO_CFG_TARGET_FEATURE should be set when passing this flag.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
build = "build.rs"
"#,
)
.file("src/lib.rs", "")
.file(
"build.rs",
r#"
fn main() {
assert!(std::env::var("CARGO_CFG_TARGET_FEATURE").unwrap().contains("crt-static"));
}
"#,
)
.build();

p.cargo("build")
.env("RUSTFLAGS", "-Ctarget-feature=+crt-static")
.run();
}

#[test]
fn config_rustflags_with_crt_static_sets_env_var() {
// The CARGO_CFG_TARGET_FEATURE should be set when passing this flag.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
build = "build.rs"
"#,
)
.file(
".cargo/config",
r#"
[build]
rustflags = ["-Ctarget-feature=+crt-static"]
"#,
)
.file("src/lib.rs", "")
.file(
"build.rs",
r#"
fn main() {
assert!(std::env::var("CARGO_CFG_TARGET_FEATURE").unwrap().contains("crt-static"));
}
"#,
)
.build();

p.cargo("build")
.env("RUSTFLAGS", "")
.run();
}

0 comments on commit 6bf75c4

Please sign in to comment.