mirror of https://github.com/lukechilds/node.git
Browse Source
PR-URL: https://github.com/nodejs/node/pull/13971 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jason Ginchereau <jasongin@microsoft.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>v6
Kyle Farnung
7 years ago
committed by
Michael Dawson
6 changed files with 75 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||
{ |
|||
"targets": [ |
|||
{ |
|||
"target_name": "test_fatal", |
|||
"sources": [ "test_fatal.c" ] |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,18 @@ |
|||
'use strict'; |
|||
const common = require('../../common'); |
|||
const assert = require('assert'); |
|||
const child_process = require('child_process'); |
|||
const test_fatal = require(`./build/${common.buildType}/test_fatal`); |
|||
|
|||
// Test in a child process because the test code will trigger a fatal error
|
|||
// that crashes the process.
|
|||
if (process.argv[2] === 'child') { |
|||
test_fatal.Test(); |
|||
return; |
|||
} |
|||
|
|||
const p = child_process.spawnSync( |
|||
process.execPath, [ '--napi-modules', __filename, 'child' ]); |
|||
assert.ifError(p.error); |
|||
assert.ok(p.stderr.toString().includes( |
|||
'FATAL ERROR: test_fatal::Test fatal message')); |
@ -0,0 +1,18 @@ |
|||
#include <node_api.h> |
|||
#include "../common.h" |
|||
|
|||
napi_value Test(napi_env env, napi_callback_info info) { |
|||
napi_fatal_error("test_fatal::Test", "fatal message"); |
|||
return NULL; |
|||
} |
|||
|
|||
void Init(napi_env env, napi_value exports, napi_value module, void* priv) { |
|||
napi_property_descriptor properties[] = { |
|||
DECLARE_NAPI_PROPERTY("Test", Test), |
|||
}; |
|||
|
|||
NAPI_CALL_RETURN_VOID(env, napi_define_properties( |
|||
env, exports, sizeof(properties) / sizeof(*properties), properties)); |
|||
} |
|||
|
|||
NAPI_MODULE(addon, Init) |
Loading…
Reference in new issue