]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Further tweaking in both SQLTesters.
authorstephan <stephan@noemail.net>
Wed, 30 Aug 2023 15:51:42 +0000 (15:51 +0000)
committerstephan <stephan@noemail.net>
Wed, 30 Aug 2023 15:51:42 +0000 (15:51 +0000)
FossilOrigin-Name: 46b0eb98e7a56cc188836c46f4289de6281f80e6bc6eb33e0aa9133a0f86f00c

ext/jni/src/org/sqlite/jni/tester/SQLTester.java
ext/jni/src/tests/000-000-sanity.test
ext/wasm/SQLTester/SQLTester.mjs
ext/wasm/SQLTester/SQLTester.run.mjs
manifest
manifest.uuid

index 47d6b6f3ef4bb1d6519b58937d31d699462f505e..517d8c30a5d94a166d8bb24996c6b597606886e4 100644 (file)
@@ -475,12 +475,12 @@ public class SQLTester {
      the db's result code.
 
      appendMode specifies how/whether to append results to the result
-     buffer. lineMode specifies whether to output all results in a
+     buffer. rowMode specifies whether to output all results in a
      single line or one line per row. If appendMode is
-     ResultBufferMode.NONE then lineMode is ignored and may be null.
+     ResultBufferMode.NONE then rowMode is ignored and may be null.
   */
   public int execSql(sqlite3 db, boolean throwOnError,
-                     ResultBufferMode appendMode, ResultRowMode lineMode,
+                     ResultBufferMode appendMode, ResultRowMode rowMode,
                      String sql) throws SQLTesterException {
     if( null==db && null==aDb[0] ){
       // Delay opening of the initial db to enable tests to change its
@@ -562,7 +562,7 @@ public class SQLTester {
                   throw new SQLTesterException("Unhandled ResultBufferMode: "+appendMode);
               }
             }
-            if( ResultRowMode.NEWLINE == lineMode ){
+            if( ResultRowMode.NEWLINE == rowMode ){
               spacing = 0;
               sb.append('\n');
             }
@@ -1128,8 +1128,9 @@ class TestScript {
   }
 
   public String getOutputPrefix(){
-    String rc =  "["+(moduleName==null ? filename : moduleName)+"]";
+    String rc = "["+(moduleName==null ? "<unnamed>" : moduleName)+"]";
     if( null!=testCaseName ) rc += "["+testCaseName+"]";
+    if( null!=filename ) rc += "["+filename+"]";
     return rc + " line "+ cur.lineNo;
   }
 
@@ -1273,6 +1274,7 @@ class TestScript {
   }
 
   private boolean checkRequiredProperties(SQLTester t, String[] props) throws SQLTesterException{
+    if( true ) return false;
     int nOk = 0;
     for(String rp : props){
       verbose1("REQUIRED_PROPERTIES: ",rp);
@@ -1293,6 +1295,12 @@ class TestScript {
           t.appendDbInitSql("pragma temp_store=0;");
           ++nOk;
           break;
+        case "AUTOVACUUM":
+          t.appendDbInitSql("pragma auto_vacuum=full;");
+          ++nOk;
+        case "INCRVACUUM":
+          t.appendDbInitSql("pragma auto_vacuum=incremental;");
+          ++nOk;
         default:
           break;
       }
@@ -1331,9 +1339,9 @@ class TestScript {
     m = patternRequiredProperties.matcher(line);
     if( m.find() ){
       final String rp = m.group(1);
-      //if( ! checkRequiredProperties( tester, rp.split("\\s+") ) ){
-      throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp);
-      //}
+      if( ! checkRequiredProperties( tester, rp.split("\\s+") ) ){
+        throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp);
+      }
     }
     m = patternMixedModuleName.matcher(line);
     if( m.find() ){
index 2bfacb1cecc157d807dc99d6bd32ff148dbf7f43..4ccbece31c3ae6c64d119756558ae49fefcd15b5 100644 (file)
@@ -6,7 +6,8 @@
 ** xMODULE_NAME:             module-name
 ** xREQUIRED_PROPERTIES:      small fast reliable
 ** xREQUIRED_PROPERTIES:      RECURSIVE_TRIGGERS
-** xREQUIRED_PROPERTIES:      TEMPSTORE_MEM  TEMPSTORE_FILE
+** xREQUIRED_PROPERTIES:      TEMPSTORE_FILE TEMPSTORE_MEM
+** xREQUIRED_PROPERTIES:      AUTOVACUUM INCRVACUUM
 **
 */
 --print starting up ðŸ˜ƒ
index 8741b81524e7ad46da599dc00dcda87b61dcd82d..a72399aefcd5659d269286843feed839f0d58b33 100644 (file)
@@ -112,12 +112,6 @@ class SQLTesterException extends globalThis.Error {
     }
     this.name = 'SQLTesterException';
   }
-  /**
-     If this overrideable method returns false (the default) then
-     exceptions of that type are fatal to a whole test run, instead of
-     just the test which triggered it. If the the "keep going" flag
-     is set, this preference is ignored.
-  */
   isFatal() { return false; }
 }
 
@@ -169,6 +163,7 @@ const __SAB = ('undefined'===typeof globalThis.SharedArrayBuffer)
       ? function(){} : globalThis.SharedArrayBuffer;
 
 
+/* Frequently-reused regexes. */
 const Rx = newObj({
   requiredProperties: / REQUIRED_PROPERTIES:[ \t]*(\S.*)\s*$/,
   scriptModuleName: / SCRIPT_MODULE_NAME:[ \t]*(\S+)\s*$/,
@@ -176,7 +171,6 @@ const Rx = newObj({
   command: /^--(([a-z-]+)( .*)?)$/,
   //! "Special" characters - we have to escape output if it contains any.
   special: /[\x00-\x20\x22\x5c\x7b\x7d]/,
-  //! Either of '{' or '}'.
   squiggly: /[{}]/
 });
 
@@ -189,7 +183,7 @@ const Util = newObj({
 
   argvToString: (list)=>{
     const m = [...list];
-    m.shift();
+    m.shift() /* strip command name */;
     return m.join(" ")
   },
 
@@ -257,9 +251,10 @@ class Outer {
     }
   }
 
+  static #verboseLabel = ["🔈",/*"🔉",*/"🔊","📢"];
   verboseN(lvl, args){
     if( this.#verbosity>=lvl ){
-      this.#outlnImpl(lvl,'VERBOSE ',lvl,': ',...args);
+      this.#outlnImpl(lvl, Outer.#verboseLabel[lvl-1],': ',...args);
     }
   }
   verbose1(...args){ return this.verboseN(1,args); }
@@ -364,8 +359,24 @@ class SQLTester {
     this.#resultBuffer.push(line);
     if( addNL ) this.#resultBuffer.push('\n');
   }
+  appendDbInitSql(sql){
+    this.#db.initSql.push(sql);
+    if( this.currentDb() ){
+      this.execSql(null, true, ResultBufferMode.NONE, null, sql);
+    }
+  }
+
+  #runInitSql(pDb){
+    let rc = 0;
+    for(const sql of this.#db.initSql){
+      this.#outer.verbose2("RUNNING DB INIT CODE: ",sql);
+      rc = this.execSql(pDb, false, ResultBufferMode.NONE, null, sql);
+      if( rc ) break;
+    }
+    return rc;
+  }
 
-  #clearBuffer(buffer){
+#clearBuffer(buffer){
     buffer.length = 0;
     return buffer;
   }
@@ -390,27 +401,21 @@ class SQLTester {
   }
 
   nullValue(){
-    if( 0==arguments.length ){
-      return this.#nullView;
-    }else{
-      this.#nullView = ''+arguments[0];
-    }
+    return (0==arguments.length)
+      ? this.#nullView
+      : (this.#nullView = ''+arguments[0]);
   }
 
   outputColumnNames(){
-    if( 0==arguments.length ){
-      return this.#emitColNames;
-    }else{
-      this.#emitColNames = !!arguments[0];
-    }
+    return (0==arguments.length)
+      ? this.#emitColNames
+      : (this.#emitColNames = !!arguments[0]);
   }
 
   currentDbId(){
-    if( 0==arguments.length ){
-      return this.#db.iCurrentDb;
-    }else{
-      this.#affirmDbId(arguments[0]).#db.iCurrentDb = arguments[0];
-    }
+    return (0==arguments.length)
+      ? this.#db.iCurrentDb
+      : (this.#affirmDbId(arguments[0]).#db.iCurrentDb = arguments[0]);
   }
 
   #affirmDbId(id){
@@ -438,9 +443,9 @@ class SQLTester {
     if( 0==arguments.length ){
       id = this.#db.iCurrentDb;
     }
-    const db = this.#affirmDbId(id).#db.list[id];
-    if( db ){
-      sqlite3.capi.sqlite3_close_v2(db);
+    const pDb = this.#affirmDbId(id).#db.list[id];
+    if( pDb ){
+      sqlite3.capi.sqlite3_close_v2(pDb);
       this.#db.list[id] = null;
     }
   }
@@ -474,10 +479,9 @@ class SQLTester {
         rc = sqlite3.capi.sqlite3_open_v2(name, ppOut, flags, null);
         pDb = wasm.peekPtr(ppOut);
       });
+      let sql;
       if( 0==rc && this.#db.initSql.length > 0){
-        this.#outer.verbose2("RUNNING DB INIT CODE: ",this.#db.initSql.toString());
-        rc = this.execSql(pDb, false, ResultBufferMode.NONE,
-                          null, this.#db.initSql.join(''));
+        rc = this.#runInitSql(pDb);
       }
       if( 0!=rc ){
         sqlite3.SQLite3Error.toss(
@@ -613,7 +617,7 @@ class SQLTester {
     sqlite3.oo1.DB.checkRc(pDb, rc);
   }
 
-  execSql(pDb, throwOnError, appendMode, lineMode, sql){
+  execSql(pDb, throwOnError, appendMode, rowMode, sql){
     if( !pDb && !this.#db.list[0] ){
       this.#setupInitialDb();
     }
@@ -685,7 +689,7 @@ class SQLTester {
               }
             }/* column loop */
           }/* row loop */
-          if( ResultRowMode.NEWLINE === lineMode ){
+          if( ResultRowMode.NEWLINE === rowMode ){
             spacing = 0;
             sb.push('\n');
           }
@@ -806,8 +810,9 @@ class TestScript {
   }
 
   getOutputPrefix() {
-    let rc =  "["+(this.#moduleName || this.#filename)+"]";
+    let rc =  "["+(this.#moduleName || '<unnamed>')+"]";
     if( this.#testCaseName ) rc += "["+this.#testCaseName+"]";
+    if( this.#filename ) rc += '['+this.#filename+']';
     return rc + " line "+ this.#cursor.lineNo;
   }
 
@@ -829,6 +834,42 @@ class TestScript {
     return args.length ? this : rc;
   }
 
+  #checkRequiredProperties(tester, props){
+    if(true) return false;
+    let nOk = 0;
+    for(const rp of props){
+      this.verbose2("REQUIRED_PROPERTIES: ",rp);
+      switch(rp){
+        case "RECURSIVE_TRIGGERS":
+          tester.appendDbInitSql("pragma recursive_triggers=on;");
+          ++nOk;
+          break;
+        case "TEMPSTORE_FILE":
+          /* This _assumes_ that the lib is built with SQLITE_TEMP_STORE=1 or 2,
+             which we just happen to know is the case */
+          tester.appendDbInitSql("pragma temp_store=1;");
+          ++nOk;
+          break;
+        case "TEMPSTORE_MEM":
+          /* This _assumes_ that the lib is built with SQLITE_TEMP_STORE=1 or 2,
+             which we just happen to know is the case */
+          tester.appendDbInitSql("pragma temp_store=0;");
+          ++nOk;
+          break;
+        case "AUTOVACUUM":
+          tester.appendDbInitSql("pragma auto_vacuum=full;");
+          ++nOk;
+          break;
+        case "INCRVACUUM":
+          tester.appendDbInitSql("pragma auto_vacuum=incremental;");
+          ++nOk;
+        default:
+          break;
+      }
+    }
+    return props.length == nOk;
+  }
+
   #checkForDirective(tester,line){
     if(line.startsWith("#")){
       throw new IncompatibleDirective(this, "C-preprocessor input: "+line);
@@ -843,9 +884,9 @@ class TestScript {
     m = Rx.requiredProperties.exec(line);
     if( m ){
       const rp = m[1];
-      //if( ! checkRequiredProperties( tester, rp.split("\\s+") ) ){
-      throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp);
-      //}
+      if( !this.#checkRequiredProperties( tester, rp.split(/\s+/).filter(v=>!!v) ) ){
+        throw new IncompatibleDirective(this, "REQUIRED_PROPERTIES: "+rp);
+      }
     }
 
     m = Rx.mixedModuleName.exec(line);
index 0f91230fd082b10eda9b06a58a9349d0adac499a..735fe4dcd8b0f8f4e6fdcfab20b0c2f40d7b47e0 100644 (file)
@@ -42,7 +42,8 @@ let ts = new ns.TestScript('/foo.test',`
 ** xMODULE_NAME:             module-name
 ** xREQUIRED_PROPERTIES:      small fast reliable
 ** xREQUIRED_PROPERTIES:      RECURSIVE_TRIGGERS
-** xREQUIRED_PROPERTIES:      TEMPSTORE_MEM  TEMPSTORE_FILE
+** xREQUIRED_PROPERTIES:      TEMPSTORE_FILE TEMPSTORE_MEM
+** xREQUIRED_PROPERTIES:      AUTOVACUUM INCRVACUUM
 **
 */
 /* --verbosity 3 */
index 0e6f1ff0762b9f4e0f6f8cc304c018deb49e95f0..c4c6ebf281969d75cbf3ebfa31b731fbbf79d9bf 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-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
+C Further\stweaking\sin\sboth\sSQLTesters.
+D 2023-08-30T15:51:42.969
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -283,9 +283,9 @@ F ext/jni/src/org/sqlite/jni/sqlite3.java 62b1b81935ccf3393472d17cb883dc5ff39c38
 F ext/jni/src/org/sqlite/jni/sqlite3_context.java 66ca95ce904044263a4aff684abe262d56f73e6b06bca6cf650761d79d7779ad
 F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 78e6d1b95ac600a9475e9db4623f69449322b0c93d1bd4e1616e76ed547ed9fc
 F ext/jni/src/org/sqlite/jni/sqlite3_value.java 3d1d4903e267bc0bc81d57d21f5e85978eff389a1a6ed46726dbe75f85e6914a
-F ext/jni/src/org/sqlite/jni/tester/SQLTester.java e5a1a4b55ed940e61558be1292aa66563219f360c7c1f9d40d770307e6da3c07
+F ext/jni/src/org/sqlite/jni/tester/SQLTester.java a6863d0284c8ec8ca5abd3d40e1fb297e7ae57fb97282ba335cd896a770e3918
 F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e
-F ext/jni/src/tests/000-000-sanity.test cfe6dc1b950751d6096e3f5695becaadcdaa048bfe9567209d6eb676e693366d
+F ext/jni/src/tests/000-000-sanity.test c3427a0e0ac84d7cbe4c95fdc1cd4b61f9ddcf43443408f3000139478c4dc745
 F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70
 F ext/jni/src/tests/900-001-fts.test bf0ce17a8d082773450e91f2388f5bbb2dfa316d0b676c313c637a91198090f0
 F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9
@@ -549,8 +549,8 @@ 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 20309ff838209601711087932b008734bab00176e6a47e41d95e11f6d363bae0
-F ext/wasm/SQLTester/SQLTester.run.mjs addeb962f33fb6bca723ab12f0b018303ff962dfc57ee969d051fcbf4f191569
+F ext/wasm/SQLTester/SQLTester.mjs ec2f6ba63a0f2f0562941a0fb8e46b7dc55589711513f1952349785966edfe50
+F ext/wasm/SQLTester/SQLTester.run.mjs c72b7fe2072d05992f7a3d8c6a1d34e95712513ceabe40849784e24e41c84638
 F ext/wasm/SQLTester/index.html 3a12895015c165281307eb47786ce3c46b3c3f06383ad6a9fe3a8526105632f1
 F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536
 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api d6a5078f48a5301ed17b9a30331075d9b2506e1360c1f0dee0c7816c10acd9ab
@@ -2115,8 +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 b530792a514d95c4e8f93cf2170d9fc4de367055fa1704fc171551c946024fa9
-R 27c4b366fbb2810d013255774a7479ce
+P 273d3b05f630d399d42914e95c416b107b4746bbef129cfba9d00fd921666261
+R 137dd20583c129ec3973659fafa81f04
 U stephan
-Z 3efc7b20eec1af6f89785f42be992e20
+Z b64a49daabb87406caca79373e21eb07
 # Remove this line to create a well-formed Fossil manifest.
index def26b8ea3fa1dd7a12b0172cacaaecb98921aeb..78b047a2724ad95955dece7522c63479c27afcfa 100644 (file)
@@ -1 +1 @@
-273d3b05f630d399d42914e95c416b107b4746bbef129cfba9d00fd921666261
\ No newline at end of file
+46b0eb98e7a56cc188836c46f4289de6281f80e6bc6eb33e0aa9133a0f86f00c
\ No newline at end of file