Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix test-child-process-stdout-flush-exit #1868

Merged
merged 1 commit into from
Jun 2, 2015
Merged
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
19 changes: 6 additions & 13 deletions test/parallel/test-child-process-stdout-flush-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ if (process.argv[2] === 'child') {
// spawn self as child
var child = spawn(process.argv[0], [process.argv[1], 'child']);

var gotHello = false;
var gotBye = false;
var stdout = '';

child.stderr.setEncoding('utf8');
child.stderr.on('data', function(data) {
Expand All @@ -30,17 +29,11 @@ if (process.argv[2] === 'child') {
// check if we receive both 'hello' at start and 'goodbye' at end
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(data) {
if (data.slice(0, 6) == 'hello\n') {
gotHello = true;
} else if (data.slice(data.length - 8) == 'goodbye\n') {
gotBye = true;
} else {
gotBye = false;
}
stdout += data;
});

child.on('close', function(data) {
assert(gotHello);
assert(gotBye);
});
child.on('close', common.mustCall(function() {
assert.equal(stdout.slice(0, 6), 'hello\n');
assert.equal(stdout.slice(stdout.length - 8), 'goodbye\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

assert.strictEqual would be better, no?

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't really matter for primitives. I'll land it, CI is happy.

}));
}