@@ -2963,3 +2963,67 @@ fn use_checksum_cache_in_cargo_home() {
29632963"# ] ] )
29642964 . run ( ) ;
29652965}
2966+
2967+ #[ cargo_test( nightly, reason = "requires -Zchecksum-hash-algorithm" ) ]
2968+ fn incremental_build_script_execution_got_new_mtime_and_cargo_check ( ) {
2969+ // See https://github.com/rust-lang/cargo/issues/16104
2970+ let p = project ( )
2971+ . file ( "src/lib.rs" , "" )
2972+ . file ( "touch-me" , "" )
2973+ . file (
2974+ "build.rs" ,
2975+ r#"fn main() { println!("cargo::rerun-if-changed=touch-me") }"# ,
2976+ )
2977+ . build ( ) ;
2978+
2979+ p. cargo ( "check -Zchecksum-freshness" )
2980+ . masquerade_as_nightly_cargo ( & [ "checksum-freshness" ] )
2981+ . env ( "CARGO_INCREMENTAL" , "1" )
2982+ . with_stderr_data ( str![ [ r#"
2983+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2984+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2985+
2986+ "# ] ] )
2987+ . run ( ) ;
2988+
2989+ p. change_file ( "touch-me" , "oops" ) ;
2990+
2991+ // The first one is expected to rerun build script
2992+ p. cargo ( "check -Zchecksum-freshness -v" )
2993+ . masquerade_as_nightly_cargo ( & [ "checksum-freshness" ] )
2994+ . env ( "CARGO_INCREMENTAL" , "1" )
2995+ . with_stderr_data ( str![ [ r#"
2996+ [DIRTY] foo v0.0.1 ([ROOT]/foo): the file `touch-me` has changed ([TIME_DIFF_AFTER_LAST_BUILD])
2997+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2998+ [RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
2999+ [RUNNING] `rustc --crate-name foo [..]`
3000+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3001+
3002+ "# ] ] )
3003+ . run ( ) ;
3004+
3005+ // subsequent cargo check gets stuck...
3006+ p. cargo ( "check -Zchecksum-freshness -v" )
3007+ . masquerade_as_nightly_cargo ( & [ "checksum-freshness" ] )
3008+ . env ( "CARGO_INCREMENTAL" , "1" )
3009+ . with_stderr_data ( str![ [ r#"
3010+ [DIRTY] foo v0.0.1 ([ROOT]/foo): the dependency build_script_build was rebuilt ([TIME_DIFF_AFTER_LAST_BUILD])
3011+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
3012+ [RUNNING] `rustc --crate-name foo [..]`
3013+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3014+
3015+ "# ] ] )
3016+ . run ( ) ;
3017+
3018+ p. cargo ( "check -Zchecksum-freshness -v" )
3019+ . masquerade_as_nightly_cargo ( & [ "checksum-freshness" ] )
3020+ . env ( "CARGO_INCREMENTAL" , "1" )
3021+ . with_stderr_data ( str![ [ r#"
3022+ [DIRTY] foo v0.0.1 ([ROOT]/foo): the dependency build_script_build was rebuilt ([TIME_DIFF_AFTER_LAST_BUILD])
3023+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
3024+ [RUNNING] `rustc --crate-name foo [..]`
3025+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3026+
3027+ "# ] ] )
3028+ . run ( ) ;
3029+ }
0 commit comments