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 check to test-fs-readfile-tostring-fail #43850

Merged
merged 2 commits into from
Jul 18, 2022
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
6 changes: 5 additions & 1 deletion test/pummel/test-fs-readfile-tostring-fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ stream.on('error', (err) => { throw err; });

const size = kStringMaxLength / 200;
const a = Buffer.alloc(size, 'a');
let expectedSize = 0;

for (let i = 0; i < 201; i++) {
stream.write(a);
stream.write(a, (err) => { assert.ifError(err); });
Copy link
Member

@lpinca lpinca Jul 15, 2022

Choose a reason for hiding this comment

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

Nit: I think this is not needed because a listener for the 'error' event is already added on the stream on line 24 but it does not harm.

expectedSize += a.length;
}

stream.end();
stream.on('finish', common.mustCall(function() {
assert.strictEqual(stream.bytesWritten, expectedSize,
`${stream.bytesWritten} bytes written (expected ${expectedSize} bytes).`);
richardlau marked this conversation as resolved.
Show resolved Hide resolved
fs.readFile(file, 'utf8', common.mustCall(function(err, buf) {
assert.ok(err instanceof Error);
if (err.message !== 'Array buffer allocation failed') {
Expand Down