Skip to content

Commit 21a0208

Browse files
committed
Consolidate test collection state in one place
1 parent d9c4b8d commit 21a0208

File tree

1 file changed

+12
-11
lines changed
  • src/tools/compiletest/src

1 file changed

+12
-11
lines changed

src/tools/compiletest/src/lib.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,7 @@ pub fn run_tests(config: Arc<Config>) {
464464
// structure for each test (or each revision of a multi-revision test).
465465
let mut tests = Vec::new();
466466
for c in configs {
467-
let mut found_paths = HashSet::new();
468-
make_tests(c, &mut tests, &mut found_paths);
469-
check_overlapping_tests(&found_paths);
467+
tests.extend(collect_and_make_tests(c));
470468
}
471469

472470
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 {
550548
/// This always inspects _all_ test files in the suite (e.g. all 17k+ ui tests),
551549
/// regardless of whether any filters/tests were specified on the command-line,
552550
/// because filtering is handled later by libtest.
553-
pub fn make_tests(
554-
config: Arc<Config>,
555-
tests: &mut Vec<test::TestDescAndFn>,
556-
found_paths: &mut HashSet<PathBuf>,
557-
) {
551+
pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
558552
debug!("making tests from {:?}", config.src_base.display());
559553
let inputs = common_inputs_stamp(&config);
560554
let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| {
561555
panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
562556
});
563-
564557
let cache = HeadersCache::load(&config);
558+
559+
let mut tests = vec![];
560+
let mut found_paths = HashSet::new();
565561
let mut poisoned = false;
562+
566563
collect_tests_from_dir(
567564
config.clone(),
568565
&cache,
569566
&config.src_base,
570567
&PathBuf::new(),
571568
&inputs,
572-
tests,
573-
found_paths,
569+
&mut tests,
570+
&mut found_paths,
574571
&modified_tests,
575572
&mut poisoned,
576573
)
@@ -582,6 +579,10 @@ pub fn make_tests(
582579
eprintln!();
583580
panic!("there are errors in tests");
584581
}
582+
583+
check_overlapping_tests(&found_paths);
584+
585+
tests
585586
}
586587

587588
/// Returns a stamp constructed from input files common to all test cases.

0 commit comments

Comments
 (0)