diff options
Diffstat (limited to 'ext/wasm/SQLTester')
-rw-r--r-- | ext/wasm/SQLTester/SQLTester.mjs | 18 | ||||
-rw-r--r-- | ext/wasm/SQLTester/SQLTester.run.mjs | 4 | ||||
-rw-r--r-- | ext/wasm/SQLTester/index.html | 9 |
3 files changed, 19 insertions, 12 deletions
diff --git a/ext/wasm/SQLTester/SQLTester.mjs b/ext/wasm/SQLTester/SQLTester.mjs index 895c64611..8741b8152 100644 --- a/ext/wasm/SQLTester/SQLTester.mjs +++ b/ext/wasm/SQLTester/SQLTester.mjs @@ -147,6 +147,7 @@ class UnknownCommand extends SQLTesterException { super(testScript, cmdName); this.name = 'UnknownCommand'; } + isFatal() { return true; } } class IncompatibleDirective extends SQLTesterException { @@ -290,10 +291,10 @@ class SQLTester { nTotalTest: 0, //! Total test script files run nTestFile: 0, - //! Number of scripts which were aborted - nAbortedScript: 0, //! Test-case count for to the current TestScript - nTest: 0 + nTest: 0, + //! Names of scripts which were aborted. + failedScripts: [] }); #emitColNames = false; //! True to keep going regardless of how a test fails. @@ -511,8 +512,9 @@ class SQLTester { runTests(){ const tStart = (new Date()).getTime(); let isVerbose = this.verbosity(); - this.metrics.nAbortedScript = 0; + this.metrics.failedScripts.length = 0; this.metrics.nTotalTest = 0; + this.metrics.nTestFile = 0; for(const ts of this.#aScripts){ this.reset(); ++this.metrics.nTestFile; @@ -525,7 +527,7 @@ class SQLTester { if(e instanceof SQLTesterException){ threw = true; this.outln("🔥EXCEPTION: ",e); - ++this.metrics.nAbortedScript; + this.metrics.failedScripts.push({script: ts.filename(), message:e.toString()}); if( this.#keepGoing ){ this.outln("Continuing anyway because of the keep-going option."); }else if( e.isFatal() ){ @@ -548,11 +550,11 @@ class SQLTester { } const tEnd = (new Date()).getTime(); Util.unlink(this.#db.initialDbName); - this.outln("Took ",(tEnd-tStart),"ms. test count = ", + this.outln("Took ",(tEnd-tStart),"ms. Test count = ", this.metrics.nTotalTest,", script count = ", this.#aScripts.length,( - this.metrics.nAbortedScript - ? ", aborted scripts = "+this.metrics.nAbortedScript + this.metrics.failedScripts.length + ? ", failed scripts = "+this.metrics.failedScripts.length : "" ) ); diff --git a/ext/wasm/SQLTester/SQLTester.run.mjs b/ext/wasm/SQLTester/SQLTester.run.mjs index 4a0890459..0f91230fd 100644 --- a/ext/wasm/SQLTester/SQLTester.run.mjs +++ b/ext/wasm/SQLTester/SQLTester.run.mjs @@ -63,6 +63,7 @@ SELECT 1, null; SELECT 1, 2; intentional error; --run +/* ---intentional-failure */ --testcase json-1 SELECT json_array(1,2,3) --json [1,2,3] @@ -96,6 +97,7 @@ const sqt = new ns.SQLTester() .setLogger(console.log.bind(console)) .verbosity(1) .addTestScript(ts); +sqt.outer().outputPrefix(''); const runTests = function(){ try{ @@ -127,7 +129,7 @@ if( globalThis.WorkerGlobalScope ){ switch(data.type){ case 'run-tests':{ try{ runTests(); } - finally{ wPost('tests-end'); } + finally{ wPost('tests-end', sqt.metrics); } break; } default: diff --git a/ext/wasm/SQLTester/index.html b/ext/wasm/SQLTester/index.html index ebd828c64..cd1423ac3 100644 --- a/ext/wasm/SQLTester/index.html +++ b/ext/wasm/SQLTester/index.html @@ -33,7 +33,7 @@ </span> <input type='button' id='btn-run-tests' value='Run tests'/> </fieldset> - <div id='test-output'></div> + <div id='test-output'>Test output will go here.</div> <!--script src='SQLTester.run.mjs' type='module'></script--> <script> (async function(){ @@ -99,9 +99,12 @@ W.onmessage = function({data}){ switch(data.type){ case 'stdout': log2(data.payload.message); break; - case 'tests-end': btnRun.removeAttribute('disabled'); break; + case 'tests-end': + btnRun.removeAttribute('disabled'); + delete data.payload.nTest; + log("test results:",data.payload); + break; case 'is-ready': - log("SQLTester.run.mjs is ready."); runTests(); break; default: log("unhandled onmessage",data); |