@@ -360,3 +360,68 @@ fn same_build_dir_cached_packages() {
360360 [COMPILING] a2 v0.0.1 ({dir}/a2)
361361" , dir = p. url( ) ) ) ) ;
362362}
363+
364+ #[ test]
365+ fn no_rebuild_if_build_artifacts_move_backwards_in_time ( ) {
366+ let p = project ( "backwards_in_time" )
367+ . file ( "Cargo.toml" , r#"
368+ [package]
369+ name = "backwards_in_time"
370+ version = "0.0.1"
371+ authors = []
372+
373+ [dependencies]
374+ a = { path = "a" }
375+ "# )
376+ . file ( "src/lib.rs" , "" )
377+ . file ( "a/Cargo.toml" , r#"
378+ [package]
379+ name = "a"
380+ version = "0.0.1"
381+ authors = []
382+ "# )
383+ . file ( "a/src/lib.rs" , "" ) ;
384+
385+ assert_that ( p. cargo_process ( "build" ) ,
386+ execs ( ) . with_status ( 0 ) ) ;
387+
388+ p. root ( ) . move_into_the_past ( ) ;
389+ p. root ( ) . join ( "target" ) . move_into_the_past ( ) ;
390+
391+ assert_that ( p. cargo ( "build" ) . env ( "RUST_LOG" , "" ) ,
392+ execs ( ) . with_status ( 0 ) . with_stdout ( "" ) . with_stderr ( "" ) ) ;
393+ }
394+
395+ #[ test]
396+ fn rebuild_if_build_artifacts_move_forward_in_time ( ) {
397+ let p = project ( "forwards_in_time" )
398+ . file ( "Cargo.toml" , r#"
399+ [package]
400+ name = "forwards_in_time"
401+ version = "0.0.1"
402+ authors = []
403+
404+ [dependencies]
405+ a = { path = "a" }
406+ "# )
407+ . file ( "src/lib.rs" , "" )
408+ . file ( "a/Cargo.toml" , r#"
409+ [package]
410+ name = "a"
411+ version = "0.0.1"
412+ authors = []
413+ "# )
414+ . file ( "a/src/lib.rs" , "" ) ;
415+
416+ assert_that ( p. cargo_process ( "build" ) ,
417+ execs ( ) . with_status ( 0 ) ) ;
418+
419+ p. root ( ) . move_into_the_future ( ) ;
420+ p. root ( ) . join ( "target" ) . move_into_the_future ( ) ;
421+
422+ assert_that ( p. cargo ( "build" ) . env ( "RUST_LOG" , "" ) ,
423+ execs ( ) . with_status ( 0 ) . with_stdout ( "" ) . with_stderr ( "\
424+ [COMPILING] a v0.0.1 ([..])
425+ [COMPILING] forwards_in_time v0.0.1 ([..])
426+ " ) ) ;
427+ }
0 commit comments