Skip to content

Commit cfcb759

Browse files
Trottaddaleax
authored andcommitted
test: prepare test-hash-seed for CI
Reduce the time it takes to run test/pummel/test-hash-seed by switching from spawnSync() to spawn(). On my computer, this reduces the runtime from about 80 seconds to about 40 seconds. This test is not (yet) run regularly on CI, but when it was run recently, it timed out. PR-URL: #25522 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
1 parent 35240ca commit cfcb759

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

‎test/pummel/test-hash-seed.js‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,30 @@
22

33
// Check that spawn child doesn't create duplicated entries
44
require('../common');
5+
constCountdown=require('../common/countdown');
56
constREPETITIONS=2;
67
constassert=require('assert');
78
constfixtures=require('../common/fixtures');
8-
const{spawnSync}=require('child_process');
9+
const{spawn}=require('child_process');
910
consttargetScript=fixtures.path('guess-hash-seed.js');
1011
constseeds=[];
1112

13+
constrequiredCallback=()=>{
14+
console.log(`Seeds: ${seeds}`);
15+
assert.strictEqual(newSet(seeds).size,seeds.length);
16+
assert.strictEqual(seeds.length,REPETITIONS);
17+
};
18+
19+
constcountdown=newCountdown(REPETITIONS,requiredCallback);
20+
1221
for(leti=0;i<REPETITIONS;++i){
13-
constseed=spawnSync(process.execPath,[targetScript],{
14-
encoding: 'utf8'
15-
}).stdout.trim();
16-
seeds.push(seed);
17-
}
22+
letresult='';
23+
constsubprocess=spawn(process.execPath,[targetScript]);
24+
subprocess.stdout.setEncoding('utf8');
25+
subprocess.stdout.on('data',(data)=>{result+=data;});
1826

19-
console.log(`Seeds: ${seeds}`);
20-
assert.strictEqual(newSet(seeds).size,seeds.length);
27+
subprocess.on('exit',()=>{
28+
seeds.push(result.trim());
29+
countdown.dec();
30+
});
31+
}

0 commit comments

Comments
 (0)