From 310a19c57adc250fc4c52c0ead692da4a1a4d1dc Mon Sep 17 00:00:00 2001 From: starkwang <381152119@qq.com> Date: Thu, 6 Jul 2017 15:13:24 +0800 Subject: [PATCH] test: fix test-process-kill-null.js for Windows --- test/parallel/test-process-kill-null.js | 26 ++++++++++--------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-process-kill-null.js b/test/parallel/test-process-kill-null.js index 023724773f6276..c604fd8abfa3d4 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 common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; -const cat = spawn('cat'); -let called; +const child = common.isWindows ? spawn('cmd.exe') : spawn('cat'); -assert.ok(process.kill(cat.pid, 0)); +assert.ok(process.kill(child.pid, 0)); -cat.on('exit', function() { +child.on('exit', common.mustCall(function() { assert.throws(function() { - process.kill(cat.pid, 0); + process.kill(child.pid, 0); }, Error); -}); +})); -cat.stdout.on('data', function() { - called = true; - process.kill(cat.pid, 'SIGKILL'); -}); +child.stdout.on('data', common.mustCall(function() { + process.kill(child.pid, 'SIGKILL'); +})); // EPIPE when null sig fails -cat.stdin.write('test'); - -process.on('exit', function() { - assert.ok(called); -}); +child.stdin.write('test');