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 f316921
Showing 1 changed file with 13 additions and 1 deletion.
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 f316921

Please sign in to comment.