From 880415e0e6c8ce236caf0236bb6f565b82134063 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 16 Oct 2017 16:25:26 +0200 Subject: [PATCH] test: refactor test-process-kill-null Use `common.mustCall()` instead of `called` variable. PR-URL: https://github.com/nodejs/node/pull/16236 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Yuta Hiroto Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel Reviewed-By: Ruben Bridgewater --- test/parallel/test-process-kill-null.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-process-kill-null.js b/test/parallel/test-process-kill-null.js index 023724773f6276..88fc677454c941 100644 --- a/test/parallel/test-process-kill-null.js +++ b/test/parallel/test-process-kill-null.js @@ -20,29 +20,23 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const { mustCall } = require('../common'); const assert = require('assert'); -const spawn = require('child_process').spawn; +const { spawn } = require('child_process'); const cat = spawn('cat'); -let called; assert.ok(process.kill(cat.pid, 0)); -cat.on('exit', function() { +cat.on('exit', mustCall(function() { assert.throws(function() { process.kill(cat.pid, 0); }, Error); -}); +})); -cat.stdout.on('data', function() { - called = true; +cat.stdout.on('data', mustCall(function() { process.kill(cat.pid, 'SIGKILL'); -}); +})); // EPIPE when null sig fails cat.stdin.write('test'); - -process.on('exit', function() { - assert.ok(called); -});