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 <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

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines 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
constsize=kStringMaxLength/200;
2727
consta=Buffer.alloc(size,'a');
28+
letexpectedSize=0;
2829

2930
for(leti=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(errinstanceofError);
3741
if(err.message!=='Array buffer allocation failed'){

0 commit comments

Comments
 (0)