Skip to content

Commit bd8574c

Browse files
TrottMylesBorins
authored andcommitted
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: #13904 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 35f9111 commit bd8574c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
3+
34
const assert = require('assert');
45
const cp = require('child_process');
56

6-
function noop() {}
7-
87
function fail(proc, args) {
98
assert.throws(() => {
109
proc.send.apply(proc, args);
@@ -13,13 +12,18 @@ function fail(proc, args) {
1312

1413
let target = process;
1514

16-
if (process.argv[2] !== 'child')
15+
if (process.argv[2] !== 'child') {
1716
target = cp.fork(__filename, ['child']);
17+
target.on('exit', common.mustCall((code, signal) => {
18+
assert.strictEqual(code, 0);
19+
assert.strictEqual(signal, null);
20+
}));
21+
}
1822

1923
fail(target, ['msg', null, null]);
2024
fail(target, ['msg', null, '']);
2125
fail(target, ['msg', null, 'foo']);
2226
fail(target, ['msg', null, 0]);
2327
fail(target, ['msg', null, NaN]);
2428
fail(target, ['msg', null, 1]);
25-
fail(target, ['msg', null, null, noop]);
29+
fail(target, ['msg', null, null, common.mustNotCall()]);

0 commit comments

Comments
 (0)