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