runapptests - Replaces sleep command by time jump on emulator

master
Martin Boonk 2024-05-13 17:56:48 +02:00
parent e248235e84
commit 409b8cbdfc
1 changed files with 10 additions and 6 deletions

View File

@ -312,12 +312,16 @@ function runStep(step, subtest, test, state){
case "sleep" : case "sleep" :
p = p.then(()=>{ p = p.then(()=>{
console.log("> SLEEP FOR", step.ms); console.log("> SLEEP FOR", step.ms);
return new Promise(resolve => { if (!subtest.wrappedDateNow){
setTimeout(()=>{ emu.tx(`Date.now = (o)=>{return ()=>{
if (verbose) console.log("> SLEPT FOR", step.ms); return o() + global.APPTESTS.timeOffset;
resolve(); };}(Date.now);\n`);
}, step.ms); subtest.wrappedDateNow = true;
}) }
emu.tx(`global.APPTESTS.timeOffset += ${step.ms};
for(let c of global["\xff"].timers){
if(c) c.time -= ${step.ms * 1000};
}\n`);
}); });
break; break;
case "upload" : case "upload" :