|
1 |
| -var spawn = require('child_process').spawn, |
2 |
| - assert = require('assert'), |
3 |
| - windows = (process.platform === 'win32'), |
4 |
| - cmd = (windows) ? 'rundll32' : 'ls', |
5 |
| - invalidcmd = 'hopefully_you_dont_have_this_on_your_machine', |
6 |
| - invalidArgsMsg = /Incorrect value of args option/, |
7 |
| - invalidOptionsMsg = /options argument must be an object/, |
8 |
| - errors = 0; |
9 |
| - |
10 |
| -try { |
11 |
| - // Ensure this throws a TypeError |
12 |
| - var child = spawn(invalidcmd, 'this is not an array'); |
13 |
| - |
14 |
| - child.on('error', function (err) { |
15 |
| - errors++; |
16 |
| - }); |
17 |
| - |
18 |
| -} catch (e) { |
19 |
| - assert.equal(e instanceof TypeError, true); |
20 |
| -} |
| 1 | +var assert = require('assert'); |
| 2 | +var child_process = require('child_process'); |
| 3 | +var spawn = child_process.spawn; |
| 4 | +var cmd = (process.platform === 'win32') ? 'rundll32' : 'ls'; |
| 5 | +var invalidArgsMsg = /Incorrect value of args option/; |
| 6 | +var invalidOptionsMsg = /options argument must be an object/; |
| 7 | + |
| 8 | +// verify that args argument must be an array |
| 9 | +assert.throws(function() { |
| 10 | + spawn(cmd, 'this is not an array'); |
| 11 | +}, TypeError); |
21 | 12 |
|
22 | 13 | // verify that valid argument combinations do not throw
|
23 | 14 | assert.doesNotThrow(function() {
|
@@ -57,6 +48,3 @@ assert.throws(function() {
|
57 | 48 | spawn(cmd, [], 1);
|
58 | 49 | }, invalidOptionsMsg);
|
59 | 50 |
|
60 |
| -process.on('exit', function() { |
61 |
| - assert.equal(errors, 0); |
62 |
| -}); |
0 commit comments