diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-08-12 15:21:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 15:21:17 -0400 |
commit | 8eed24cd3d9cea5179c65e43d23fbf6cf4d873ca (patch) | |
tree | 3047d60a9f8e972a601de011460dee151ad4c558 /cli/args/mod.rs | |
parent | ee2f4e745c33797ac9fd20571e77cef73ea585bf (diff) |
fix(coverage): ensure coverage is only collected in certain situations (#15467)
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index ecbc53db7..85e44aca2 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -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 { |