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 targos committed Oct 18, 2017
1 parent fefcd82 commit a601596
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions test/parallel/test-process-kill-null.js
Expand Up @@ -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);
});

0 comments on commit a601596

Please sign in to comment.