| 11 | }; |
| 12 | |
| 13 | function test (binding) { |
| 14 | if (process.argv.includes('child')) { |
| 15 | child(binding); |
| 16 | return; |
| 17 | } |
| 18 | const cp = napiChild.spawn(process.execPath, [__filename, 'child'], { |
| 19 | stdio: ['ignore', 'inherit', 'pipe'] |
| 20 | }); |
| 21 | cp.stderr.setEncoding('utf8'); |
| 22 | let stderr = ''; |
| 23 | cp.stderr.on('data', chunk => { |
| 24 | stderr += chunk; |
| 25 | }); |
| 26 | cp.on('exit', (code, signal) => { |
| 27 | if (process.platform === 'win32') { |
| 28 | assert.strictEqual(code, 128 + 6 /* SIGABRT */); |
| 29 | } else { |
| 30 | assert.strictEqual(signal, 'SIGABRT'); |
| 31 | } |
| 32 | assert.ok(stderr.match(/FATAL ERROR: Napi::Maybe::Check Maybe value is Nothing./)); |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | function child (binding) { |
| 37 | const MAGIC_NUMBER = 12459062; |