diff options
Diffstat (limited to 'ext/wasm/tests/opfs/concurrency')
-rw-r--r-- | ext/wasm/tests/opfs/concurrency/test.js | 24 | ||||
-rw-r--r-- | ext/wasm/tests/opfs/concurrency/worker.js | 12 |
2 files changed, 23 insertions, 13 deletions
diff --git a/ext/wasm/tests/opfs/concurrency/test.js b/ext/wasm/tests/opfs/concurrency/test.js index d045f3271..b80dad24c 100644 --- a/ext/wasm/tests/opfs/concurrency/test.js +++ b/ext/wasm/tests/opfs/concurrency/test.js @@ -1,6 +1,6 @@ (async function(self){ - const logClass = (function(){ + const logCss = (function(){ const mapToString = (v)=>{ switch(typeof v){ case 'number': case 'string': case 'boolean': @@ -20,7 +20,7 @@ }; const normalizeArgs = (args)=>args.map(mapToString); const logTarget = document.querySelector('#test-output'); - const logClass = function(cssClass,...args){ + const logCss = function(cssClass,...args){ const ln = document.createElement('div'); if(cssClass){ for(const c of (Array.isArray(cssClass) ? cssClass : [cssClass])){ @@ -41,10 +41,10 @@ cbReverse.checked = !!(+localStorage.getItem(cbReverseKey)); } cbReverseIt(); - return logClass; + return logCss; })(); - const stdout = (...args)=>logClass('',...args); - const stderr = (...args)=>logClass('error',...args); + const stdout = (...args)=>logCss('',...args); + const stderr = (...args)=>logCss('error',...args); const wait = async (ms)=>{ return new Promise((resolve)=>setTimeout(resolve,ms)); @@ -67,9 +67,6 @@ const wName = msg.worker; const prefix = 'Worker ['+wName+']:'; switch(msg.type){ - case 'stdout': stdout(prefix,...msg.payload); break; - case 'stderr': stderr(prefix,...msg.payload); break; - case 'error': stderr(prefix,"ERROR:",...msg.payload); break; case 'loaded': stdout(prefix,"loaded"); if(++workers.loadedCount === workers.length){ @@ -77,7 +74,16 @@ workers.post('run'); } break; - default: logClass('error',"Unhandled message type:",msg); break; + case 'stdout': stdout(prefix,...msg.payload); break; + case 'stderr': stderr(prefix,...msg.payload); break; + case 'error': stderr(prefix,"ERROR:",...msg.payload); break; + case 'finished': + logCss('tests-pass',prefix,...msg.payload); + break; + case 'failed': + logCss('tests-fail',prefix,"FAILED:",...msg.payload); + break; + default: logCss('error',"Unhandled message type:",msg); break; } }; diff --git a/ext/wasm/tests/opfs/concurrency/worker.js b/ext/wasm/tests/opfs/concurrency/worker.js index 7ba15bf8c..9aaa2f4c7 100644 --- a/ext/wasm/tests/opfs/concurrency/worker.js +++ b/ext/wasm/tests/opfs/concurrency/worker.js @@ -26,7 +26,7 @@ self.sqlite3InitModule().then(async function(sqlite3){ wPost('loaded'); const run = async function(){ - const db = new sqlite3.opfs.OpfsDb(dbName); + const db = new sqlite3.opfs.OpfsDb(dbName,'c'); //sqlite3.capi.sqlite3_busy_timeout(db.pointer, 2000); db.transaction((db)=>{ db.exec([ @@ -37,7 +37,7 @@ self.sqlite3InitModule().then(async function(sqlite3){ const maxIterations = 10; const interval = Object.assign(Object.create(null),{ - delay: 300, + delay: 500, handle: undefined, count: 0 }); @@ -58,9 +58,13 @@ self.sqlite3InitModule().then(async function(sqlite3){ } }; const finish = ()=>{ - if(interval.error) stderr("Ending work due to error:",e.message); - else stdout("Ending work after",interval.count,"interval(s)"); db.close(); + if(interval.error){ + wPost('failed',"Ending work after interval #"+interval.count, + "due to error:",interval.error); + }else{ + wPost('finished',"Ending work after",interval.count,"intervals."); + } }; if(1){/*use setInterval()*/ interval.handle = setInterval(async ()=>{ |