forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add failing test for nodejs#45992
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
test/known_issues/test-readline-big-file-carriage-return.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
// Context: https://github.com/nodejs/node/issues/45992 | ||
|
||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const readline = require('readline'); | ||
|
||
const tmpdir = require('../common/tmpdir'); | ||
|
||
tmpdir.refresh(); | ||
fs.mkdtempSync(`${tmpdir.path}/`); | ||
const path = `${tmpdir.path}/foo`; | ||
const writeStream = fs.createWriteStream(path); | ||
|
||
function write(iteration, callback) { | ||
for (; iteration < 16384; iteration += 1) { | ||
if (!writeStream.write('foo\r\n')) { | ||
writeStream.once('drain', () => write(iteration + 1, callback)); | ||
return; | ||
} | ||
} | ||
|
||
writeStream.end(); | ||
callback(); | ||
} | ||
|
||
write(0, () => { | ||
const input = fs.createReadStream(path); | ||
const rl = readline.createInterface({ input, crlfDelay: Infinity }); | ||
let carriageReturns = 0; | ||
|
||
rl.on('line', (x) => { | ||
if (x.includes('\r')) carriageReturns += 1; | ||
}); | ||
|
||
rl.on('close', () => { | ||
assert.strictEqual(carriageReturns, 0); | ||
}); | ||
}); |