Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions test/pummel/test-child-process-spawn-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ const assert = require('assert');

const spawn = require('child_process').spawn;

var SIZE = 1000 * 1024;
var N = 40;
var finished = false;
const SIZE = 1000 * 1024;
const N = 40;
let finished = false;

function doSpawn(i) {
var child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']);
var count = 0;
const child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nodejs/testing This test depends on python, although I understand that our build system depends on it. Is that okay to keep it as it is, or refactor it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's reasonable to keep the dependency here but it's also reasonable to spawn Node instead. I don't want to block this PR on it though.

let count = 0;

child.stdout.setEncoding('ascii');
child.stdout.on('data', function(chunk) {
child.stdout.on('data', (chunk) => {
count += chunk.length;
});

child.stderr.on('data', function(chunk) {
child.stderr.on('data', (chunk) => {
console.log('stderr: ' + chunk);
});

child.on('close', function() {
child.on('close', () => {
// + 1 for \n or + 2 for \r\n on Windows
assert.equal(SIZE + (common.isWindows ? 2 : 1), count);
assert.strictEqual(SIZE + (common.isWindows ? 2 : 1), count);
if (i < N) {
doSpawn(i + 1);
} else {
Expand All @@ -34,6 +34,6 @@ function doSpawn(i) {

doSpawn(0);

process.on('exit', function() {
process.on('exit', () => {
assert.ok(finished);
});