Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb6787c

Browse filesBrowse files
richardlaudanielleadams
authored andcommitted
test: add check to test-fs-readfile-tostring-fail
Check that all of the bytes were written to the temporary file before reading it to catch the case where there is insufficient disk space. PR-URL: #43850 Refs: #43833 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent bb5511e commit bb6787c
Copy full SHA for bb6787c

File tree

Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Open diff view settings
Collapse file

‎test/pummel/test-fs-readfile-tostring-fail.js‎

Copy file name to clipboardExpand all lines: test/pummel/test-fs-readfile-tostring-fail.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ stream.on('error', (err) => { throw err; });
2525

2626
const size = kStringMaxLength / 200;
2727
const a = Buffer.alloc(size, 'a');
28+
let expectedSize = 0;
2829

2930
for (let i = 0; i < 201; i++) {
30-
stream.write(a);
31+
stream.write(a, (err) => { assert.ifError(err); });
32+
expectedSize += a.length;
3133
}
3234

3335
stream.end();
3436
stream.on('finish', common.mustCall(function() {
37+
assert.strictEqual(stream.bytesWritten, expectedSize,
38+
`${stream.bytesWritten} bytes written (expected ${expectedSize} bytes).`);
3539
fs.readFile(file, 'utf8', common.mustCall(function(err, buf) {
3640
assert.ok(err instanceof Error);
3741
if (err.message !== 'Array buffer allocation failed') {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.