Consolidate test collection state in one place

This commit is contained in:
Zalathar 2024-10-18 11:32:49 +11:00
parent d9c4b8d475
commit 21a020881d

View File

@ -464,9 +464,7 @@ pub fn run_tests(config: Arc<Config>) {
// structure for each test (or each revision of a multi-revision test). // structure for each test (or each revision of a multi-revision test).
let mut tests = Vec::new(); let mut tests = Vec::new();
for c in configs { for c in configs {
let mut found_paths = HashSet::new(); tests.extend(collect_and_make_tests(c));
make_tests(c, &mut tests, &mut found_paths);
check_overlapping_tests(&found_paths);
} }
tests.sort_by(|a, b| a.desc.name.as_slice().cmp(&b.desc.name.as_slice())); tests.sort_by(|a, b| a.desc.name.as_slice().cmp(&b.desc.name.as_slice()));
@ -550,27 +548,26 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
/// This always inspects _all_ test files in the suite (e.g. all 17k+ ui tests), /// This always inspects _all_ test files in the suite (e.g. all 17k+ ui tests),
/// regardless of whether any filters/tests were specified on the command-line, /// regardless of whether any filters/tests were specified on the command-line,
/// because filtering is handled later by libtest. /// because filtering is handled later by libtest.
pub fn make_tests( pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
config: Arc<Config>,
tests: &mut Vec<test::TestDescAndFn>,
found_paths: &mut HashSet<PathBuf>,
) {
debug!("making tests from {:?}", config.src_base.display()); debug!("making tests from {:?}", config.src_base.display());
let inputs = common_inputs_stamp(&config); let inputs = common_inputs_stamp(&config);
let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| { let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| {
panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err) panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
}); });
let cache = HeadersCache::load(&config); let cache = HeadersCache::load(&config);
let mut tests = vec![];
let mut found_paths = HashSet::new();
let mut poisoned = false; let mut poisoned = false;
collect_tests_from_dir( collect_tests_from_dir(
config.clone(), config.clone(),
&cache, &cache,
&config.src_base, &config.src_base,
&PathBuf::new(), &PathBuf::new(),
&inputs, &inputs,
tests, &mut tests,
found_paths, &mut found_paths,
&modified_tests, &modified_tests,
&mut poisoned, &mut poisoned,
) )
@ -582,6 +579,10 @@ pub fn make_tests(
eprintln!(); eprintln!();
panic!("there are errors in tests"); panic!("there are errors in tests");
} }
check_overlapping_tests(&found_paths);
tests
} }
/// Returns a stamp constructed from input files common to all test cases. /// Returns a stamp constructed from input files common to all test cases.