@@ -37,7 +37,6 @@ use target::*;
37
37
use package_source:: PkgSrc ;
38
38
use source_control:: { CheckedOutSources , DirToUse , safe_git_clone} ;
39
39
use exit_codes:: { BAD_FLAG_CODE , COPY_FAILED_CODE } ;
40
- use util:: datestamp;
41
40
42
41
fn fake_ctxt ( sysroot : Path , workspace : & Path ) -> BuildContext {
43
42
let context = workcache:: Context :: new (
@@ -507,6 +506,7 @@ fn output_file_name(workspace: &Path, short_name: ~str) -> Path {
507
506
os:: EXE_SUFFIX ) )
508
507
}
509
508
509
+ #[ cfg( target_os = "linux" ) ]
510
510
fn touch_source_file ( workspace : & Path , pkgid : & PkgId ) {
511
511
use conditions:: bad_path:: cond;
512
512
let pkg_src_dir = workspace. join_many ( [ ~"src", pkgid. to_str ( ) ] ) ;
@@ -515,7 +515,28 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
515
515
if p. extension_str ( ) == Some ( "rs" ) {
516
516
// should be able to do this w/o a process
517
517
// FIXME (#9639): This needs to handle non-utf8 paths
518
- if run:: process_output ( "touch" , [ p. as_str ( ) . unwrap ( ) . to_owned ( ) ] ) . status != 0 {
518
+ // n.b. Bumps time up by 2 seconds to get around granularity issues
519
+ if run:: process_output ( "touch" , [ ~"--date",
520
+ ~"+2 seconds",
521
+ p. as_str ( ) . unwrap ( ) . to_owned ( ) ] ) . status != 0 {
522
+ let _ = cond. raise ( ( pkg_src_dir. clone ( ) , ~"Bad path") ) ;
523
+ }
524
+ }
525
+ }
526
+ }
527
+
528
+ #[ cfg( not( target_os = "linux" ) ) ]
529
+ fn touch_source_file ( workspace : & Path , pkgid : & PkgId ) {
530
+ use conditions:: bad_path:: cond;
531
+ let pkg_src_dir = workspace. join_many ( [ ~"src", pkgid. to_str ( ) ] ) ;
532
+ let contents = os:: list_dir_path ( & pkg_src_dir) ;
533
+ for p in contents. iter ( ) {
534
+ if p. extension_str ( ) == Some ( "rs" ) {
535
+ // should be able to do this w/o a process
536
+ // FIXME (#9639): This needs to handle non-utf8 paths
537
+ // n.b. Bumps time up by 2 seconds to get around granularity issues
538
+ if run:: process_output ( "touch" , [ ~"-A02 ",
539
+ p. as_str ( ) . unwrap ( ) . to_owned ( ) ] ) . status != 0 {
519
540
let _ = cond. raise ( ( pkg_src_dir. clone ( ) , ~"Bad path") ) ;
520
541
}
521
542
}
@@ -1033,12 +1054,17 @@ fn no_rebuilding() {
1033
1054
let workspace = create_local_package(&p_id);
1034
1055
let workspace = workspace.path();
1035
1056
command_line_test([~" build", ~" foo"], workspace);
1036
- let date = datestamp(&built_library_in_workspace(&p_id,
1037
- workspace).expect(" no_rebuilding"));
1057
+ let foo_lib = lib_output_file_name(workspace, " foo");
1058
+ // Now make `foo` read-only so that subsequent rebuilds of it will fail
1059
+ assert!(chmod_read_only(&foo_lib));
1060
+
1038
1061
command_line_test([~" build", ~" foo"], workspace);
1039
- let newdate = datestamp(&built_library_in_workspace(&p_id,
1040
- workspace).expect(" no_rebuilding ( 2 ) "));
1041
- assert_eq!(date, newdate);
1062
+
1063
+ match command_line_test_partial([~" build", ~" foo"], workspace) {
1064
+ Success(*) => (), // ok
1065
+ Fail(status) if status == 65 => fail2!(" no_rebuilding failed: it tried to rebuild bar"),
1066
+ Fail(_) => fail2!(" no_rebuilding failed for some other reason")
1067
+ }
1042
1068
}
1043
1069
1044
1070
#[test]
@@ -1049,55 +1075,55 @@ fn no_rebuilding_dep() {
1049
1075
let workspace = workspace.path();
1050
1076
command_line_test([~" build", ~" foo"], workspace);
1051
1077
let bar_lib = lib_output_file_name(workspace, " bar");
1052
- let bar_date_1 = datestamp(&bar_lib);
1053
-
1054
1078
frob_source_file(workspace, &p_id, " main. rs");
1055
-
1056
1079
// Now make `bar` read-only so that subsequent rebuilds of it will fail
1057
1080
assert!(chmod_read_only(&bar_lib));
1058
-
1059
1081
match command_line_test_partial([~" build", ~" foo"], workspace) {
1060
1082
Success(*) => (), // ok
1061
1083
Fail(status) if status == 65 => fail2!(" no_rebuilding_dep failed: it tried to rebuild bar"),
1062
1084
Fail(_) => fail2!(" no_rebuilding_dep failed for some other reason")
1063
1085
}
1064
-
1065
- let bar_date_2 = datestamp(&bar_lib);
1066
- assert_eq!(bar_date_1, bar_date_2);
1067
1086
}
1068
1087
1069
1088
#[test]
1070
- #[ignore]
1071
1089
fn do_rebuild_dep_dates_change() {
1072
1090
let p_id = PkgId::new(" foo");
1073
1091
let dep_id = PkgId::new(" bar");
1074
1092
let workspace = create_local_package_with_dep(&p_id, &dep_id);
1075
1093
let workspace = workspace.path();
1076
1094
command_line_test([~" build", ~" foo"], workspace);
1077
1095
let bar_lib_name = lib_output_file_name(workspace, " bar");
1078
- let bar_date = datestamp(&bar_lib_name);
1079
- debug2!(" Datestamp on { } is { : ?} ", bar_lib_name.display(), bar_date);
1080
1096
touch_source_file(workspace, &dep_id);
1081
- command_line_test([~" build", ~" foo"], workspace);
1082
- let new_bar_date = datestamp(&bar_lib_name);
1083
- debug2!(" Datestamp on { } is { : ?} ", bar_lib_name.display(), new_bar_date);
1084
- assert!(new_bar_date > bar_date);
1097
+
1098
+ // Now make `bar` read-only so that subsequent rebuilds of it will fail
1099
+ assert!(chmod_read_only(&bar_lib_name));
1100
+
1101
+ match command_line_test_partial([~" build", ~" foo"], workspace) {
1102
+ Success(*) => fail2!(" do_rebuild_dep_dates_change failed: it didn' t rebuild bar"),
1103
+ Fail(status) if status == 65 => (), // ok
1104
+ Fail(_) => fail2!(" do_rebuild_dep_dates_change failed for some other reason")
1105
+ }
1085
1106
}
1086
1107
1087
1108
#[test]
1088
- #[ignore]
1089
1109
fn do_rebuild_dep_only_contents_change() {
1090
1110
let p_id = PkgId::new(" foo");
1091
1111
let dep_id = PkgId::new(" bar");
1092
1112
let workspace = create_local_package_with_dep(&p_id, &dep_id);
1093
1113
let workspace = workspace.path();
1094
1114
command_line_test([~" build", ~" foo"], workspace);
1095
- let bar_date = datestamp(&lib_output_file_name(workspace, " bar"));
1096
1115
frob_source_file(workspace, &dep_id, " lib. rs");
1116
+ let bar_lib_name = lib_output_file_name(workspace, " bar");
1117
+
1118
+ // Now make `bar` read-only so that subsequent rebuilds of it will fail
1119
+ assert!(chmod_read_only(&bar_lib_name));
1120
+
1097
1121
// should adjust the datestamp
1098
- command_line_test([~" build", ~" foo"], workspace);
1099
- let new_bar_date = datestamp(&lib_output_file_name(workspace, " bar"));
1100
- assert!(new_bar_date > bar_date);
1122
+ match command_line_test_partial([~" build", ~" foo"], workspace) {
1123
+ Success(*) => fail2!(" do_rebuild_dep_only_contents_change failed: it didn' t rebuild bar"),
1124
+ Fail(status) if status == 65 => (), // ok
1125
+ Fail(_) => fail2!(" do_rebuild_dep_only_contents_change failed for some other reason")
1126
+ }
1101
1127
}
1102
1128
1103
1129
#[test]
@@ -2003,7 +2029,7 @@ fn test_rustpkg_test_output() {
2003
2029
}
2004
2030
2005
2031
#[test]
2006
- #[ignore(reason = " See issue # 9441 ")]
2032
+ #[ignore(reason = " Issue 9441 ")]
2007
2033
fn test_rebuild_when_needed() {
2008
2034
let foo_id = PkgId::new(" foo");
2009
2035
let foo_workspace = create_local_package(&foo_id);
0 commit comments