@@ -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 (
@@ -515,7 +514,8 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
515
514
if p. extension_str ( ) == Some ( "rs" ) {
516
515
// should be able to do this w/o a process
517
516
// FIXME (#9639): This needs to handle non-utf8 paths
518
- if run:: process_output ( "touch" , [ p. as_str ( ) . unwrap ( ) . to_owned ( ) ] ) . status != 0 {
517
+ // n.b. Bumps time up by 2 seconds to get around granularity issues
518
+ if run:: process_output ( "touch" , [ ~"-A ", ~"02 ", p. to_str ( ) ] ) . status != 0 {
519
519
let _ = cond. raise ( ( pkg_src_dir. clone ( ) , ~"Bad path") ) ;
520
520
}
521
521
}
@@ -1033,12 +1033,17 @@ fn no_rebuilding() {
1033
1033
let workspace = create_local_package(&p_id);
1034
1034
let workspace = workspace.path();
1035
1035
command_line_test([~" build", ~" foo"], workspace);
1036
- let date = datestamp(&built_library_in_workspace(&p_id,
1037
- workspace).expect(" no_rebuilding"));
1036
+ let foo_lib = lib_output_file_name(workspace, " foo");
1037
+ // Now make `foo` read-only so that subsequent rebuilds of it will fail
1038
+ assert!(chmod_read_only(&foo_lib));
1039
+
1038
1040
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);
1041
+
1042
+ match command_line_test_partial([~" build", ~" foo"], workspace) {
1043
+ Success(*) => (), // ok
1044
+ Fail(status) if status == 65 => fail2!(" no_rebuilding failed: it tried to rebuild bar"),
1045
+ Fail(_) => fail2!(" no_rebuilding failed for some other reason")
1046
+ }
1042
1047
}
1043
1048
1044
1049
#[test]
@@ -1049,55 +1054,55 @@ fn no_rebuilding_dep() {
1049
1054
let workspace = workspace.path();
1050
1055
command_line_test([~" build", ~" foo"], workspace);
1051
1056
let bar_lib = lib_output_file_name(workspace, " bar");
1052
- let bar_date_1 = datestamp(&bar_lib);
1053
-
1054
1057
frob_source_file(workspace, &p_id, " main. rs");
1055
-
1056
1058
// Now make `bar` read-only so that subsequent rebuilds of it will fail
1057
1059
assert!(chmod_read_only(&bar_lib));
1058
-
1059
1060
match command_line_test_partial([~" build", ~" foo"], workspace) {
1060
1061
Success(*) => (), // ok
1061
1062
Fail(status) if status == 65 => fail2!(" no_rebuilding_dep failed: it tried to rebuild bar"),
1062
1063
Fail(_) => fail2!(" no_rebuilding_dep failed for some other reason")
1063
1064
}
1064
-
1065
- let bar_date_2 = datestamp(&bar_lib);
1066
- assert_eq!(bar_date_1, bar_date_2);
1067
1065
}
1068
1066
1069
1067
#[test]
1070
- #[ignore]
1071
1068
fn do_rebuild_dep_dates_change() {
1072
1069
let p_id = PkgId::new(" foo");
1073
1070
let dep_id = PkgId::new(" bar");
1074
1071
let workspace = create_local_package_with_dep(&p_id, &dep_id);
1075
1072
let workspace = workspace.path();
1076
1073
command_line_test([~" build", ~" foo"], workspace);
1077
1074
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
1075
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);
1076
+
1077
+ // Now make `bar` read-only so that subsequent rebuilds of it will fail
1078
+ assert!(chmod_read_only(&bar_lib_name));
1079
+
1080
+ match command_line_test_partial([~" build", ~" foo"], workspace) {
1081
+ Success(*) => fail2!(" do_rebuild_dep_dates_change failed: it didn' t rebuild bar"),
1082
+ Fail(status) if status == 65 => (), // ok
1083
+ Fail(_) => fail2!(" do_rebuild_dep_dates_change failed for some other reason")
1084
+ }
1085
1085
}
1086
1086
1087
1087
#[test]
1088
- #[ignore]
1089
1088
fn do_rebuild_dep_only_contents_change() {
1090
1089
let p_id = PkgId::new(" foo");
1091
1090
let dep_id = PkgId::new(" bar");
1092
1091
let workspace = create_local_package_with_dep(&p_id, &dep_id);
1093
1092
let workspace = workspace.path();
1094
1093
command_line_test([~" build", ~" foo"], workspace);
1095
- let bar_date = datestamp(&lib_output_file_name(workspace, " bar"));
1096
1094
frob_source_file(workspace, &dep_id, " lib. rs");
1095
+ let bar_lib_name = lib_output_file_name(workspace, " bar");
1096
+
1097
+ // Now make `bar` read-only so that subsequent rebuilds of it will fail
1098
+ assert!(chmod_read_only(&bar_lib_name));
1099
+
1097
1100
// 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);
1101
+ match command_line_test_partial([~" build", ~" foo"], workspace) {
1102
+ Success(*) => fail2!(" do_rebuild_dep_only_contents_change failed: it didn' t rebuild bar"),
1103
+ Fail(status) if status == 65 => (), // ok
1104
+ Fail(_) => fail2!(" do_rebuild_dep_only_contents_change failed for some other reason")
1105
+ }
1101
1106
}
1102
1107
1103
1108
#[test]
@@ -2003,7 +2008,7 @@ fn test_rustpkg_test_output() {
2003
2008
}
2004
2009
2005
2010
#[test]
2006
- #[ignore(reason = " See issue # 9441 ")]
2011
+ #[ignore(reason = " Issue 9441 ")]
2007
2012
fn test_rebuild_when_needed() {
2008
2013
let foo_id = PkgId::new(" foo");
2009
2014
let foo_workspace = create_local_package(&foo_id);
0 commit comments