Skip to content

Commit d94b184

Browse files
lpincaRafaelGSS
authored andcommitted
test: deflake test-buffer-large-size-buffer-alloc
Use the error message as another condition to skip the test when the buffer allocation fails. Refs: 795dd8eb7988ae38553e Refs: e9c6004a2d580008082b PR-URL: #58734 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
1 parent 7bb1246 commit d94b184

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎test/pummel/test-buffer-large-size-buffer-alloc.js‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@ common.skipIf32Bits();
77
constassert=require('node:assert');
88
constsize=2**31;
99

10+
letlargeBuffer;
11+
1012
// Test Buffer.alloc with size larger than integer range
1113
try{
12-
assert.throws(()=>Buffer.alloc(size).toString('utf8'),{code: 'ERR_STRING_TOO_LONG'});
14+
largeBuffer=Buffer.alloc(size);
1315
}catch(e){
14-
if(e.code!=='ERR_MEMORY_ALLOCATION_FAILED'){
15-
throwe;
16+
if(
17+
e.code==='ERR_MEMORY_ALLOCATION_FAILED'||
18+
/Arraybufferallocationfailed/.test(e.message)
19+
){
20+
common.skip('insufficient space for Buffer.alloc');
1621
}
17-
common.skip('insufficient space for Buffer.alloc');
22+
23+
throwe;
1824
}
25+
26+
assert.throws(()=>largeBuffer.toString('utf8'),{
27+
code: 'ERR_STRING_TOO_LONG',
28+
});

0 commit comments

Comments
 (0)