]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
SQLTester now ignores tests which contain constructs specified in the spec doc.
authorstephan <stephan@noemail.net>
Mon, 7 Aug 2023 23:04:17 +0000 (23:04 +0000)
committerstephan <stephan@noemail.net>
Mon, 7 Aug 2023 23:04:17 +0000 (23:04 +0000)
FossilOrigin-Name: ecaeee652aa2cc6893ded9231d7e9b2783465516016740b307b74e4e81598ae3

ext/jni/src/org/sqlite/jni/tester/SQLTester.java
ext/jni/src/org/sqlite/jni/tester/TestScript.java
ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md
ext/jni/src/tests/010_ignored.test [new file with mode: 0644]
manifest
manifest.uuid

index 69c122da25fb165f5ac0a2ffc1a39628ef7e5f21..43591228219c500d3de4e350cd2ade2959850f0d 100644 (file)
@@ -36,9 +36,9 @@ public class SQLTester {
   public void runTests() throws Exception {
     // process each input file
     for(String f : listInFiles){
-      verbose("Running test script",f);
       final TestScript ts = new TestScript(f);
       ts.setVerbose(this.outer.getVerbose());
+      verbose("Test",ts.getName(),"...");
       ts.dump();
     }
   }
index a415b917a9dc340ab5e65f7f43033a7cd704b44c..b4f8ec28be38ed6b5cd2603319ca6b9382ba548d 100644 (file)
@@ -14,30 +14,48 @@ import java.util.regex.*;
 */
 public class TestScript {
   //! Test script content.
+  private String name;
   private String content;
+  private List<String> chunks = null;
   private final Outer outer = new Outer();
+  private boolean ignored = false;
 
-  private byte[] readFile(String filename) throws IOException {
+  private byte[] readFile(String filename) throws Exception {
     return java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(filename));
   }
 
   private void setContent(String c){
     content = c;
+    ignored = shouldBeIgnored(c);
+    chunks = chunkContent();
   }
   /**
      Initializes the script with the content of the given file.
   */
-  public TestScript(String filename) throws IOException{
+  public TestScript(String filename) throws Exception{
     setContent(new String(readFile(filename),
                           java.nio.charset.StandardCharsets.UTF_8));
+    name = filename;
   }
 
   /**
-     Initializes the script with the given content, copied
-     at construction-time.
+     Initializes the script with the given content, copied at
+     construction-time. The first argument is a filename for that
+     content. It need not refer to a real file - it's for display
+     purposes only.
   */
-  public TestScript(StringBuffer content){
+  public TestScript(String virtualName, StringBuffer content)
+    throws RuntimeException {
     setContent(content.toString());
+    name = virtualName;
+  }
+
+  public String getName(){
+    return name;
+  }
+
+  public boolean isIgnored(){
+    return ignored;
   }
 
   public void setVerbose(boolean b){
@@ -50,17 +68,23 @@ public class TestScript {
     return this;
   }
 
+  /**
+     Returns true if the given script content should be ignored
+     (because it contains certain content which indicates such).
+  */
+  public static boolean shouldBeIgnored(String content){
+    return content.indexOf("SCRIPT_MODULE_NAME")>=0
+      || content.indexOf("\n|")>=0;
+  }
+
   /**
      A quick-and-dirty approach to chopping a script up into individual
-     commands. The primary problem with this is that it will remove any
-     C-style comments from expected script output, which might or might not
-     be a real problem.
-   */
-  private List<String> chunkContent(String input){
-    final String sCComment =
-      "[/][*]([*](?![/])|[^*])*[*][/]"
-      //"/\\*[^/*]*(?:(?!/\\*|\\*/)[/*][^/*]*)*\\*/"
-      ;
+     commands and their inputs.
+  */
+  private List<String> chunkContent(){
+    if( ignored ) return null;
+    // First, strip out any content which we know we can ignore...
+    final String sCComment = "[/][*]([*](?![/])|[^*])*[*][/]";
     final String s3Dash = "^---+[^\\n]*\\n";
     final String sTclComment = "^#[^\\n]*\\n";
     final String sEmptyLine = "^\\n";
@@ -69,8 +93,8 @@ public class TestScript {
     lPats.add(s3Dash);
     lPats.add(sTclComment);
     lPats.add(sEmptyLine);
-    //verbose("Content:").verbose(input).verbose("<EOF>");
-    String tmp = input;
+    //verbose("Content:").verbose(content).verbose("<EOF>");
+    String tmp = content;
     for( String s : lPats ){
       final Pattern p = Pattern.compile(
         s, Pattern.MULTILINE
@@ -83,7 +107,7 @@ public class TestScript {
       //while( m.find() ) verbose("#"+(++n)+"\t",m.group(0).trim());
       tmp = m.replaceAll("");
     }
-    // Chunk the newly-stripped text into individual commands.
+    // Chunk the newly-cleaned text into individual commands and their input...
     final String sCommand = "^--";
     final List<String> rc = new ArrayList<>();
     final Pattern p = Pattern.compile(
@@ -110,12 +134,15 @@ public class TestScript {
      in some form or other (possibly mangled from its original).
   */
   public void dump(){
-    List<String> list = chunkContent(content);
-    verbose("script chunked by command:");
-    int n = 0;
-    for(String c : list){
-      verbose("#"+(++n),c);
+    if( null==chunks ){
+      verbose("This contains content which forces it to be ignored.");
+    }else{
+      verbose("script commands:");
+      int n = 0;
+      for(String c : chunks){
+        verbose("#"+(++n),c);
+      }
+      verbose("<EOF>");
     }
-    verbose("<EOF>");
   }
 }
index 36454f9d3b34aaaf357400e9f8b60e075ec7921c..d8610a68b8cf5ec6f566ca95c9039e0891048086 100644 (file)
@@ -17,7 +17,7 @@ script are deleted when the script finishes.
 ## Parsing Rules:
 
   1.   Ignore the entire script if the script does not contain the
-       string "SCRIPT_MODULE_NAME:".  
+       string "SCRIPT_MODULE_NAME:".
 
   2.   Ignore any script that contains the character sequence "\\n\|"
        (0x0a, 0x7c).  In other words, ignore scripts that contain the
@@ -37,14 +37,14 @@ script are deleted when the script finishes.
 
 ## Commands:
 
-Each command looks like an SQL comment.  The command begins at the left 
+Each command looks like an SQL comment.  The command begins at the left
 margin (no leading space) and starts with exactly 2 minus signs ("-").
 The command name consists of lowercase letters and maybe a "-" or two.
 Some commands have arguments.
 The arguments are separated from the command name by one or more spaces.
 
 Commands have access to the input buffer and might reset the input buffer.
-The command can also optionally read (and consume) additional text from 
+The command can also optionally read (and consume) additional text from
 script that comes after the command.
 
 Unknown or unrecognized commands should cause an error message to be
diff --git a/ext/jni/src/tests/010_ignored.test b/ext/jni/src/tests/010_ignored.test
new file mode 100644 (file)
index 0000000..fe15c54
--- /dev/null
@@ -0,0 +1,4 @@
+/* This script must be marked as ignored because it contains
+   content which triggers that condition. */
+
+|
index 3758d4f51e119695f9a8c187824471b43b7effcf..d21ad9811458704e7f14a6021eef1bf612de5056 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C SQLTester\scan\snow\ssplit\sa\stest\sscript\sinto\sa\sseries\sof\sindividual\scommands.
-D 2023-08-07T22:32:22.258
+C SQLTester\snow\signores\stests\swhich\scontain\sconstructs\sspecified\sin\sthe\sspec\sdoc.
+D 2023-08-07T23:04:17.593
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -265,10 +265,11 @@ F ext/jni/src/org/sqlite/jni/sqlite3_context.java d26573fc7b309228cb49786e907859
 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/Outer.java 8931ff9f152d22a822ff98831a4e924da48016ff1f1f84042390a6f51ad7b48f
-F ext/jni/src/org/sqlite/jni/tester/SQLTester.java edcab1ea3d7848523416b881061f8095e8f7ae2a626e07947a55a4215898e040
-F ext/jni/src/org/sqlite/jni/tester/TestScript.java 00007d167ce5b40506a624bad1fb8571a0b975285849a7bd8fd7c0ebcfb3f785
-F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md ba3cf6584783939c8797a67203e63ec588430fdc0b7719f24873e6731c6d0445
+F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 1ee4ef9c65c9eedf6bfd68ad807346592ee01faf7fad16c3f18c462ed4c98c38
+F ext/jni/src/org/sqlite/jni/tester/TestScript.java 374bdad5cd0597aa9e20e5b8abd077a41d92caae6190ce383c250cb08859e7e4
+F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md 2627f8ac7c3d3f502404d9a9b8481bad5c2d11df7fdf25fbd0e1dbd2bcaa54c3
 F ext/jni/src/tests/000_first.test a06b72b6815246a21f6a4b14126bbc40b9cd1e3b03410431ed50203cfa942e9b
+F ext/jni/src/tests/010_ignored.test ce2de6742ff1bf98d8976fda0f260ff3d280e8f8c0a99309fb59fcfef2556fcd
 F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9
 F ext/lsm1/Makefile.msc f8c878b467232226de288da320e1ac71c131f5ec91e08b21f502303347260013
 F ext/lsm1/lsm-test/README 87ea529d2abe615e856d4714bfe8bb185e6c2771b8612aa6298588b7b43e6f86
@@ -2088,8 +2089,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 59bd392817ac69ffdf60ab7a2094b0d616bf593da060b6acf1b4ce9837847fcb
-R 63407ef8cfa2823943afd16b1a637995
+P d3d1accc8b4ba0cd396ee3a58d9710a54b8e1d1b171d67595d4ef1fc7faea8cb
+R d5c9761c7876583110d4d0a8a0b413b4
 U stephan
-Z 2b2535b40ad95e4630d07d7436d967c8
+Z e82e467651a46849ab5637959c044f1b
 # Remove this line to create a well-formed Fossil manifest.
index 08b4c777f71537b07e3266b95ac5817c3a828edc..b3ed60e6dfa198ccd3ace6f59ffe406cebb889a3 100644 (file)
@@ -1 +1 @@
-d3d1accc8b4ba0cd396ee3a58d9710a54b8e1d1b171d67595d4ef1fc7faea8cb
\ No newline at end of file
+ecaeee652aa2cc6893ded9231d7e9b2783465516016740b307b74e4e81598ae3
\ No newline at end of file