Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! testFinalizerException to gc until it throws
  • Loading branch information
Gabriel Schulhof committed Jul 23, 2020
commit 540ec7ee561c77340a205a8b5f9a59f72f81452a
18 changes: 14 additions & 4 deletions test/js-native-api/test_exception/testFinalizerException.js
Original file line number Diff line number Diff line change
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);