Skip to content

Commit a459f5c

Browse files
committed
doc: update tests to avoid running in parallel
fixes: #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: #1024 Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 6697c51 commit a459f5c

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

test/common/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,10 @@ exports.runTestWithBindingPath = async function(test, buildType) {
101101
await test(item);
102102
}
103103
}
104+
105+
exports.runTestWithBuildType = async function(test, buildType) {
106+
buildType = buildType || process.config.target_defaults.default_configuration || 'Release';
107+
108+
await Promise.resolve(test(buildType))
109+
.finally(exports.mustCall());
110+
}

test/objectwrap_worker_thread.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
'use strict';
2+
const path = require('path');
23
const { Worker, isMainThread, workerData } = require('worker_threads');
34

4-
if (isMainThread) {
5-
const buildType = process.config.target_defaults.default_configuration;
6-
new Worker(__filename, { workerData: buildType });
7-
} else {
8-
const test = binding => {
9-
new binding.objectwrap.Test();
10-
};
5+
module.exports = require('./common').runTestWithBuildType(test);
116

12-
const buildType = workerData;
13-
require('./common').runTest(test, buildType);
7+
async function test(buildType) {
8+
if (isMainThread) {
9+
const buildType = process.config.target_defaults.default_configuration;
10+
const worker = new Worker(__filename, { workerData: buildType });
11+
return new Promise((resolve, reject) => {
12+
worker.on('exit', () => {
13+
resolve();
14+
});
15+
}, () => {});
16+
} else {
17+
await require(path.join(__dirname, 'objectwrap.js'));
18+
}
1419
}

test/symbol.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
const buildType = process.config.target_defaults.default_configuration;
44
const assert = require('assert');
55

6-
test(require(`./build/${buildType}/binding.node`));
7-
test(require(`./build/${buildType}/binding_noexcept.node`));
6+
module.exports = require('./common').runTest(test);
87

98

10-
async function test(binding)
9+
function test(binding)
1110
{
11+
const majorNodeVersion = process.versions.node.split('.')[0];
1212

13-
const wellKnownSymbolFunctions = ['asyncIterator','hasInstance','isConcatSpreadable', 'iterator','match','matchAll','replace','search','split','species','toPrimitive','toStringTag','unscopables'];
13+
let wellKnownSymbolFunctions = ['asyncIterator','hasInstance','isConcatSpreadable', 'iterator','match','replace','search','split','species','toPrimitive','toStringTag','unscopables'];
14+
if (majorNodeVersion >= 12) {
15+
wellKnownSymbolFunctions.push('matchAll');
16+
}
1417

1518
function assertCanCreateSymbol(symbol)
1619
{

0 commit comments

Comments
 (0)