Skip to content

Commit

Permalink
testcase(Problem)
Browse files Browse the repository at this point in the history
  • Loading branch information
heisen-li committed Apr 7, 2024
1 parent 6b27055 commit ee634fb
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5527,3 +5527,50 @@ fn test_old_syntax_with_old_msrv() {
p.cargo("build -v").run();
p.cargo("run -v").with_stdout("foo\n").run();
}

#[cargo_test]
fn build_script_rerun_when_target_rustflags_change() {
let target = rustc_host();
let p = project()
.file(
"src/lib.rs",
"#![cfg_attr(enable, feature(error_generic_member_access))]
",
)
.file(
"build.rs",
r#"
use std::env;
fn main() {
if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
if !rustflags.is_empty() {
println!("cargo::rustc-cfg=enable")
}
}
}
"#,
)
.build();

p.cargo("build --target")
.arg(&target)
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([..])
[FINISHED] [..]
",
)
.run();

p.cargo("build --target")
.arg(&target)
.env("RUSTFLAGS", "-C opt-level=3")
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([..])
[FINISHED] [..]
",
)
.run();
}

0 comments on commit ee634fb

Please sign in to comment.