Skip to content

Commit 5cf3e68

Browse files
author
chen ruixiang
committed
fix: Coverage flag with npm command line parameter
1 parent e5bb6db commit 5cf3e68

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +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=\"*\" c8 npm run test:coverage",
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 && 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",
7777
"test:parser": "node --enable-source-maps tests/parser",
7878
"test:compiler": "node --enable-source-maps --experimental-wasi-unstable-preview1 --no-warnings tests/compiler",
7979
"test:browser": "node --enable-source-maps tests/browser",

tests/compiler.js

Lines changed: 5 additions & 2 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);
@@ -78,7 +81,7 @@ if (args.help) {
7881
process.exit(0);
7982
}
8083

81-
const features = process.env.ASC_FEATURES ? process.env.ASC_FEATURES.split(",") : [];
84+
const features = args.coverage ? ["*"] : process.env.ASC_FEATURES ? process.env.ASC_FEATURES.split(",") : [];
8285
const featuresConfig = require("./features.json");
8386
const basedir = path.join(dirname, "compiler");
8487

@@ -501,7 +504,7 @@ function evaluateResult(failedTests, skippedTests) {
501504
}
502505

503506
// Run tests in parallel if requested
504-
if (args.parallel && coreCount > 2) {
507+
if (args.parallel && coreCount > 2 && !args.coverage) {
505508
if (cluster.isWorker) {
506509
process.on("message", msg => {
507510
if (msg.cmd != "run") throw Error("invalid command: " + JSON.stringify(msg));

0 commit comments

Comments
 (0)