Skip to content

Commit 91bfbb9

Browse files
committed
Use compiletest timestamp to check if the tests should be rerun.
1 parent 7fb479c commit 91bfbb9

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/tools/compiletest/src/main.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,20 @@ fn stamp(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Path
682682
output_base_dir(config, testpaths, revision).join("stamp")
683683
}
684684

685+
/// Walk the directory at `path` and collect timestamps of all files into `inputs`.
686+
fn collect_timestamps(path: &PathBuf, inputs: &mut Vec<FileTime>) {
687+
let mut entries = path.read_dir().unwrap().collect::<Vec<_>>();
688+
while let Some(entry) = entries.pop() {
689+
let entry = entry.unwrap();
690+
let path = entry.path();
691+
if entry.metadata().unwrap().is_file() {
692+
inputs.push(mtime(&path));
693+
} else {
694+
entries.extend(path.read_dir().unwrap());
695+
}
696+
}
697+
}
698+
685699
fn up_to_date(
686700
config: &Config,
687701
testpaths: &TestPaths,
@@ -725,16 +739,7 @@ fn up_to_date(
725739
for pretty_printer_file in &pretty_printer_files {
726740
inputs.push(mtime(&rust_src_dir.join(pretty_printer_file)));
727741
}
728-
let mut entries = config.run_lib_path.read_dir().unwrap().collect::<Vec<_>>();
729-
while let Some(entry) = entries.pop() {
730-
let entry = entry.unwrap();
731-
let path = entry.path();
732-
if entry.metadata().unwrap().is_file() {
733-
inputs.push(mtime(&path));
734-
} else {
735-
entries.extend(path.read_dir().unwrap());
736-
}
737-
}
742+
collect_timestamps(&config.run_lib_path, &mut inputs);
738743
if let Some(ref rustdoc_path) = config.rustdoc_path {
739744
inputs.push(mtime(&rustdoc_path));
740745
inputs.push(mtime(&rust_src_dir.join("src/etc/htmldocck.py")));
@@ -746,6 +751,9 @@ fn up_to_date(
746751
inputs.push(mtime(path));
747752
}
748753

754+
// Compiletest itself.
755+
collect_timestamps(&rust_src_dir.join("src/tools/compiletest/"), &mut inputs);
756+
749757
inputs.iter().any(|input| *input > stamp)
750758
}
751759

0 commit comments

Comments
 (0)