From 409b8cbdfcc8113bff066a72ebb021acf4a708f7 Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 13 May 2024 17:56:48 +0200 Subject: [PATCH] runapptests - Replaces sleep command by time jump on emulator --- bin/runapptests.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/runapptests.js b/bin/runapptests.js index da172259e..8187d869d 100755 --- a/bin/runapptests.js +++ b/bin/runapptests.js @@ -312,12 +312,16 @@ function runStep(step, subtest, test, state){ case "sleep" : p = p.then(()=>{ console.log("> SLEEP FOR", step.ms); - return new Promise(resolve => { - setTimeout(()=>{ - if (verbose) console.log("> SLEPT FOR", step.ms); - resolve(); - }, step.ms); - }) + if (!subtest.wrappedDateNow){ + emu.tx(`Date.now = (o)=>{return ()=>{ + return o() + global.APPTESTS.timeOffset; + };}(Date.now);\n`); + 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; case "upload" :