test: use assert.throw to test exceptions
authorSam Roberts <sam@strongloop.com>
Tue, 13 Jan 2015 02:21:29 +0000 (03:21 +0100)
committerBert Belder <bertbelder@gmail.com>
Tue, 13 Jan 2015 02:28:32 +0000 (03:28 +0100)
commitf76722686b91cf1c8db05a116ea0a960a5a49e8a
treeffe51e9e8218cc2603f8b6836395e540f0896bf3
parent22d20582ccfbb9077c72c196340b21ef6f1aa624
test: use assert.throw to test exceptions

The test wasn't checking directly that an assertion was thrown. Instead,
it was checking that spawn did not sucessfully spawn a non-existent
command.

However, the command chosen, dir, exists in GNU coreutils, so it exists
on Linux (though not on BSD derived OS X). The test as written passed on
Linux, even with the TypeError it is supposed to be checking for deleted
from spawn(). It would also pass on Windows if a ls.exe existed.

The approach is unnecessarily obscure, assert.throw() is for asserting
code throws, using it is more clear and works regardless of what
commands do or do not exist.

PR-URL: https://github.com/joyent/node/pull/8454
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Cherry-picked-from: https://github.com/joyent/node/commit/2ff29cc7e35f486daf86710fd2db48275442c788

Conflicts:
test/parallel/test-child-process-spawn-typeerror.js
test/parallel/test-child-process-spawn-typeerror.js