Skip to content

Commit bb6787c

Browse 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 <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent bb5511e commit bb6787c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

+5-1
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)