Skip to content

Commit

Permalink
doc: update tests to avoid running in parallel
Browse files Browse the repository at this point in the history
fixes: nodejs#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#1024
Reviewed-By: Chengzhong Wu <[email protected]>
  • Loading branch information
mhdawson authored and Deepak Rajamohan committed Sep 23, 2021
1 parent fe950f6 commit 6ff72ac
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
7 changes: 7 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,10 @@ exports.runTestWithBindingPath = async function(test, buildType) {
await test(item);
}
}

exports.runTestWithBuildType = async function(test, buildType) {
buildType = buildType || process.config.target_defaults.default_configuration || 'Release';

await Promise.resolve(test(buildType))
.finally(exports.mustCall());
}
23 changes: 14 additions & 9 deletions test/objectwrap_worker_thread.js
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'));
}
}
11 changes: 7 additions & 4 deletions test/symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
const buildType = process.config.target_defaults.default_configuration;
const assert = require('assert');

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


async function test(binding)
function test(binding)
{
const majorNodeVersion = process.versions.node.split('.')[0];

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

function assertCanCreateSymbol(symbol)
{
Expand Down

0 comments on commit 6ff72ac

Please sign in to comment.