coverage: Give each coverage test mode a separate output directory

When multiple test modes share the same test directory, this will allow them to
avoid interfering with each others' files and timestamps.
This commit is contained in:
Zalathar 2023-11-02 13:07:57 +11:00
parent 211d4cee8e
commit e585a99230
2 changed files with 12 additions and 2 deletions

View File

@ -78,7 +78,7 @@ impl Default for Mode {
}
impl Mode {
pub fn disambiguator(self) -> &'static str {
pub fn aux_dir_disambiguator(self) -> &'static str {
// Pretty-printing tests could run concurrently, and if they do,
// they need to keep their output segregated.
match self {
@ -86,6 +86,15 @@ impl Mode {
_ => "",
}
}
pub fn output_dir_disambiguator(self) -> &'static str {
// Coverage tests use the same test files for multiple test modes,
// so each mode should have a separate output directory.
match self {
CoverageMap | RunCoverage => self.to_str(),
_ => "",
}
}
}
string_enum! {
@ -699,6 +708,7 @@ pub fn output_testname_unique(
let mode = config.compare_mode.as_ref().map_or("", |m| m.to_str());
let debugger = config.debugger.as_ref().map_or("", |m| m.to_str());
PathBuf::from(&testpaths.file.file_stem().unwrap())
.with_extra_extension(config.mode.output_dir_disambiguator())
.with_extra_extension(revision.unwrap_or(""))
.with_extra_extension(mode)
.with_extra_extension(debugger)

View File

@ -2720,7 +2720,7 @@ impl<'test> TestCx<'test> {
fn aux_output_dir_name(&self) -> PathBuf {
self.output_base_dir()
.join("auxiliary")
.with_extra_extension(self.config.mode.disambiguator())
.with_extra_extension(self.config.mode.aux_dir_disambiguator())
}
/// Generates a unique name for the test, such as `testname.revision.mode`.