-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: update tests to avoid running in parallel
fixes: nodejs/node-addon-api#1022 The objectwrap_worker_thread and symbol tests were not waiting for the test to complete before the subsequent tests were started. This caused intermitted crashes in the CI. Updated both tests so that they complete before the next test runs. Signed-off-by: Michael Dawson <[email protected]> PR-URL: nodejs/node-addon-api#1024 Reviewed-By: Chengzhong Wu <[email protected]>
- Loading branch information
1 parent
06c4faf
commit 5f07939
Showing
3 changed files
with
28 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const { Worker, isMainThread, workerData } = require('worker_threads'); | ||
|
||
if (isMainThread) { | ||
const buildType = process.config.target_defaults.default_configuration; | ||
new Worker(__filename, { workerData: buildType }); | ||
} else { | ||
const test = binding => { | ||
new binding.objectwrap.Test(); | ||
}; | ||
module.exports = require('./common').runTestWithBuildType(test); | ||
|
||
const buildType = workerData; | ||
require('./common').runTest(test, buildType); | ||
async function test(buildType) { | ||
if (isMainThread) { | ||
const buildType = process.config.target_defaults.default_configuration; | ||
const worker = new Worker(__filename, { workerData: buildType }); | ||
return new Promise((resolve, reject) => { | ||
worker.on('exit', () => { | ||
resolve(); | ||
}); | ||
}, () => {}); | ||
} else { | ||
await require(path.join(__dirname, 'objectwrap.js')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters