Skip to content

Commit 071ecb0

Browse files
Trottaddaleax
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 f1d92fb commit 071ecb0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/parallel/test-child-process-send-type-error.js

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

@@ -11,13 +12,18 @@ function fail(proc, args) {
1112

1213
let target = process;
1314

14-
if (process.argv[2] !== 'child')
15+
if (process.argv[2] !== 'child') {
1516
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+
}
1622

1723
fail(target, ['msg', null, null]);
1824
fail(target, ['msg', null, '']);
1925
fail(target, ['msg', null, 'foo']);
2026
fail(target, ['msg', null, 0]);
2127
fail(target, ['msg', null, NaN]);
2228
fail(target, ['msg', null, 1]);
23-
fail(target, ['msg', null, null, common.noop]);
29+
fail(target, ['msg', null, null, common.mustNotCall()]);

0 commit comments

Comments
 (0)