compiletest

Function check_for_overlapping_test_paths

source
pub(crate) fn check_for_overlapping_test_paths(
    found_path_stems: &HashSet<PathBuf>,
)
Expand description

Checks that test discovery didn’t find any tests whose name stem is a prefix of some other tests’s name.

For example, suppose the test suite contains these two test files:

  • tests/rustdoc/primitive.rs
  • tests/rustdoc/primitive/no_std.rs

The test runner might put the output from those tests in these directories:

  • $build/test/rustdoc/primitive/
  • $build/test/rustdoc/primitive/no_std/

Because one output path is a subdirectory of the other, the two tests might interfere with each other in unwanted ways, especially if the test runner decides to delete test output directories to clean them between runs. To avoid problems, we forbid test names from overlapping in this way.

See https://github.com/rust-lang/rust/pull/109509 for more context.