Skip to content

Commit

Permalink
test: refactor test-process-kill-null
Browse files Browse the repository at this point in the history
Use `common.mustCall()` instead of `called` variable.

PR-URL: #16236
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
lpinca authored and MylesBorins committed Nov 28, 2017
1 parent 9c96d7f commit fa8315c
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions test/parallel/test-process-kill-null.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
'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);
});

0 comments on commit fa8315c

Please sign in to comment.