Skip to content

Commit

Permalink
coverage: Give each coverage test mode a separate output directory
Browse files Browse the repository at this point in the history
When multiple test modes share the same test directory, this will allow them to
avoid interfering with each others' files and timestamps.
  • Loading branch information
Zalathar committed Nov 7, 2023
1 parent 211d4ce commit e585a99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,23 @@ 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 {
Pretty => ".pretty",
_ => "",
}
}

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! {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit e585a99

Please sign in to comment.