Skip to content

Commit

Permalink
test: fix up delays for array buffer test
Browse files Browse the repository at this point in the history
Refs: nodejs#735

Signed-off-by: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
mhdawson committed May 25, 2020
1 parent 45cb1d9 commit 1575968
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ if (typeof global.gc === 'function') {
console.log('\nAll tests passed!');
} else {
// Make it easier to run with the correct (version-dependent) command-line args.
const child = require('./napi_child').spawnSync(process.argv[0], [ '--expose-gc', __filename ], {
const child = require('./napi_child').spawnSync(process.argv[0],
['--expose-gc', '--no-concurrent-array-buffer-freeing', '--no-concurrent-array-buffer-sweeping', __filename ], {
stdio: 'inherit',
});

Expand Down
14 changes: 13 additions & 1 deletion test/testUtil.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
// Run each test function in sequence,
// with an async delay and GC call between each.

function tick(x, cb) {
function ontick() {
if (--x === 0) {
if (typeof cb === 'function') cb();
} else {
setImmediate(ontick);
}
}
setImmediate(ontick);
};

function runGCTests(tests, i, title) {
if (!i) {
i = 0;
Expand All @@ -18,7 +30,7 @@ function runGCTests(tests, i, title) {
}
setImmediate(() => {
global.gc();
runGCTests(tests, i + 1, title);
tick(10, runGCTests(tests, i + 1, title));
});
}
}
Expand Down

0 comments on commit 1575968

Please sign in to comment.