fix(coverage): ensure coverage is only collected in certain situations (#15467)

This commit is contained in:
David Sherret 2022-08-12 15:21:17 -04:00 committed by GitHub
parent ee2f4e745c
commit 8eed24cd3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 12 deletions

View file

@ -278,8 +278,25 @@ impl CliOptions {
self.flags.compat
}
pub fn coverage_dir(&self) -> Option<&String> {
self.flags.coverage_dir.as_ref()
pub fn coverage_dir(&self) -> Option<String> {
fn allow_coverage(sub_command: &DenoSubcommand) -> bool {
match sub_command {
DenoSubcommand::Test(_) => true,
DenoSubcommand::Run(flags) => !flags.is_stdin(),
_ => false,
}
}
if allow_coverage(self.sub_command()) {
self
.flags
.coverage_dir
.as_ref()
.map(ToOwned::to_owned)
.or_else(|| env::var("DENO_UNSTABLE_COVERAGE_DIR").ok())
} else {
None
}
}
pub fn enable_testing_features(&self) -> bool {