Skip to content

Commit

Permalink
test: use common module API in test-child-process-exec-stdout-stderr-…
Browse files Browse the repository at this point in the history
…data-string

PR-URL: #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>
  • Loading branch information
sreepurnajasti authored and MylesBorins committed Feb 11, 2018
1 parent 1a966f1 commit 78e0cb9
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions test/parallel/test-child-process-exec-stdout-stderr-data-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@ const common = require('../common');
const assert = require('assert');
const exec = require('child_process').exec;

let stdoutCalls = 0;
let stderrCalls = 0;

const command = common.isWindows ? 'dir' : 'ls';
exec(command).stdout.on('data', (data) => {
stdoutCalls += 1;
});

exec('fhqwhgads').stderr.on('data', (data) => {
assert.strictEqual(typeof data, 'string');
stderrCalls += 1;
});
exec(command).stdout.on('data', common.mustCallAtLeast());

process.on('exit', () => {
assert(stdoutCalls > 0);
assert(stderrCalls > 0);
});
exec('fhqwhgads').stderr.on('data', common.mustCallAtLeast((data) => {
assert.strictEqual(typeof data, 'string');
}));

0 comments on commit 78e0cb9

Please sign in to comment.