From 78e0cb963eabe12af97e7a49d7031d501ebcc42d Mon Sep 17 00:00:00 2001 From: sreepurnajasti Date: Tue, 19 Dec 2017 11:44:04 +0530 Subject: [PATCH] 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 Reviewed-By: James M Snell Reviewed-By: Yuta Hiroto Reviewed-By: Luigi Pinca Reviewed-By: Jon Moss Reviewed-By: Ruben Bridgewater --- ...d-process-exec-stdout-stderr-data-string.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-child-process-exec-stdout-stderr-data-string.js b/test/parallel/test-child-process-exec-stdout-stderr-data-string.js index 472d31f16ac920..1fbdfbf8e45b4d 100644 --- a/test/parallel/test-child-process-exec-stdout-stderr-data-string.js +++ b/test/parallel/test-child-process-exec-stdout-stderr-data-string.js @@ -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'); +}));