]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When a JS SQLTester script throws, report the exception details back to the UI regard...
authorstephan <stephan@noemail.net>
Wed, 30 Aug 2023 14:20:02 +0000 (14:20 +0000)
committerstephan <stephan@noemail.net>
Wed, 30 Aug 2023 14:20:02 +0000 (14:20 +0000)
FossilOrigin-Name: 273d3b05f630d399d42914e95c416b107b4746bbef129cfba9d00fd921666261

ext/wasm/SQLTester/SQLTester.mjs
ext/wasm/SQLTester/SQLTester.run.mjs
ext/wasm/SQLTester/index.html
manifest
manifest.uuid

index 895c6461167b595111fb5344f7ed27f6daae7656..8741b81524e7ad46da599dc00dcda87b61dcd82d 100644 (file)
@@ -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
                    : ""
                )
               );
index 4a089045921d2c3fdc99f6b91eab6c1ea03d389d..0f91230fd082b10eda9b06a58a9349d0adac499a 100644 (file)
@@ -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:
index ebd828c645164e37e927d0e8cca4a13d16c1f05d..cd1423ac372f112bc27a0560ef4c7e55a9d32c6a 100644 (file)
@@ -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(){
         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);
index 9dffaa6607c752e53e4ea49163e2aa6c66af8549..0e6f1ff0762b9f4e0f6f8cc304c018deb49e95f0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\sJS\simplementation\sof\sJava's\sSQLTester.
-D 2023-08-30T13:07:35.058
+C When\sa\sJS\sSQLTester\sscript\sthrows,\sreport\sthe\sexception\sdetails\sback\sto\sthe\sUI\sregardless\sof\swhether\sit's\sfatal.
+D 2023-08-30T14:20:02.025
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -549,9 +549,9 @@ F ext/wasm/GNUmakefile 0e362f3fc04eab6628cbe4f1e35f4ab4a200881f6b5f753b27fb45eab
 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576
 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193
 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
-F ext/wasm/SQLTester/SQLTester.mjs 4a8fc2194a67180772830f503129c93fe44887b9573f50a4e24868b4bbc817f4
-F ext/wasm/SQLTester/SQLTester.run.mjs a50a1f9314d22d68b62a2f21d8913de163fce1fa420229711d6749c2b4fff9d0
-F ext/wasm/SQLTester/index.html e5f18af71749d81d86e4649d8c6efc9b78361738cb8e5c5014ba0dd3dc3de6ac
+F ext/wasm/SQLTester/SQLTester.mjs 20309ff838209601711087932b008734bab00176e6a47e41d95e11f6d363bae0
+F ext/wasm/SQLTester/SQLTester.run.mjs addeb962f33fb6bca723ab12f0b018303ff962dfc57ee969d051fcbf4f191569
+F ext/wasm/SQLTester/index.html 3a12895015c165281307eb47786ce3c46b3c3f06383ad6a9fe3a8526105632f1
 F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536
 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api d6a5078f48a5301ed17b9a30331075d9b2506e1360c1f0dee0c7816c10acd9ab
 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b
@@ -2115,9 +2115,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 058722b2d0b995195a8ce3effe9722ae1c18cb1e7a520b481030da0bd579fe41 249e82b9917ea47c56ee1cbd3345a977d335fd3fc0d67a1ef157813ef4571c7c
-R 1d37ca9b2e6614cb5d02f3816f204e9d
-T +closed 249e82b9917ea47c56ee1cbd3345a977d335fd3fc0d67a1ef157813ef4571c7c Closed\sby\sintegrate-merge.
+P b530792a514d95c4e8f93cf2170d9fc4de367055fa1704fc171551c946024fa9
+R 27c4b366fbb2810d013255774a7479ce
 U stephan
-Z 4d7d0ed957593edddd1409081f78edf6
+Z 3efc7b20eec1af6f89785f42be992e20
 # Remove this line to create a well-formed Fossil manifest.
index 0edb46a8699e7582bfd5e2037a78ace9e260a83f..def26b8ea3fa1dd7a12b0172cacaaecb98921aeb 100644 (file)
@@ -1 +1 @@
-b530792a514d95c4e8f93cf2170d9fc4de367055fa1704fc171551c946024fa9
\ No newline at end of file
+273d3b05f630d399d42914e95c416b107b4746bbef129cfba9d00fd921666261
\ No newline at end of file