Skip to content

Commit 6e0a99d

Browse files
author
chen ruixiang
committed
fix: Coverage flag with npm command line parameter
1 parent 537fc23 commit 6e0a99d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@
7171
"lint": "eslint --max-warnings 0 --ext js . && eslint --max-warnings 0 --ext ts .",
7272
"build": "node scripts/build",
7373
"watch": "node scripts/build --watch",
74-
"coverage": "ASC_FEATURES=\"*\" ASC_COVERAGERUN=1 c8 npm run test",
74+
"coverage": "c8 npm run test:coverage",
7575
"test": "npm run test:parser && npm run test:compiler -- --parallel && npm run test:browser && npm run test:asconfig && npm run test:transform",
76+
"test:coverage": "npm run test:parser && npm run test:compiler -- --coverage && npm run test:browser && npm run test:asconfig && npm run test:transform",
7677
"test:parser": "node --enable-source-maps tests/parser",
7778
"test:compiler": "node --enable-source-maps --experimental-wasi-unstable-preview1 --no-warnings tests/compiler",
7879
"test:browser": "node --enable-source-maps tests/browser",

tests/compiler.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ const config = {
5858
"description": "Prints this message and exits.",
5959
"type": "b",
6060
"alias": "h"
61+
},
62+
"coverage": {
63+
"description": "Enable this option during generating test coverage report"
6164
}
6265
};
6366
const opts = optionsUtil.parse(process.argv.slice(2), config);
@@ -79,8 +82,9 @@ if (args.help) {
7982
}
8083

8184
const features = process.env.ASC_FEATURES ? process.env.ASC_FEATURES.split(",") : [];
82-
//Disable parallel run during test coverage report generation
83-
const coverageRun = process.env.ASC_FEATURES ? true : false;
85+
if (args.coverage) {
86+
features = ["*"]; // open all features during testing coverage run
87+
}
8488
const featuresConfig = require("./features.json");
8589
const basedir = path.join(dirname, "compiler");
8690

@@ -503,7 +507,7 @@ function evaluateResult(failedTests, skippedTests) {
503507
}
504508

505509
// Run tests in parallel if requested
506-
if (args.parallel && coreCount > 2 && !coverageRun) {
510+
if (args.parallel && coreCount > 2 && !args.coverage) {
507511
if (cluster.isWorker) {
508512
process.on("message", msg => {
509513
if (msg.cmd != "run") throw Error("invalid command: " + JSON.stringify(msg));

0 commit comments

Comments
 (0)