1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

JS SQLTestRunner can now run the Java impl's core-most sanity tests, missing only support for directives.

FossilOrigin-Name: 5e798369375ce1b0c9cdf831f835d931fbd562ff7b4db09a06d1bdca2ac1b975
This commit is contained in:
stephan
2023-08-29 20:01:01 +00:00
parent 69a55ca17d
commit aa15047796
7 changed files with 503 additions and 79 deletions

View File

@ -181,7 +181,7 @@ public class SQLTester {
private int nTestFile = 0;
//! Number of scripts which were aborted.
private int nAbortedScript = 0;
//! Per-script test counter.
//! Incremented by test case handlers
private int nTest = 0;
//! True to enable column name output from execSql()
private boolean emitColNames;
@ -582,6 +582,10 @@ public class SQLTester {
}
}
}finally{
sqlite3_reset(stmt
/* In order to trigger an exception in the
INSERT...RETURNING locking scenario:
https://sqlite.org/forum/forumpost/36f7a2e7494897df */);
sqlite3_finalize(stmt);
}
if( 0!=rc && throwOnError ){
@ -926,8 +930,8 @@ class RunCommand extends Command {
final sqlite3 db = (1==argv.length)
? t.getCurrentDb() : t.getDbById( Integer.parseInt(argv[1]) );
final String sql = t.takeInputBuffer();
int rc = t.execSql(db, false, ResultBufferMode.NONE,
ResultRowMode.ONELINE, sql);
final int rc = t.execSql(db, false, ResultBufferMode.NONE,
ResultRowMode.ONELINE, sql);
if( 0!=rc && t.isVerbose() ){
String msg = sqlite3_errmsg(db);
ts.verbose1(argv[0]," non-fatal command error #",rc,": ",
@ -950,8 +954,7 @@ class TableResultCommand extends Command {
if( !body.endsWith("\n--end") ){
ts.toss(argv[0], " must be terminated with --end.");
}else{
int n = body.length();
body = body.substring(0, n-6);
body = body.substring(0, body.length()-6);
}
final String[] globs = body.split("\\s*\\n\\s*");
if( globs.length < 1 ){
@ -1240,14 +1243,15 @@ class TestScript {
final int oldPB = cur.putbackPos;
final int oldPBL = cur.putbackLineNo;
final int oldLine = cur.lineNo;
final String rc = getLine();
cur.peekedPos = cur.pos;
cur.peekedLineNo = cur.lineNo;
cur.pos = oldPos;
cur.lineNo = oldLine;
cur.putbackPos = oldPB;
cur.putbackLineNo = oldPBL;
return rc;
try{ return getLine(); }
finally{
cur.peekedPos = cur.pos;
cur.peekedLineNo = cur.lineNo;
cur.pos = oldPos;
cur.lineNo = oldLine;
cur.putbackPos = oldPB;
cur.putbackLineNo = oldPBL;
}
}
/**
@ -1374,11 +1378,10 @@ class TestScript {
String line;
while( (null != (line = peekLine())) ){
checkForDirective(tester, line);
if( !isCommandLine(line, true) ){
if( isCommandLine(line, true) ) break;
else {
sb.append(line).append("\n");
consumePeeked();
}else{
break;
}
}
line = sb.toString();