Skip to content

Commit

Permalink
Fix segfault in test
Browse files Browse the repository at this point in the history
Fail test suite if child process receives a signal.
Fixes segfault in test.

PR-URL: nodejs/node-addon-api#148
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
Marlyfleitas committed Oct 25, 2017
1 parent 65c020b commit e2a5de5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ if (typeof global.gc === 'function') {
const child = require('./napi_child').spawnSync(process.argv[0], [ '--expose-gc', __filename ], {
stdio: 'inherit',
});
process.exitCode = child.status;

if (child.signal) {
console.log(`Tests aborted with ${child.signal}`);
process.exitCode = 1;
} else {
process.exitCode = child.status;
}
}
2 changes: 2 additions & 0 deletions test/objectwrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class TestIter : public Napi::ObjectWrap<TestIter> {
Constructor = Napi::Persistent(DefineClass(env, "TestIter", {
InstanceMethod("next", &TestIter::Next),
}));

Constructor.SuppressDestruct();
}

static Napi::FunctionReference Constructor;
Expand Down

0 comments on commit e2a5de5

Please sign in to comment.