From ad5b8974fcea3259a5ddb42a1de3d379e4d43707 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Jun 2016 16:21:21 -0700 Subject: [PATCH 1/4] test: add test for exec() known issue Refs: https://github.com/nodejs/node/issues/7342 --- .../test-child-process-exec-stdout-data-string.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/known_issues/test-child-process-exec-stdout-data-string.js diff --git a/test/known_issues/test-child-process-exec-stdout-data-string.js b/test/known_issues/test-child-process-exec-stdout-data-string.js new file mode 100644 index 00000000000000..443613450699cc --- /dev/null +++ b/test/known_issues/test-child-process-exec-stdout-data-string.js @@ -0,0 +1,15 @@ +'use strict'; +// Refs: https://github.com/nodejs/node/issues/7342 +const common = require('../common'); +const assert = require('assert'); +const exec = require('child_process').exec; + +const keepAlive = setInterval(() => {}, 9999); + +const command = common.isWindows ? 'dir' : 'ls'; +const e = exec(command); + +e.stdout.on('data', function(data) { + assert.strictEqual(typeof data, 'string'); + clearInterval(keepAlive); +}); From d46fe32e612bed334c7e37620f03e312e4a732fd Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Jun 2016 22:16:21 -0700 Subject: [PATCH 2/4] squash: address nits, add test for stderr --- ...t-child-process-exec-stdout-data-string.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/known_issues/test-child-process-exec-stdout-data-string.js b/test/known_issues/test-child-process-exec-stdout-data-string.js index 443613450699cc..5876d6233b7af2 100644 --- a/test/known_issues/test-child-process-exec-stdout-data-string.js +++ b/test/known_issues/test-child-process-exec-stdout-data-string.js @@ -4,12 +4,19 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -const keepAlive = setInterval(() => {}, 9999); +// const keepAlive = setInterval(() => {}, 9999); +var cbCalls = 0; +const expectedCalls = 2; + +const cb = common.mustCall((data) => { + console.log('foo'); + assert(data instanceof Buffer); + // if (++cbCalls === expectedCalls) { + // clearInterval(keepAlive); + // } +}, expectedCalls); const command = common.isWindows ? 'dir' : 'ls'; -const e = exec(command); +exec(command).stdout.on('data', cb); -e.stdout.on('data', function(data) { - assert.strictEqual(typeof data, 'string'); - clearInterval(keepAlive); -}); +exec('fhqwhgads').stderr.on('data', cb); From 8485d17cef25942fbaaaafe06a670968073a2ae9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Jun 2016 22:21:42 -0700 Subject: [PATCH 3/4] squash: fix goofs --- .../test-child-process-exec-stdout-data-string.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/known_issues/test-child-process-exec-stdout-data-string.js b/test/known_issues/test-child-process-exec-stdout-data-string.js index 5876d6233b7af2..538dc8883d9042 100644 --- a/test/known_issues/test-child-process-exec-stdout-data-string.js +++ b/test/known_issues/test-child-process-exec-stdout-data-string.js @@ -4,16 +4,11 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -// const keepAlive = setInterval(() => {}, 9999); var cbCalls = 0; const expectedCalls = 2; const cb = common.mustCall((data) => { - console.log('foo'); - assert(data instanceof Buffer); - // if (++cbCalls === expectedCalls) { - // clearInterval(keepAlive); - // } + assert.strictEqual(typeof data, 'string'); }, expectedCalls); const command = common.isWindows ? 'dir' : 'ls'; From 8141cfa19b6dc3e24f929435fd40ce968698fa6b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Jun 2016 22:23:34 -0700 Subject: [PATCH 4/4] squash: lint --- test/known_issues/test-child-process-exec-stdout-data-string.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/known_issues/test-child-process-exec-stdout-data-string.js b/test/known_issues/test-child-process-exec-stdout-data-string.js index 538dc8883d9042..b267ff5e98347a 100644 --- a/test/known_issues/test-child-process-exec-stdout-data-string.js +++ b/test/known_issues/test-child-process-exec-stdout-data-string.js @@ -4,7 +4,6 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -var cbCalls = 0; const expectedCalls = 2; const cb = common.mustCall((data) => {