Skip to content

Commit d53b636

Browse files
committed
test: verify fields in spawn{Sync} errors
This commit validates the properties of ENOENT error objects returned by spawn() and spawnSync(). PR-URL: #838 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent f029693 commit d53b636

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

test/parallel/test-child-process-spawn-error.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ var assert = require('assert');
66
var errors = 0;
77

88
var enoentPath = 'foo123';
9+
var spawnargs = ['bar'];
910
assert.equal(common.fileExists(enoentPath), false);
1011

11-
var enoentChild = spawn(enoentPath);
12+
var enoentChild = spawn(enoentPath, spawnargs);
1213
enoentChild.on('error', function (err) {
14+
assert.equal(err.code, 'ENOENT');
15+
assert.equal(err.errno, 'ENOENT');
16+
assert.equal(err.syscall, 'spawn ' + enoentPath);
1317
assert.equal(err.path, enoentPath);
18+
assert.deepEqual(err.spawnargs, spawnargs);
1419
errors++;
1520
});
1621

test/parallel/test-child-process-spawnsync.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ console.log('sleep exited', stop);
2323
assert.strictEqual(stop[0], 1, 'sleep should not take longer or less than 1 second');
2424

2525
// Error test when command does not exist
26-
var ret_err = spawnSync('command_does_not_exist');
27-
assert.strictEqual(ret_err.error.code, 'ENOENT');
26+
var ret_err = spawnSync('command_does_not_exist', ['bar']).error;
27+
28+
assert.strictEqual(ret_err.code, 'ENOENT');
29+
assert.strictEqual(ret_err.errno, 'ENOENT');
30+
assert.strictEqual(ret_err.syscall, 'spawnSync command_does_not_exist');
31+
assert.strictEqual(ret_err.path, 'command_does_not_exist');
32+
assert.deepEqual(ret_err.spawnargs, ['bar']);
2833

2934
// Verify that the cwd option works - GH #7824
3035
(function() {

0 commit comments

Comments
 (0)