Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

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: nodejs/node#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 addaleax committed Oct 26, 2017
1 parent d90b9fc commit d106a9b
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
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 d106a9b

Please sign in to comment.