Commit c7bdf1fc by Ryan Petrich

Add test:worker script that runs the mocha tests inside a worker

parent 1b5aa3a7
......@@ -50,7 +50,8 @@
"prepublishOnly": "npm ls",
"install": "node-pre-gyp install --fallback-to-build",
"pretest": "node test/support/createdb.js",
"test": "mocha -R spec --timeout 480000"
"test": "mocha -R spec --timeout 480000",
"test:worker": "node --experimental-worker scripts/mocha-as-worker.js -R spec --timeout 480000"
},
"license": "BSD-3-Clause",
"keywords": [
......
// Run the mocha tests in a worker
// Not a clean approach, but is sufficient to verify correctness
const worker_threads = require("worker_threads");
const path = require("path");
if (worker_threads.isMainThread) {
const worker = new worker_threads.Worker(__filename, { workerData: { windowSize: process.stdout.getWindowSize() } });
worker.on("error", console.error);
} else {
process.stdout.getWindowSize = () => worker_threads.workerData.windowSize;
const mochaPath = path.resolve(require.resolve("mocha"), "../bin/_mocha");
require(mochaPath);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment