Browse Source

Make it work on windows and use a hack to make the nv8 coverage actually output on ctrl-c.

master
Zed A. Shaw 2 months ago
parent
commit
79d59c9e17
  1. 22
      scripts/nv8cov.js
  2. 5
      services/api.js
  3. 3
      services/qserver.js
  4. 3
      services/tracker.js

22
scripts/nv8cov.js

@ -9,7 +9,9 @@ import url from "url";
import normalize from "normalize-path";
import path from "path";
const covdir = normalize(path.relative(process.cwd(), process.env.NODE_V8_COVERAGE));
assert(process.argv[2], "USAGE: nv8cov.js (coverage_dir)");
const covdir = normalize(process.argv[2]);
const covpattern = `${covdir}/**/*.json`;
console.log(`Searching ${covpattern} for coverage files...`);
@ -29,9 +31,20 @@ for(const fname of covfiles) {
// test removing just node modules
data.result = data.result.filter(x => {
if(x.url) {
const pathname = url.parse(x.url).pathname;
const excluded = excludes.filter(e => pathname.includes(e));
return excluded.length === 0 && fs.existsSync(pathname);
// we need to do surgery on the URL because node is bad at them
let pathname = url.parse(x.url).pathname;
// fix the URL and turn it into a file name
if(pathname.startsWith("/C:")) {
// why does url not parse windows paths right?
// remove the leading / so it's parsed correctly
x.url = pathname.slice(1);
} else {
x.url = pathname;
}
const excluded = excludes.filter(e => x.url.includes(e));
return excluded.length === 0 && fs.existsSync(x.url);
} else {
return false;
}
@ -44,6 +57,7 @@ for(const fname of covfiles) {
}
const coverageMap = libCoverage.createCoverageMap();
console.log("After filtering, found count is:", Object.entries(coverage).length);
for(const [fname, data] of Object.entries(coverage)) {
for(const entry of data.result) {

5
services/api.js

@ -204,3 +204,8 @@ io.on('connection', (socket) => {
http_server.listen(5001, "127.0.0.1", () => {
log.info('listening on *:5001');
});
// NOTE: this is about the stupidest thing ever, but you need
// this so that node actually writes the V8 coverage on ctrl-c
// see: https://github.com/nodejs/node/issues/35212
process.on('SIGINT', () => process.exit());

3
services/qserver.js

@ -26,3 +26,6 @@ glob("queues/*.js", {}, (err, files) => {
});
log.info("Queues loading, waiting for messages.");
// see: https://github.com/nodejs/node/issues/35212
process.on('SIGINT', () => process.exit());

3
services/tracker.js

@ -54,3 +54,6 @@ server.on('stop', (addr) => {
const onHttpReq = server.onHttpRequest.bind(server);
assert(onHttpReq !== undefined, "Bad call to bind.");
// see: https://github.com/nodejs/node/issues/35212
process.on('SIGINT', () => process.exit());

Loading…
Cancel
Save