+/*
+** 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 the main application entry pointer for the
+** SQLTester framework.
+*/
package org.sqlite.jni.tester;
import java.util.List;
import java.util.ArrayList;
//! List of input script files.
private final java.util.List<String> listInFiles = new ArrayList<>();
private final Outer outer = new Outer();
+ private final StringBuilder inputBuffer = new StringBuilder();
public SQLTester(){
}
}
@SuppressWarnings("unchecked")
- private <T> void verbose(T... vals){
+ public <T> void verbose(T... vals){
this.outer.verbose(vals);
}
+ @SuppressWarnings("unchecked")
+ public <T> void outln(T... vals){
+ this.outer.outln(vals);
+ }
+
//! Adds the given test script to the to-test list.
public void addTestScript(String filename){
listInFiles.add(filename);
public void runTests() throws Exception {
// process each input file
for(String f : listInFiles){
+ this.reset();
final TestScript ts = new TestScript(f);
ts.setVerbose(this.outer.getVerbose());
verbose("Test",ts.getName(),"...");
- ts.dump();
+ ts.run(this);
}
}
+ void resetInputBuffer(){
+ this.inputBuffer.delete(0, this.inputBuffer.length());
+ }
+
+ void reset(){
+ this.resetInputBuffer();
+ }
+
public static void main(String[] argv) throws Exception{
final SQLTester t = new SQLTester();
for(String a : argv){
t.runTests();
}
}
+
+abstract class Command {
+ private SQLTester tester;
+ Command(SQLTester t){tester = t;}
+ public SQLTester getTester(){return tester;}
+
+ public abstract void process(String[] argv, String content);
+}
+
+class NullCommand extends Command {
+ public NullCommand(SQLTester t){super(t);}
+
+ public void process(String[] argv, String content){
+ }
+}
+
+class TestCaseCommand extends Command {
+ public TestCaseCommand(SQLTester t){super(t);}
+
+ public void process(String[] argv, String content){
+ }
+}
+
+class ResultCommand extends Command {
+ public ResultCommand(SQLTester t){super(t);}
+
+ public void process(String[] argv, String content){
+ }
+}
+
+class CommandFactory {
+ static Command getCommandByName(SQLTester t, String name){
+ switch(name){
+ case "null": return new NullCommand(t);
+ case "result": return new ResultCommand(t);
+ case "testcase": return new TestCaseCommand(t);
+ default: return null;
+ }
+ }
+}
+/*
+** 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 the TestScript part of the SQLTester framework.
+*/
package org.sqlite.jni.tester;
import java.util.List;
import java.util.ArrayList;
final Matcher m = p.matcher(tmp);
int ndxPrev = 0, pos = 0;
String chunk;
+ int i = 0;
+ //verbose("Trimmed content:").verbose(tmp).verbose("<EOF>");
while( m.find() ){
pos = m.start();
chunk = tmp.substring(ndxPrev, pos).trim();
- if( !chunk.isEmpty() ) rc.add( chunk );
+ if( 0==ndxPrev && pos>ndxPrev ){
+ /* Initial chunk of non-command state. Skip it. */
+ ndxPrev = pos + 2;
+ continue;
+ }
+ if( !chunk.isEmpty() ){
+ ++i;
+ //verbose("CHUNK #"+i,""+ndxPrev,"..",""+pos,chunk);
+ rc.add( chunk );
+ }
ndxPrev = pos + 2;
}
- if( ndxPrev != pos + 2 ){
+ if( ndxPrev < tmp.length() ){
chunk = tmp.substring(ndxPrev, tmp.length()).trim();
- if( !chunk.isEmpty() ) rc.add( chunk );
+ if( !chunk.isEmpty() ){
+ ++i;
+ //verbose("CHUNK #"+(++i),chunk);
+ rc.add( chunk );
+ }
}
return rc;
}
A debug-only function which dumps the content of the test script
in some form or other (possibly mangled from its original).
*/
- public void dump(){
+ public void run(SQLTester tester) throws Exception {
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);
+ for(String chunk : chunks){
+ ++n;
+ //verbose("#"+n,c).verbose("<EOF>");
+ String[] parts = chunk.split("\\n", 2);
+ String[] argv = parts[0].split("\\s+");
+ Command cmd = CommandFactory.getCommandByName(tester, argv[0]);
+ verbose("Command #"+n,argv[0],":",
+ (null==cmd ? "null" : cmd.getClass().getName()));
+ if(null == cmd){
+ throw new IllegalArgumentException(
+ "No command handler found for '"+argv[0]+"'"
+ );
+ }
+ if( parts.length > 1 ){
+ verbose(parts[1]).verbose("<EOF>");
+ }
+ cmd.process(argv, parts.length>1 ? parts[1] : null);
}
- verbose("<EOF>");
}
}
}
# this line is ignored
+junk
+
--null NULL
--- also ignored
--testcase first
-C SQLTester\snow\signores\stests\swhich\scontain\sconstructs\sspecified\sin\sthe\sspec\sdoc.
-D 2023-08-07T23:04:17.593
+C Add\scommand\sdispatcher\sto\sSQLTester.
+D 2023-08-07T23:59:08.259
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
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 1ee4ef9c65c9eedf6bfd68ad807346592ee01faf7fad16c3f18c462ed4c98c38
-F ext/jni/src/org/sqlite/jni/tester/TestScript.java 374bdad5cd0597aa9e20e5b8abd077a41d92caae6190ce383c250cb08859e7e4
+F ext/jni/src/org/sqlite/jni/tester/SQLTester.java e717d2117f9589f17af599e527c126733b13a2cfded3f47297ae37c02e62e9ab
+F ext/jni/src/org/sqlite/jni/tester/TestScript.java fa93b7abe11903412464b6cfbb6a2c44c738d4da291748ec99b28d3964bce846
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/000_first.test dad04b8e386bb5a33d02c9647a20229daccea9889ead58c70a723d5d179facea
F ext/jni/src/tests/010_ignored.test ce2de6742ff1bf98d8976fda0f260ff3d280e8f8c0a99309fb59fcfef2556fcd
F ext/lsm1/Makefile a553b728bba6c11201b795188c5708915cc4290f02b7df6ba7e8c4c943fd5cd9
F ext/lsm1/Makefile.msc f8c878b467232226de288da320e1ac71c131f5ec91e08b21f502303347260013
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P d3d1accc8b4ba0cd396ee3a58d9710a54b8e1d1b171d67595d4ef1fc7faea8cb
-R d5c9761c7876583110d4d0a8a0b413b4
+P ecaeee652aa2cc6893ded9231d7e9b2783465516016740b307b74e4e81598ae3
+R 248f12cc342cf395644ad37d3af803a2
U stephan
-Z e82e467651a46849ab5637959c044f1b
+Z 328e43fc1d1558590d24a0a8fa1662fc
# Remove this line to create a well-formed Fossil manifest.
-ecaeee652aa2cc6893ded9231d7e9b2783465516016740b307b74e4e81598ae3
\ No newline at end of file
+e0a06931e91459ea43fed2954568bfafa7ad6b794fcff66e0d3bf0ed181db386
\ No newline at end of file