From: stephan Date: Tue, 8 Aug 2023 00:59:40 +0000 (+0000) Subject: Add missing license header. Minor cleanups in SQLTester. X-Git-Tag: version-3.43.0~47^2~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58eebdaa25b9f29f70638ca24b0c367ef5e3a5bb;p=thirdparty%2Fsqlite.git Add missing license header. Minor cleanups in SQLTester. FossilOrigin-Name: 5be50fd5887e5378f7d66405bff3a44117a826a17e5f1a18c5129d1109ecdae2 --- diff --git a/ext/jni/src/org/sqlite/jni/tester/Outer.java b/ext/jni/src/org/sqlite/jni/tester/Outer.java index f099fe3660..779d71f1e2 100644 --- a/ext/jni/src/org/sqlite/jni/tester/Outer.java +++ b/ext/jni/src/org/sqlite/jni/tester/Outer.java @@ -1,30 +1,43 @@ +/* +** 2023-08-08 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains a utility class for generating console output. +*/ package org.sqlite.jni.tester; -public class Outer { +class Outer { public boolean isVerbose = true; - public static void out(T val){ + public static void out(Object val){ System.out.print(val); } - public static void outln(T val){ + public static void outln(Object val){ System.out.println(val); } @SuppressWarnings("unchecked") - public static void out(T... vals){ + public static void out(Object... vals){ int n = 0; - for(T v : vals) out((n++>0 ? " " : "")+v); + for(Object v : vals) out((n++>0 ? " " : "")+v); } @SuppressWarnings("unchecked") - public static void outln(T... vals){ + public static void outln(Object... vals){ out(vals); out("\n"); } @SuppressWarnings("unchecked") - public Outer verbose(T... vals){ + public Outer verbose(Object... vals){ if(isVerbose) outln(vals); return this; } diff --git a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java b/ext/jni/src/org/sqlite/jni/tester/SQLTester.java index 441383ca0a..a1ede71840 100644 --- a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java +++ b/ext/jni/src/org/sqlite/jni/tester/SQLTester.java @@ -29,9 +29,12 @@ public class SQLTester { private final java.util.List listInFiles = new ArrayList<>(); private final Outer outer = new Outer(); private final StringBuilder inputBuffer = new StringBuilder(); - private String nullView = "nil"; + private String nullView; + private int totalTestCount = 0; + private int testCount; public SQLTester(){ + reset(); } public void setVerbose(boolean b){ @@ -39,13 +42,13 @@ public class SQLTester { } @SuppressWarnings("unchecked") - public void verbose(T... vals){ - this.outer.verbose(vals); + public void verbose(Object... vals){ + outer.verbose(vals); } @SuppressWarnings("unchecked") - public void outln(T... vals){ - this.outer.outln(vals); + public void outln(Object... vals){ + outer.outln(vals); } //! Adds the given test script to the to-test list. @@ -57,16 +60,17 @@ public class SQLTester { public void runTests() throws Exception { // process each input file for(String f : listInFiles){ - this.reset(); + reset(); final TestScript ts = new TestScript(f); ts.setVerbose(this.outer.getVerbose()); verbose("Test",ts.getName(),"..."); ts.run(this); + verbose("Ran",testCount,"test(s)."); } } void resetInputBuffer(){ - this.inputBuffer.delete(0, this.inputBuffer.length()); + inputBuffer.delete(0, this.inputBuffer.length()); } String getInputBuffer(){ @@ -80,11 +84,18 @@ public class SQLTester { } void reset(){ - this.resetInputBuffer(); + testCount = 0; + nullView = "nil"; + resetInputBuffer(); } void setNullValue(String v){nullView = v;} + void incrementTestCounter(){ + ++testCount; + ++totalTestCount; + } + public static void main(String[] argv) throws Exception{ final SQLTester t = new SQLTester(); for(String a : argv){ @@ -108,18 +119,18 @@ class Command { protected SQLTester tester; Command(SQLTester t){tester = t;} - protected final void badArg(String... msg){ + protected final void badArg(Object... msg){ StringBuilder sb = new StringBuilder(); int i = 0; - for(String s : msg) sb.append(((0==i++) ? "" : " ")+s); + for(Object s : msg) sb.append(((0==i++) ? "" : " ")+s); throw new IllegalArgumentException(sb.toString()); } protected final void argcCheck(String[] argv, int min, int max){ int argc = argv.length-1; if(argcmax){ - if( min==max ) badArg(argv[0],"requires exactly",""+min,"argument(s)"); - else badArg(argv[0],"requires",""+min,"-",""+max,"arguments."); + if( min==max ) badArg(argv[0],"requires exactly",min,"argument(s)"); + else badArg(argv[0],"requires",min,"-",max,"arguments."); } } @@ -148,7 +159,7 @@ class NullCommand extends Command { super(t); argcCheck(argv,1); affirmNoContent(content); - tester.setNullValue(argv[1]); + t.setNullValue(argv[1]); //t.verbose(argv[0],argv[1]); } } @@ -158,6 +169,7 @@ class ResultCommand extends Command { super(t); argcCheck(argv,0); t.verbose(argv[0],"command is TODO"); + t.incrementTestCounter(); } } @@ -190,7 +202,7 @@ class CommandDispatcher { } final java.lang.reflect.Constructor ctor = cmdClass.getConstructor(SQLTester.class, String[].class, String.class); - tester.verbose("Running",cmdClass.getSimpleName(),"..."); + //tester.verbose("Running",argv[0],"..."); ctor.newInstance(tester, argv, content); } } diff --git a/ext/jni/src/org/sqlite/jni/tester/TestScript.java b/ext/jni/src/org/sqlite/jni/tester/TestScript.java index c94e348880..c27528a3ae 100644 --- a/ext/jni/src/org/sqlite/jni/tester/TestScript.java +++ b/ext/jni/src/org/sqlite/jni/tester/TestScript.java @@ -16,8 +16,6 @@ import java.util.List; import java.util.ArrayList; import java.io.*; import java.util.regex.*; -//import java.util.List; -//import java.util.ArrayList; /** This class represents a single test script. It handles (or delegates) @@ -25,8 +23,7 @@ import java.util.regex.*; as-yet-non-existent, classes. */ -public class TestScript { - //! Test script content. +class TestScript { private String name; private String content; private List chunks = null; @@ -44,6 +41,7 @@ public class TestScript { } /** Initializes the script with the content of the given file. + Throws if it cannot read the file or if tokenizing it fails. */ public TestScript(String filename) throws Exception{ setContent(new String(readFile(filename), @@ -91,8 +89,8 @@ public class TestScript { } /** - A quick-and-dirty approach to chopping a script up into individual - commands and their inputs. + Chop script up into chunks containing individual commands and + their inputs. */ private List chunkContent(){ if( ignored ) return null; @@ -121,15 +119,11 @@ public class TestScript { tmp = m.replaceAll(""); } // Chunk the newly-cleaned text into individual commands and their input... - final String sCommand = "^--"; final List rc = new ArrayList<>(); - final Pattern p = Pattern.compile( - sCommand, Pattern.MULTILINE - ); + final Pattern p = Pattern.compile("^--", Pattern.MULTILINE); final Matcher m = p.matcher(tmp); - int ndxPrev = 0, pos = 0; + int ndxPrev = 0, pos = 0, i = 0; String chunk; - int i = 0; //verbose("Trimmed content:").verbose(tmp).verbose(""); while( m.find() ){ pos = m.start(); @@ -147,6 +141,7 @@ public class TestScript { ndxPrev = pos + 2; } if( ndxPrev < tmp.length() ){ + // This all belongs to the final command chunk = tmp.substring(ndxPrev, tmp.length()).trim(); if( !chunk.isEmpty() ){ ++i; @@ -158,8 +153,7 @@ public class TestScript { } /** - A debug-only function which dumps the content of the test script - in some form or other (possibly mangled from its original). + Runs this test script in the context of the given tester object. */ public void run(SQLTester tester) throws Exception { if( null==chunks ){ diff --git a/ext/jni/src/tests/000_first.test b/ext/jni/src/tests/000_first.test index 58ad6e7013..aaec5e08b5 100644 --- a/ext/jni/src/tests/000_first.test +++ b/ext/jni/src/tests/000_first.test @@ -10,6 +10,8 @@ junk --testcase first input for the first command; +--result +hello world --testcase second select 1 --result /* ignored */ diff --git a/manifest b/manifest index c4e0df940e..8999d330f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rework\sSQLTester\sdispatching\sand\sadd\sstub\simpls\sfor\sseveral\scommmands. -D 2023-08-08T00:37:31.945 +C Add\smissing\slicense\sheader.\sMinor\scleanups\sin\sSQLTester. +D 2023-08-08T00:59:40.520 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -264,11 +264,11 @@ F ext/jni/src/org/sqlite/jni/sqlite3.java ff3729426704626a6019d97bfee512a83f253c F ext/jni/src/org/sqlite/jni/sqlite3_context.java d26573fc7b309228cb49786e9078597d96232257defa955a3425d10897bca810 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 c4cadc7d0a8c86a9369a55527d711558206f8d2cf0ee8e26c1c1167a247e9c16 -F ext/jni/src/org/sqlite/jni/tester/TestScript.java ed3cbc0371d0949293d9cc1925ce79d0d354fbe5282042dfbfe60c6e9d792fcd +F ext/jni/src/org/sqlite/jni/tester/Outer.java c35a54bd3fd3363ba2abb5533453454d8ffe3f942c9a37a7921c8f6739762e82 +F ext/jni/src/org/sqlite/jni/tester/SQLTester.java d89dc9921b41aea67ee3c69e763671467042b33b62085aa7a44444856c4eca3f +F ext/jni/src/org/sqlite/jni/tester/TestScript.java 6a631e2ecce24734bd93631ce00446ed109aaeb1ea6666f7a8aff74d96221a6a F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md 2627f8ac7c3d3f502404d9a9b8481bad5c2d11df7fdf25fbd0e1dbd2bcaa54c3 -F ext/jni/src/tests/000_first.test 29cc4ab0fa97a296ba0e2a7d821f7869503eec52e0fdb9de6a536dd02dd01946 +F ext/jni/src/tests/000_first.test 0a066e5e30189545ca4f3586d45db6c08195a50bd2f00907b4d6a3727ff58c02 F ext/jni/src/tests/010_ignored.test ce2de6742ff1bf98d8976fda0f260ff3d280e8f8c0a99309fb59fcfef2556fcd F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9 F ext/lsm1/Makefile.msc f8c878b467232226de288da320e1ac71c131f5ec91e08b21f502303347260013 @@ -2089,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 e0a06931e91459ea43fed2954568bfafa7ad6b794fcff66e0d3bf0ed181db386 -R 6790dfdd79e39541015901c80293f883 +P 9e61af75ac83e74487a6ae681ee3ff891d8cf1f1d23bf895e9e3963ddf6eaf28 +R 75e2a8b50272267a155f3645b409db9d U stephan -Z 7dd3c312d5e23f2927529b8054c01871 +Z fbbe7908dd24ba8c5b8dfecd37f39fe7 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 96ab7475d9..fa8b36a1f2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9e61af75ac83e74487a6ae681ee3ff891d8cf1f1d23bf895e9e3963ddf6eaf28 \ No newline at end of file +5be50fd5887e5378f7d66405bff3a44117a826a17e5f1a18c5129d1109ecdae2 \ No newline at end of file