Skip to content

Commit 9723a49

Browse files
committed
Auto merge of #56680 - vakaras:issue56280, r=nagisa
Use compiletest timestamp to check if the tests should be rerun. An attempt to fix #56280 by checking if timestamps of compile test files are older than the timestamp of the stamp file. ?r nagisa
2 parents fa922ab + d966e57 commit 9723a49

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ dependencies = [
431431
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
432432
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
433433
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
434+
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
434435
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
435436
]
436437

src/tools/compiletest/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ serde_json = "1.0"
1515
serde_derive = "1.0"
1616
rustfix = "0.4.1"
1717
lazy_static = "1.0"
18+
walkdir = "2"
1819

1920
[target.'cfg(unix)'.dependencies]
2021
libc = "0.2"

src/tools/compiletest/src/main.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern crate serde_derive;
2828
extern crate serde_json;
2929
extern crate test;
3030
extern crate rustfix;
31+
extern crate walkdir;
3132

3233
use common::CompareMode;
3334
use common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
@@ -43,6 +44,7 @@ use std::path::{Path, PathBuf};
4344
use std::process::Command;
4445
use test::ColorConfig;
4546
use util::logv;
47+
use walkdir::WalkDir;
4648

4749
use self::header::{EarlyProps, Ignore};
4850

@@ -682,6 +684,15 @@ fn stamp(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Path
682684
output_base_dir(config, testpaths, revision).join("stamp")
683685
}
684686

687+
/// Return an iterator over timestamps of files in the directory at `path`.
688+
fn collect_timestamps(path: &PathBuf) -> impl Iterator<Item=FileTime> {
689+
WalkDir::new(path)
690+
.into_iter()
691+
.map(|entry| entry.unwrap())
692+
.filter(|entry| entry.metadata().unwrap().is_file())
693+
.map(|entry| mtime(entry.path()))
694+
}
695+
685696
fn up_to_date(
686697
config: &Config,
687698
testpaths: &TestPaths,
@@ -725,16 +736,7 @@ fn up_to_date(
725736
for pretty_printer_file in &pretty_printer_files {
726737
inputs.push(mtime(&rust_src_dir.join(pretty_printer_file)));
727738
}
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-
}
739+
inputs.extend(collect_timestamps(&config.run_lib_path));
738740
if let Some(ref rustdoc_path) = config.rustdoc_path {
739741
inputs.push(mtime(&rustdoc_path));
740742
inputs.push(mtime(&rust_src_dir.join("src/etc/htmldocck.py")));
@@ -746,6 +748,9 @@ fn up_to_date(
746748
inputs.push(mtime(path));
747749
}
748750

751+
// Compiletest itself.
752+
inputs.extend(collect_timestamps(&rust_src_dir.join("src/tools/compiletest/")));
753+
749754
inputs.iter().any(|input| *input > stamp)
750755
}
751756

0 commit comments

Comments
 (0)