Use monocart for coverage reports, enable codecov (#58850)

This commit is contained in:
Jake Bailey
2024-07-17 14:55:45 -07:00
committed by GitHub
parent e7e813542a
commit ba46eca139
7 changed files with 316 additions and 18 deletions

View File

@@ -32,7 +32,7 @@ export const coverageDir = "coverage";
* @param {boolean} [options.watching]
*/
export async function runConsoleTests(runJs, defaultReporter, runInParallel, options = {}) {
const testTimeout = cmdLineOptions.timeout;
let testTimeout = cmdLineOptions.timeout;
const tests = cmdLineOptions.tests;
const skipSysTests = cmdLineOptions.skipSysTests;
const inspect = cmdLineOptions.break || cmdLineOptions.inspect;
@@ -45,6 +45,12 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
const shards = +cmdLineOptions.shards || undefined;
const shardId = +cmdLineOptions.shardId || undefined;
const coverage = cmdLineOptions.coverage;
if (coverage && testTimeout) {
testTimeout *= 2;
console.log(chalk.yellowBright(`[coverage] doubling test timeout to ${testTimeout}ms...`));
}
if (!cmdLineOptions.dirty) {
if (options.watching) {
console.log(chalk.yellowBright(`[watch] cleaning test directories...`));
@@ -142,9 +148,14 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
process.env.NODE_V8_COVERAGE = path.resolve(coverageDir, "tmp");
}
await exec(process.execPath, args, { token: options.token });
if (coverage) {
await exec("npm", ["--prefer-offline", "exec", "--", "c8", "report"], { token: options.token });
try {
await exec(process.execPath, args, { token: options.token });
}
finally {
// Calculate coverage even if tests failed.
if (coverage) {
await exec("npm", ["--prefer-offline", "exec", "--", "c8", "report", "--experimental-monocart"], { token: options.token });
}
}
}
catch (e) {