Skip to content

Commit a43a4af

Browse files
Fix coverage-gathering for the reference implementation
This has been broken for a while. By switching from nyc/istanbul to c8 and doing some browserify tricks, it now works.
1 parent 9beefc2 commit a43a4af

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
web-platform-tests/
22
coverage/
33
generated/
4+
bundle.js

reference-implementation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ package-lock.json
55
.nyc_output/
66
coverage/
77
generated/
8+
bundle.js

reference-implementation/package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,23 @@
22
"private": true,
33
"description": "Reference implementation and tests for the WHATWG Streams Standard",
44
"scripts": {
5-
"pretest": "node compile-idl.js",
5+
"pretest": "node compile-idl.js && browserify lib/index.js -d -o bundle.js",
66
"test": "npm run lint && npm run wpt",
77
"wpt": "npm run pretest && node --expose_gc run-web-platform-tests.js",
88
"sync-wpt": "git submodule update --init",
99
"lint": "eslint .",
10-
"coverage": "nyc --reporter=lcov npm test && opener coverage/lcov-report/index.html"
10+
"coverage": "c8 --reporter=lcov -- npm run wpt && opener coverage/lcov-report/index.html"
1111
},
1212
"author": "Domenic Denicola <[email protected]> (https://domenic.me/)",
1313
"license": "(CC0-1.0 OR MIT)",
1414
"devDependencies": {
1515
"browserify": "^16.5.1",
16+
"c8": "^7.7.2",
1617
"debug": "^4.1.1",
1718
"eslint": "^6.8.0",
1819
"minimatch": "^3.0.4",
19-
"nyc": "^15.0.1",
2020
"opener": "^1.5.1",
2121
"webidl2js": "^16.2.0",
2222
"wpt-runner": "^3.2.1"
23-
},
24-
"nyc": {
25-
"include": [
26-
"**/lib/**/*.js"
27-
]
2823
}
2924
}

reference-implementation/run-web-platform-tests.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
const path = require('path');
66
const fs = require('fs');
77
const { promisify } = require('util');
8-
const browserify = require('browserify');
98
const wptRunner = require('wpt-runner');
109
const minimatch = require('minimatch');
1110
const readFileAsync = promisify(fs.readFile);
@@ -28,7 +27,7 @@ main().catch(e => {
2827
});
2928

3029
async function main() {
31-
const entryPath = path.resolve(__dirname, 'lib/index.js');
30+
const bundlePath = path.resolve(__dirname, 'bundle.js');
3231
const wptPath = path.resolve(__dirname, 'web-platform-tests');
3332
const testsPath = path.resolve(wptPath, 'streams');
3433

@@ -40,7 +39,8 @@ async function main() {
4039
];
4140
const anyTestPattern = /\.any\.html$/;
4241

43-
const bundledJS = await bundle(entryPath);
42+
let bundledJS = await readFileAsync(bundlePath, { encoding: 'utf8' });
43+
bundledJS = `${bundledJS}\n//# sourceURL=file://${bundlePath}`;
4444

4545
const failures = await wptRunner(testsPath, {
4646
rootURL: 'streams/',
@@ -83,9 +83,3 @@ async function main() {
8383
}
8484
}
8585
}
86-
87-
async function bundle(entryPath) {
88-
const b = browserify([entryPath]);
89-
const buffer = await promisify(b.bundle.bind(b))();
90-
return buffer.toString();
91-
}

0 commit comments

Comments
 (0)