test: test execFile/fork arg validation
Fixes: https://github.com/nodejs/node/issues/2681 Refs: https://github.com/nodejs/node/pull/4508 PR-URL: https://github.com/nodejs/node/pull/7399 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
0548e5d12a
commit
99cfd53097
@ -23,11 +23,11 @@ exports.fork = function(modulePath /*, args, options*/) {
|
|||||||
var options = {};
|
var options = {};
|
||||||
var args = [];
|
var args = [];
|
||||||
var pos = 1;
|
var pos = 1;
|
||||||
if (Array.isArray(arguments[pos])) {
|
if (pos < arguments.length && Array.isArray(arguments[pos])) {
|
||||||
args = arguments[pos++];
|
args = arguments[pos++];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments[pos] != null) {
|
if (pos < arguments.length && arguments[pos] != null) {
|
||||||
if (typeof arguments[pos] !== 'object') {
|
if (typeof arguments[pos] !== 'object') {
|
||||||
throw new TypeError('Incorrect value of args option');
|
throw new TypeError('Incorrect value of args option');
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,13 +111,36 @@ assert.doesNotThrow(function() { execFile(cmd, a, o, u); });
|
|||||||
assert.doesNotThrow(function() { execFile(cmd, n, o, c); });
|
assert.doesNotThrow(function() { execFile(cmd, n, o, c); });
|
||||||
assert.doesNotThrow(function() { execFile(cmd, a, n, c); });
|
assert.doesNotThrow(function() { execFile(cmd, a, n, c); });
|
||||||
assert.doesNotThrow(function() { execFile(cmd, a, o, n); });
|
assert.doesNotThrow(function() { execFile(cmd, a, o, n); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, u, u, u); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, u, u, c); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, u, o, u); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, a, u, u); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, n, n, n); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, n, n, c); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, n, o, n); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, a, n, n); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, a, u); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, a, n); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, o, u); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, o, n); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, c, u); });
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, c, n); });
|
||||||
|
|
||||||
// string is invalid in arg position (this may seem strange, but is
|
// string is invalid in arg position (this may seem strange, but is
|
||||||
// consistent across node API, cf. `net.createServer('not options', 'not
|
// consistent across node API, cf. `net.createServer('not options', 'not
|
||||||
// callback')`
|
// callback')`
|
||||||
assert.throws(function() { execFile(cmd, s, o, c); }, TypeError);
|
assert.throws(function() { execFile(cmd, s, o, c); }, TypeError);
|
||||||
assert.doesNotThrow(function() { execFile(cmd, a, s, c); });
|
assert.throws(function() { execFile(cmd, a, s, c); }, TypeError);
|
||||||
assert.doesNotThrow(function() { execFile(cmd, a, o, s); });
|
assert.throws(function() { execFile(cmd, a, o, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, a, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, o, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, u, u, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, n, n, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, a, u, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, a, n, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, u, o, s); }, TypeError);
|
||||||
|
assert.throws(function() { execFile(cmd, n, o, s); }, TypeError);
|
||||||
|
assert.doesNotThrow(function() { execFile(cmd, c, s); });
|
||||||
|
|
||||||
|
|
||||||
// verify that fork has same argument parsing behaviour as spawn
|
// verify that fork has same argument parsing behaviour as spawn
|
||||||
@ -131,6 +154,12 @@ assert.doesNotThrow(function() { fork(empty); });
|
|||||||
assert.doesNotThrow(function() { fork(empty, a); });
|
assert.doesNotThrow(function() { fork(empty, a); });
|
||||||
assert.doesNotThrow(function() { fork(empty, a, o); });
|
assert.doesNotThrow(function() { fork(empty, a, o); });
|
||||||
assert.doesNotThrow(function() { fork(empty, o); });
|
assert.doesNotThrow(function() { fork(empty, o); });
|
||||||
|
assert.doesNotThrow(function() { fork(empty, u, u); });
|
||||||
|
assert.doesNotThrow(function() { fork(empty, u, o); });
|
||||||
|
assert.doesNotThrow(function() { fork(empty, a, u); });
|
||||||
|
assert.doesNotThrow(function() { fork(empty, n, n); });
|
||||||
|
assert.doesNotThrow(function() { fork(empty, n, o); });
|
||||||
|
assert.doesNotThrow(function() { fork(empty, a, n); });
|
||||||
|
|
||||||
assert.throws(function() { fork(empty, s); }, TypeError);
|
assert.throws(function() { fork(empty, s); }, TypeError);
|
||||||
assert.doesNotThrow(function() { fork(empty, a, s); }, TypeError);
|
assert.throws(function() { fork(empty, a, s); }, TypeError);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user