runapptests - Allow running setup steps

master
Martin Boonk 2024-05-03 23:38:10 +02:00
parent d29876cb7d
commit c66199c76b
1 changed files with 68 additions and 58 deletions

View File

@ -144,30 +144,13 @@ function assertCall(step){
assertFail(step.text)
}
function runTest(test) {
var app = apploader.apps.find(a=>a.id==test.app);
if (!app) ERROR(`App ${JSON.stringify(test.app)} not found`);
if (app.custom) ERROR(`App ${JSON.stringify(appId)} requires HTML customisation`);
return apploader.getAppFilesString(app).then(command => {
console.log("Handling command", command);
// What about dependencies??
test.tests.forEach((subtest,subtestIdx) => {
console.log(`==============================`);
console.log(`"${test.app}" Test ${subtestIdx}`);
if (test.description)
console.log(`"${test.description}`);
console.log(`==============================`);
emu.factoryReset();
console.log("> Sending app "+test.app);
emu.tx(command);
console.log("> Sent app");
emu.tx("reset()\n");
console.log("> Reset.");
var ok = true;
subtest.steps.forEach(step => {
if (ok) switch(step.t) {
function runStep(step, subtest, test, state){
if (state.ok) switch(step.t) {
case "setup" :
test.setup.filter(e=>e.id==step.id)[0].steps.forEach(setupStep=>{
runStep(setupStep, subtest, test, state);
});
break;
case "load" :
console.log(`> Loading file "${step.fn}"`);
emu.tx(`load(${JSON.stringify(step.fn)})\n`);
@ -189,7 +172,7 @@ function runTest(test) {
console.log("> GOT "+result);
if (result!=expected) {
console.log("> FAIL: EXPECTED "+expected);
ok = false;
state.ok = false;
}
break;
// tap/touch/drag/button press
@ -217,12 +200,39 @@ function runTest(test) {
console.log("> CURRENT MEMORY USAGE", memUsage);
if (subtest.memUsage != memUsage ) {
console.log("> FAIL: EXPECTED MEMORY USAGE OF "+subtest.memUsage);
ok = false;
state.ok = false;
}
break;
default: ERROR("Unknown step type "+step.t);
}
emu.idle();
}
function runTest(test) {
var app = apploader.apps.find(a=>a.id==test.app);
if (!app) ERROR(`App ${JSON.stringify(test.app)} not found`);
if (app.custom) ERROR(`App ${JSON.stringify(appId)} requires HTML customisation`);
return apploader.getAppFilesString(app).then(command => {
console.log("Handling command", command);
// What about dependencies??
test.tests.forEach((subtest,subtestIdx) => {
console.log(`==============================`);
console.log(`"${test.app}" Test ${subtestIdx}`);
if (test.description)
console.log(`"${test.description}`);
console.log(`==============================`);
emu.factoryReset();
console.log("> Sending app "+test.app);
emu.tx(command);
console.log("> Sent app");
emu.tx("reset()\n");
console.log("> Reset");
var state = { ok: true};
subtest.steps.forEach(step => {
runStep(step, subtest, test, state)
});
});
emu.stopIdle();