Skip to content

fix(coverage): pass DENO_COVERAGE_DIR env var correctly #29363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ async fn run_subcommand(
// this is set in order to ensure spawned processes use the same
// coverage directory
env::set_var(
"DENO_UNSTABLE_COVERAGE_DIR",
"DENO_COVERAGE_DIR",
PathBuf::from(coverage_dir).canonicalize()?,
);
}
Expand Down
15 changes: 15 additions & 0 deletions tests/testdata/coverage/complex_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,18 @@ Deno.test("sub process with deno eval", () => {
throw new Error("Failed");
}
});

Deno.test("DENO_COVERAGE_DIR is set and passed down to child process", () => {
const coverageDir = Deno.env.get("DENO_COVERAGE_DIR");
if (coverageDir === undefined) {
throw new Error("DENO_COVERAGE_DIR is not set");
}
const code = "console.log(Deno.env.get('DENO_COVERAGE_DIR'))";
const { stdout } = new Deno.Command(Deno.execPath(), {
args: ["eval", code],
}).outputSync();
const output = new TextDecoder().decode(stdout);
if (output.trim() !== coverageDir) {
throw new Error("Failed");
}
});
Loading