Skip to content

Commit 4c5efea

Browse files
committed
Auto merge of rust-lang#96517 - ferrocene:pa-files-related-to-test, r=Mark-Simulacrum
[compiletest] Extract code to detect files related to a test into a different function In the code that checks whether a test needs to be re-executed, compiletest checks the modification date of all the files related to the test. I need the list of files related to the test for other purposes inside compiletest, and while I could copy/paste the code `is_up_to_date` runs, that would produce incomplete results if more related files are added in the future. This PR extracts the code to detect related files into a separate function, allowing the rest of compiletest to access the same data. r? `@Mark-Simulacrum`
2 parents 4dd8b42 + 62f9844 commit 4c5efea

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

src/tools/compiletest/src/main.rs

+35-11
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,40 @@ fn stamp(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Path
665665
output_base_dir(config, testpaths, revision).join("stamp")
666666
}
667667

668+
fn files_related_to_test(
669+
config: &Config,
670+
testpaths: &TestPaths,
671+
props: &EarlyProps,
672+
revision: Option<&str>,
673+
) -> Vec<PathBuf> {
674+
let mut related = vec![];
675+
676+
if testpaths.file.is_dir() {
677+
// run-make tests use their individual directory
678+
for entry in WalkDir::new(&testpaths.file) {
679+
let path = entry.unwrap().into_path();
680+
if path.is_file() {
681+
related.push(path);
682+
}
683+
}
684+
} else {
685+
related.push(testpaths.file.clone());
686+
}
687+
688+
for aux in &props.aux {
689+
let path = testpaths.file.parent().unwrap().join("auxiliary").join(aux);
690+
related.push(path);
691+
}
692+
693+
// UI test files.
694+
for extension in UI_EXTENSIONS {
695+
let path = expected_output_path(testpaths, revision, &config.compare_mode, extension);
696+
related.push(path);
697+
}
698+
699+
related
700+
}
701+
668702
fn is_up_to_date(
669703
config: &Config,
670704
testpaths: &TestPaths,
@@ -686,20 +720,10 @@ fn is_up_to_date(
686720

687721
// Check timestamps.
688722
let mut inputs = inputs.clone();
689-
// Use `add_dir` to account for run-make tests, which use their individual directory
690-
inputs.add_dir(&testpaths.file);
691-
692-
for aux in &props.aux {
693-
let path = testpaths.file.parent().unwrap().join("auxiliary").join(aux);
723+
for path in files_related_to_test(config, testpaths, props, revision) {
694724
inputs.add_path(&path);
695725
}
696726

697-
// UI test files.
698-
for extension in UI_EXTENSIONS {
699-
let path = &expected_output_path(testpaths, revision, &config.compare_mode, extension);
700-
inputs.add_path(path);
701-
}
702-
703727
inputs < Stamp::from_path(&stamp_name)
704728
}
705729

0 commit comments

Comments
 (0)