test: refactor test-child-process-send-type-error
* Add exit listener to child process to check return code. Previously, child process faiilure would not cause the test to fail. * Use common.mustNotCall() to guarantee callback is not invoked. * Insert blank line per test writing guide. PR-URL: https://github.com/nodejs/node/pull/13904 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
7477f9ba9c
commit
93683c616b
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
const assert = require('assert');
|
||||
const cp = require('child_process');
|
||||
|
||||
@ -11,8 +12,13 @@ function fail(proc, args) {
|
||||
|
||||
let target = process;
|
||||
|
||||
if (process.argv[2] !== 'child')
|
||||
if (process.argv[2] !== 'child') {
|
||||
target = cp.fork(__filename, ['child']);
|
||||
target.on('exit', common.mustCall((code, signal) => {
|
||||
assert.strictEqual(code, 0);
|
||||
assert.strictEqual(signal, null);
|
||||
}));
|
||||
}
|
||||
|
||||
fail(target, ['msg', null, null]);
|
||||
fail(target, ['msg', null, '']);
|
||||
@ -20,4 +26,4 @@ fail(target, ['msg', null, 'foo']);
|
||||
fail(target, ['msg', null, 0]);
|
||||
fail(target, ['msg', null, NaN]);
|
||||
fail(target, ['msg', null, 1]);
|
||||
fail(target, ['msg', null, null, common.noop]);
|
||||
fail(target, ['msg', null, null, common.mustNotCall()]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user