@@ -1257,6 +1257,49 @@ fn simple_deps_cleaner_does_not_rebuild() {
1257
1257
. run ( ) ;
1258
1258
}
1259
1259
1260
+ #[ cargo_test]
1261
+ fn update_dependency_mtime_does_not_rebuild ( ) {
1262
+ let p = project ( )
1263
+ . file (
1264
+ "Cargo.toml" ,
1265
+ r#"
1266
+ [package]
1267
+ name = "foo"
1268
+ version = "0.0.1"
1269
+
1270
+ [dependencies]
1271
+ bar = { path = "bar" }
1272
+ "# ,
1273
+ )
1274
+ . file ( "src/lib.rs" , "" )
1275
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.0.1" ) )
1276
+ . file ( "bar/src/lib.rs" , "" )
1277
+ . build ( ) ;
1278
+
1279
+ p. cargo ( "build -Z mtime-on-use" )
1280
+ . masquerade_as_nightly_cargo ( )
1281
+ . env ( "RUSTFLAGS" , "-C target-cpu=native" )
1282
+ . with_stderr (
1283
+ "\
1284
+ [COMPILING] bar v0.0.1 ([..])
1285
+ [COMPILING] foo v0.0.1 ([..])
1286
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" ,
1287
+ )
1288
+ . run ( ) ;
1289
+ // This does not make new files, but it does update the mtime of the dependency.
1290
+ p. cargo ( "build -p bar -Z mtime-on-use" )
1291
+ . masquerade_as_nightly_cargo ( )
1292
+ . env ( "RUSTFLAGS" , "-C target-cpu=native" )
1293
+ . with_stderr ( "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" )
1294
+ . run ( ) ;
1295
+ // This should not recompile!
1296
+ p. cargo ( "build -Z mtime-on-use" )
1297
+ . masquerade_as_nightly_cargo ( )
1298
+ . env ( "RUSTFLAGS" , "-C target-cpu=native" )
1299
+ . with_stderr ( "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" )
1300
+ . run ( ) ;
1301
+ }
1302
+
1260
1303
fn fingerprint_cleaner ( mut dir : PathBuf , timestamp : filetime:: FileTime ) {
1261
1304
// Cargo is experimenting with letting outside projects develop some
1262
1305
// limited forms of GC for target_dir. This is one of the forms.
0 commit comments