File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -5527,3 +5527,57 @@ fn test_old_syntax_with_old_msrv() {
55275527 p. cargo ( "build -v" ) . run ( ) ;
55285528 p. cargo ( "run -v" ) . with_stdout ( "foo\n " ) . run ( ) ;
55295529}
5530+
5531+ #[ cargo_test]
5532+ fn build_script_rerun_when_target_rustflags_change ( ) {
5533+ let target = rustc_host ( ) ;
5534+ let p = project ( )
5535+ . file (
5536+ "src/main.rs" ,
5537+ r#"
5538+ fn main() {
5539+ #[cfg(enable)]
5540+ println!("hello");
5541+ }
5542+ "# ,
5543+ )
5544+ . file (
5545+ "build.rs" ,
5546+ r#"
5547+ use std::env;
5548+
5549+ fn main() {
5550+ if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
5551+ if !rustflags.is_empty() {
5552+ println!("cargo::rustc-cfg=enable")
5553+ }
5554+ }
5555+ }
5556+ "# ,
5557+ )
5558+ . build ( ) ;
5559+
5560+ p. cargo ( "run --target" )
5561+ . arg ( & target)
5562+ . with_stderr (
5563+ "\
5564+ [COMPILING] foo v0.0.1 ([..])
5565+ [FINISHED] [..]
5566+ [RUNNING] [..]
5567+ " ,
5568+ )
5569+ . run ( ) ;
5570+
5571+ p. cargo ( "run --target" )
5572+ . arg ( & target)
5573+ . env ( "RUSTFLAGS" , "-C opt-level=3" )
5574+ . with_stderr (
5575+ "\
5576+ [COMPILING] foo v0.0.1 ([..])
5577+ [FINISHED] [..]
5578+ [RUNNING] [..]
5579+ " ,
5580+ )
5581+ . with_stdout ( "" )
5582+ . run ( ) ;
5583+ }
You can’t perform that action at this time.
0 commit comments