mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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 <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>
This commit is contained in:
committed by
James M Snell
parent
5d99a9bf65
commit
880415e0e6
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user