-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #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>
- Loading branch information
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"targets": [ | ||
{ | ||
"target_name": "test_fatal", | ||
"sources": [ "test_fatal.c" ] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |