From 62f984423c147189382fb0c097c52a1a13d83f34 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 11 Apr 2022 16:32:29 +0200 Subject: [PATCH] extract code to detect files related to a test into a different function --- src/tools/compiletest/src/main.rs | 46 +++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index f4e6c2a2bb288..3d11ea21acf9f 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -665,6 +665,40 @@ fn stamp(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Path output_base_dir(config, testpaths, revision).join("stamp") } +fn files_related_to_test( + config: &Config, + testpaths: &TestPaths, + props: &EarlyProps, + revision: Option<&str>, +) -> Vec { + let mut related = vec![]; + + if testpaths.file.is_dir() { + // run-make tests use their individual directory + for entry in WalkDir::new(&testpaths.file) { + let path = entry.unwrap().into_path(); + if path.is_file() { + related.push(path); + } + } + } else { + related.push(testpaths.file.clone()); + } + + for aux in &props.aux { + let path = testpaths.file.parent().unwrap().join("auxiliary").join(aux); + related.push(path); + } + + // UI test files. + for extension in UI_EXTENSIONS { + let path = expected_output_path(testpaths, revision, &config.compare_mode, extension); + related.push(path); + } + + related +} + fn is_up_to_date( config: &Config, testpaths: &TestPaths, @@ -686,20 +720,10 @@ fn is_up_to_date( // Check timestamps. let mut inputs = inputs.clone(); - // Use `add_dir` to account for run-make tests, which use their individual directory - inputs.add_dir(&testpaths.file); - - for aux in &props.aux { - let path = testpaths.file.parent().unwrap().join("auxiliary").join(aux); + for path in files_related_to_test(config, testpaths, props, revision) { inputs.add_path(&path); } - // UI test files. - for extension in UI_EXTENSIONS { - let path = &expected_output_path(testpaths, revision, &config.compare_mode, extension); - inputs.add_path(path); - } - inputs < Stamp::from_path(&stamp_name) }