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: add known_issues test for GH-2148 #5920

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Next Next commit
test: add known_issues test for GH-2148
Refs: #2148
  • Loading branch information
Trott committed Mar 28, 2016
commit d0f677afa176ffb7439897fe02b57a38222978f9
19 changes: 19 additions & 0 deletions test/known_issues/test-stdout-buffer-flush-on-exit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
// Refs: https://github.com/nodejs/node/issues/2148
require('../common');
const assert = require('assert');
const execSync = require('child_process').execSync;

const longLine = 'foo bar baz quux quuz aaa bbb ccc'.repeat(80);
const expectedLength = (longLine.length * 999) + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this technically be + 2 on Windows?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably. Good point. Maybe the thing to do is compare stdout.trim().length in the assertion so as to avoid any assumptions whatsoever about the line separator?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, and we may want to compare the (trimmed) output instead of comparing the lengths just to be extra sure we get what we expect.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, done. PTAL


if (process.argv[2] === 'child') {
process.on('exit', () => {
console.log(longLine.repeat(999));
});
process.exit();
}

const stdout = execSync(`${process.execPath} ${__filename} child`);

assert.strictEqual(stdout.length, expectedLength);