Skip to content

Commit 22be609

Browse files
rolftimmermansmhdawson
authored andcommitted
Fix segfault in test
Fail test suite if child process receives a signal. Fixes segfault in test. PR-URL: #148 Reviewed-By: Michael Dawson <[email protected]>
1 parent d3f62e3 commit 22be609

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ if (typeof global.gc === 'function') {
2828
const child = require('./napi_child').spawnSync(process.argv[0], [ '--expose-gc', __filename ], {
2929
stdio: 'inherit',
3030
});
31-
process.exitCode = child.status;
31+
32+
if (child.signal) {
33+
console.log(`Tests aborted with ${child.signal}`);
34+
process.exitCode = 1;
35+
} else {
36+
process.exitCode = child.status;
37+
}
3238
}

test/objectwrap.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class TestIter : public Napi::ObjectWrap<TestIter> {
1414
Constructor = Napi::Persistent(DefineClass(env, "TestIter", {
1515
InstanceMethod("next", &TestIter::Next),
1616
}));
17+
18+
Constructor.SuppressDestruct();
1719
}
1820

1921
static Napi::FunctionReference Constructor;

0 commit comments

Comments
 (0)