From 8b161e0a7869f9a1c51f2509a69633bc80c98422 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 May 2017 22:14:21 -0700 Subject: [PATCH] test: check number of message events When a no-op message event handler is used in a test, make it clear what is expected by using `common.mustCall()` and `common.mustNotCall()`. PR-URL: https://github.com/nodejs/node/pull/13125 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Gibson Fahnestock Reviewed-By: Refael Ackermann Reviewed-By: Luigi Pinca --- test/parallel/test-child-process-fork-ref2.js | 4 ++-- test/sequential/test-child-process-pass-fd.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-child-process-fork-ref2.js b/test/parallel/test-child-process-fork-ref2.js index 9f59aa344aa2c9..cf50a17ad00c64 100644 --- a/test/parallel/test-child-process-fork-ref2.js +++ b/test/parallel/test-child-process-fork-ref2.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const fork = require('child_process').fork; if (process.argv[2] === 'child') { @@ -8,7 +8,7 @@ if (process.argv[2] === 'child') { setTimeout(function() { console.log('child -> will this keep it alive?'); - process.on('message', function() { }); + process.on('message', common.mustNotCall()); }, 400); } else { diff --git a/test/sequential/test-child-process-pass-fd.js b/test/sequential/test-child-process-pass-fd.js index 2d05407e67b99f..b2481270faf065 100644 --- a/test/sequential/test-child-process-pass-fd.js +++ b/test/sequential/test-child-process-pass-fd.js @@ -45,7 +45,7 @@ if (process.argv[2] !== 'child') { // the only thing keeping this worker alive will be IPC. This is important, // because it means a worker with no parent will have no referenced handles, // thus no work to do, and will exit immediately, preventing process leaks. - process.on('message', common.noop); + process.on('message', common.mustCall()); const server = net.createServer((c) => { process.once('message', function(msg) {