Skip to content

Commit 1607563

Browse files
committed
Add test for cargo:rustc-link-arg-bin=foo=--bar
1 parent 5382aa6 commit 1607563

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/testsuite/build_script_extra_link_arg.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,49 @@ fn build_script_extra_link_arg_bin() {
2626
.run();
2727
}
2828

29+
#[cargo_test]
30+
fn build_script_extra_link_arg_bin_single() {
31+
let p = project()
32+
.file(
33+
"Cargo.toml",
34+
r#"
35+
[package]
36+
37+
name = "foobar"
38+
version = "0.5.0"
39+
authors = ["[email protected]"]
40+
41+
[[bin]]
42+
name = "foo"
43+
[[bin]]
44+
name = "bar"
45+
"#,
46+
)
47+
.file("src/main.rs", "fn main() {}")
48+
.file(
49+
"build.rs",
50+
r#"
51+
fn main() {
52+
println!("cargo:rustc-link-arg-bins=--bogus-flag-all");
53+
println!("cargo:rustc-link-arg-bin=foo=--bogus-flag-foo");
54+
println!("cargo:rustc-link-arg-bin=bar=--bogus-flag-bar");
55+
}
56+
"#,
57+
)
58+
.build();
59+
60+
p.cargo("build -Zextra-link-arg -v")
61+
.masquerade_as_nightly_cargo()
62+
.without_status()
63+
.with_stderr_contains(
64+
"[RUNNING] `rustc --crate-name foo [..]-C link-arg=--bogus-flag-all -C link-arg=--bogus-flag-foo[..]",
65+
)
66+
.with_stderr_contains(
67+
"[RUNNING] `rustc --crate-name bar [..]-C link-arg=--bogus-flag-all -C link-arg=--bogus-flag-bar[..]",
68+
)
69+
.run();
70+
}
71+
2972
#[cargo_test]
3073
fn build_script_extra_link_arg() {
3174
let p = project()

0 commit comments

Comments
 (0)