test: use common module API in test-child-process-exec-stdout-stderr-data-string
PR-URL: https://github.com/nodejs/node/pull/17751 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
1dd9c826e0
commit
4d74b52979
@ -4,20 +4,10 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
|
|
||||||
let stdoutCalls = 0;
|
|
||||||
let stderrCalls = 0;
|
|
||||||
|
|
||||||
const command = common.isWindows ? 'dir' : 'ls';
|
const command = common.isWindows ? 'dir' : 'ls';
|
||||||
exec(command).stdout.on('data', (data) => {
|
|
||||||
stdoutCalls += 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
exec('fhqwhgads').stderr.on('data', (data) => {
|
exec(command).stdout.on('data', common.mustCallAtLeast());
|
||||||
|
|
||||||
|
exec('fhqwhgads').stderr.on('data', common.mustCallAtLeast((data) => {
|
||||||
assert.strictEqual(typeof data, 'string');
|
assert.strictEqual(typeof data, 'string');
|
||||||
stderrCalls += 1;
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
process.on('exit', () => {
|
|
||||||
assert(stdoutCalls > 0);
|
|
||||||
assert(stderrCalls > 0);
|
|
||||||
});
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user