Skip to content

Commit

Permalink
fixup! testFinalizerException to gc until it throws
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Schulhof committed Jul 23, 2020
1 parent f04eaa7 commit 540ec7e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/js-native-api/test_exception/testFinalizerException.js
Expand Up @@ -9,14 +9,24 @@ if (process.argv[2] === 'child') {
} catch (anException) {
anException.binding.createExternal();
}
const interval = setInterval(() => {
clearInterval(interval);
}, 100);

// Collect garbage 10 times. At least one of those should throw the exception
// and cause the whole process to bail with it, its text printed to stderr and
// asserted by the parent process to match expectations.
let gcCount = 10;
(function gcLoop() {
global.gc();
if (--gcCount > 0) {
setImmediate(() => gcLoop());
}
})();
return;
}

const assert = require('assert');
const { spawnSync } = require('child_process');
const child = spawnSync(process.execPath, [ __filename, 'child' ]);
const child = spawnSync(process.execPath, [
'--expose-gc', __filename, 'child'
]);
assert.strictEqual(child.signal, null);
assert.match(child.stderr.toString(), /Error during Finalize/m);

0 comments on commit 540ec7e

Please sign in to comment.