diff --git a/test/parallel/test-child-process-execfile.js b/test/parallel/test-child-process-execfile.js index ab36aa7b156f99..f87a4eb1154f2a 100644 --- a/test/parallel/test-child-process-execfile.js +++ b/test/parallel/test-child-process-execfile.js @@ -1,9 +1,9 @@ 'use strict'; - const common = require('../common'); const assert = require('assert'); const execFile = require('child_process').execFile; const path = require('path'); +const uv = process.binding('uv'); const fixture = path.join(common.fixturesDir, 'exit.js'); @@ -19,3 +19,22 @@ const fixture = path.join(common.fixturesDir, 'exit.js'); }) ); } + +{ + // Verify that negative exit codes can be translated to UV error names. + const errorString = `Error: Command failed: ${process.execPath}`; + const code = -1; + const callback = common.mustCall((err, stdout, stderr) => { + assert.strictEqual(err.toString().trim(), errorString); + assert.strictEqual(err.code, uv.errname(code)); + assert.strictEqual(err.killed, true); + assert.strictEqual(err.signal, null); + assert.strictEqual(err.cmd, process.execPath); + assert.strictEqual(stdout.trim(), ''); + assert.strictEqual(stderr.trim(), ''); + }); + const child = execFile(process.execPath, callback); + + child.kill(); + child.emit('close', code, null); +}