From f9096a79b7b649c0f9fa9d78e61d647e64a952e3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 24 Jun 2017 20:11:43 -0700 Subject: [PATCH] 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 Reviewed-By: James M Snell Reviewed-By: Refael Ackermann --- test/parallel/test-child-process-send-type-error.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-child-process-send-type-error.js b/test/parallel/test-child-process-send-type-error.js index b92d1ee90bffaf..803d8173aeb9dc 100644 --- a/test/parallel/test-child-process-send-type-error.js +++ b/test/parallel/test-child-process-send-type-error.js @@ -1,5 +1,6 @@ 'use strict'; -require('../common'); +const common = require('../common'); + const assert = require('assert'); const cp = require('child_process'); @@ -13,8 +14,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, '']); @@ -22,4 +28,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, noop]); +fail(target, ['msg', null, null, common.mustNotCall()]);