Browse Source

test: fix unreliable known_issues test

`test-stdout-buffer-flush-on-exit` was not failing reliably on POSIX
machines and not failing at all on Windows. Revised test fails reliably
on POSIX and is skipped (in CI) on Windows where the issue does not
exist.

Fixes: https://github.com/nodejs/node/issues/6527
PR-URL: https://github.com/nodejs/node/pull/6555
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joao Reis <reis@janeasystems.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
process-exit-stdio-flushing
Rich Trott 9 years ago
parent
commit
c4006ddfc3
  1. 20
      test/known_issues/known_issues.status
  2. 15
      test/known_issues/test-stdout-buffer-flush-on-exit.js

20
test/known_issues/known_issues.status

@ -0,0 +1,20 @@
prefix known_issues
# If a known issue does not apply to a platform, list the test name in the
# appropriate section below, without ".js", followed by ": SKIP". Example:
# sample-test : SKIP
[true] # This section applies to all platforms
[$system==win32]
test-stdout-buffer-flush-on-exit: SKIP
[$system==linux]
[$system==macos]
[$system==solaris]
[$system==freebsd]
[$system==aix]

15
test/known_issues/test-stdout-buffer-flush-on-exit.js

@ -5,16 +5,23 @@ require('../common');
const assert = require('assert'); const assert = require('assert');
const execSync = require('child_process').execSync; const execSync = require('child_process').execSync;
const longLine = 'foo bar baz quux quuz aaa bbb ccc'.repeat(65536); const lineSeed = 'foo bar baz quux quuz aaa bbb ccc';
if (process.argv[2] === 'child') { if (process.argv[2] === 'child') {
const longLine = lineSeed.repeat(parseInt(process.argv[4], 10));
process.on('exit', () => { process.on('exit', () => {
console.log(longLine); console.log(longLine);
}); });
process.exit(); process.exit();
} }
const cmd = `${process.execPath} ${__filename} child`; [16, 18, 20].forEach((exponent) => {
const stdout = execSync(cmd).toString().trim(); const bigNum = Math.pow(2, exponent);
const longLine = lineSeed.repeat(bigNum);
const cmd = `${process.execPath} ${__filename} child ${exponent} ${bigNum}`;
const stdout = execSync(cmd).toString().trim();
assert.strictEqual(stdout, longLine, `failed with exponent ${exponent}`);
});
assert.strictEqual(stdout, longLine);

Loading…
Cancel
Save