//! Console output utility.
#outer = new Outer().outputPrefix( ()=>'SQLTester: ' );
- //! List of input script files.
- #aFiles = [];
+ //! List of input scripts.
+ #aScripts = [];
//! Test input buffer.
#inputBuffer = [];
//! Test result buffer.
this.nullView = "nil";
this.emitColNames = false;
this.#db.iCurrentDb = 0;
- this.#db.initSql.push("SELECT 1;");
+ //this.#db.initSql.push("SELECT 1;");
}
appendInput(line, addNL){
}
}
+ addTestScript(ts){
+ if( 2===arguments.length ){
+ ts = new TestScript(arguments[0], arguments[1]);
+ }else if(ts instanceof Uint8Array){
+ ts = new TestScript('<unnamed>', ts);
+ }else if('string' === typeof arguments[1]){
+ ts = new TestScript('<unnamed>', Util.utf8Encode(arguments[1]));
+ }
+ if( !(ts instanceof TestScript) ){
+ Util.toss(SQLTesterException, "Invalid argument type for addTestScript()");
+ }
+ this.#aScripts.push(ts);
+ return this;
+ }
+
+ runTests(){
+ const tStart = (new Date()).getTime();
+ for(const ts of this.#aScripts){
+ this.reset();
+ ++this.metrics.nTestFile;
+ let threw = false;
+ const timeStart = (new Date()).getTime();
+ try{
+ ts.run(this);
+ }catch(e){
+ if(e instanceof SQLTesterException){
+ threw = true;
+ this.outln("🔥EXCEPTION: ",''+e);
+ ++this.metrics.nAbortedScript;
+ if( this.#keepGoing ){
+ this.outln("Continuing anyway becaure of the keep-going option.");
+ }
+ else if( e.isFatal() ) throw e;
+ }else{
+ throw e;
+ }
+ }finally{
+ const timeEnd = (new Date()).getTime();
+ this.outln("🏁", (threw ? "❌" : "✅"), " ", this.metrics.nTest,
+ " test(s) in ", (timeEnd-timeStart),"ms.");
+ }
+ }
+ const tEnd = (new Date()).getTime();
+ this.outln("Total run-time: ",(tEnd-tStart),"ms");
+ Util.unlink(this.#db.initialDbName);
+ return this;
+ }
+
#setupInitialDb(){
if( !this.#db.list[0] ){
Util.unlink(this.#db.initialDbName);
const wasm = sqlite3.wasm, capi = sqlite3.capi;
sql = (sql instanceof Uint8Array)
? sql
- : new TextEncoder("utf-8").encode(capi.sqlite3_js_sql_to_string(sql));
+ : Util.utf8Encode(capi.sqlite3_js_sql_to_string(sql));
const self = this;
const sb = (ResultBufferMode.NONE===appendMode) ? null : this.#resultBuffer;
let rc = 0;
}else{
content = args[0];
}
+ if(!(content instanceof Uint8Array)){
+ if('string' === typeof content){
+ content = Util.utf8Encode(content);
+ }else if(content instanceof ArrayBuffer){
+ content = new Uint8Array(content);
+ }else{
+ toss(Error, "Invalid content type for TestScript constructor.");
+ }
+ }
this.#filename = filename;
this.#cursor.src = content;
}
this.argcCheck(ts,argv,0);
t.incrementTestCounter();
let body = ts.fetchCommandBody(t);
- log("TRC fetchCommandBody: ",body);
if( null===body ) ts.toss("Missing ",argv[0]," body.");
body = body.trim();
if( !body.endsWith("\n--end") ){
ts.toss(argv[0], " must be terminated with --end\\n");
}else{
body = body.substring(0, body.length-6);
- log("TRC fetchCommandBody reshaped:",body);
}
const globs = body.split(/\s*\n\s*/);
if( globs.length < 1 ){
ts.toss(argv[0], " requires 1 or more ",
(this.#jsonMode ? "json snippets" : "globs"),".");
}
- log("TRC fetchCommandBody globs:",globs);
const sql = t.takeInputBuffer();
t.execSql(null, true,
this.#jsonMode ? ResultBufferMode.ASIS : ResultBufferMode.ESCAPED,
ResultRowMode.NEWLINE, sql);
const rbuf = t.getResultText().trim();
const res = rbuf.split(/\r?\n/);
- log("TRC fetchCommandBody rbuf, res:",rbuf, res);
if( res.length !== globs.length ){
ts.toss(argv[0], " failure: input has ", res.length,
" row(s) but expecting ",globs.length);
console.log("Loaded",ns);
log("ns =",ns);
-out("Hi there. ").outln("SQLTester is ostensibly ready.");
+outln("SQLTester is ready.");
-let ts = new ns.TestScript('/foo.test', ns.Util.utf8Encode(
-`
+let ts = new ns.TestScript('/foo.test',`
+--print Hello, world.
--close all
--oom
--db 0
select 1 as 'a', 2 as 'b';
--result 1 2
--close
-`));
+--print Until next time
+`);
const sqt = new ns.SQLTester();
try{
- log( 'sqt.getCurrentDb()', sqt.getCurrentDb() );
+ affirm( !sqt.getCurrentDb(), 'sqt.getCurrentDb()' );
sqt.openDb('/foo.db', true);
- log( 'sqt.getCurrentDb()', sqt.getCurrentDb() );
+ affirm( !!sqt.getCurrentDb(),'sqt.getCurrentDb()' );
sqt.verbosity(0);
- affirm( 'zilch' !== sqt.nullValue() );
- ts.run(sqt);
- affirm( 'zilch' === sqt.nullValue() );
+ if(false){
+ affirm( 'zilch' !== sqt.nullValue() );
+ ts.run(sqt);
+ affirm( 'zilch' === sqt.nullValue() );
+ }
+ sqt.addTestScript(ts);
+ sqt.runTests();
}finally{
sqt.reset();
}
-C JS\sSQLTestRunner\scan\snow\srun\sthe\sJava\simpl's\score-most\ssanity\stests,\smissing\sonly\ssupport\sfor\sdirectives.
-D 2023-08-29T20:01:01.586
+C More\sfleshing\sout\sof\sJS\sSQLTester.
+D 2023-08-29T20:44:40.606
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
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 a9f4b9e12109645b21fef15807973706dd958aad9fe1c835693fcb8e95abe949
+F ext/jni/src/org/sqlite/jni/tester/SQLTester.java e5a1a4b55ed940e61558be1292aa66563219f360c7c1f9d40d770307e6da3c07
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-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70
F ext/wasm/GNUmakefile 0e362f3fc04eab6628cbe4f1e35f4ab4a200881f6b5f753b27fb45eabeddd9d2
F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576
F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193
-F ext/wasm/SQLTester/SQLTester.mjs 345736d970dc56e2c1041f8583fc602eedd8a64d455864f312db7d3208e640ea
-F ext/wasm/SQLTester/SQLTester.run.mjs 2dfa1407f5f188dadafe6f21f7a6740b4f07d59c594781a01eedadec16b2ddfe
+F ext/wasm/SQLTester/SQLTester.mjs ed6bc486d804829883d05a94cbc5ace1b468837fcaf687d87f17969a659100ae
+F ext/wasm/SQLTester/SQLTester.run.mjs e053a4e94b22a97f5981a0ce927b77c542d68a564d723dbaeb7b299d817bb915
F ext/wasm/SQLTester/index.html 88d87e3ccbc33e7ab3773a8e48c1172e876951c4be31d1307c3700671262cddf
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api d6a5078f48a5301ed17b9a30331075d9b2506e1360c1f0dee0c7816c10acd9ab
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P d21b1217964a53f33b7ba3958b34aa8560dff8ede33e66f54aa0afbab7099ec3
-R 7266768b4057594984eb0965145c2068
+P 5e798369375ce1b0c9cdf831f835d931fbd562ff7b4db09a06d1bdca2ac1b975
+R 3c7d31cab0e76e0f71d5ac9e71d46fd7
U stephan
-Z 703bcb5450951150eb9347fe40faa521
+Z 3b4eebe6c916b635f59799d0c8f89ba5
# Remove this line to create a well-formed Fossil manifest.