mirror of
https://github.com/sqlite/sqlite.git
synced 2026-10-28 09:46:20 +08:00
Add a new direct CLI testing script in test/modeA.clitest to demonstration
that can be done. Rig this this to be run by test/shellB.test during normal testing. FossilOrigin-Name: 3107ebb9e1602fe5bed644c6f69426bebf307772e581b17a8fa3e50bd522e566
This commit is contained in:
1 parent
3b847a4040
commit
ed72bb3fa3
6 files changed
+127
-10
No files matched your search
@@ -1,5 +1,5 @@
|
||||
C Rename\sQRF_STYLE_JsonLine\sto\sQRF_STYLE_JObject.\s\sAdd\snew\sconvenience\smodes\nto\sthe\sCLI\sand\sgenerally\srefactor\sand\simprove\sthe\s".mode"\scommand.\s\sSome\ntests\sare\sfailing,\smostly\sdue\sto\schanges\sin\serror\smessage\soutput\sand\ssimilar.
|
||||
D 2025-11-12T12:44:02.867
|
||||
C Add\sa\snew\sdirect\sCLI\stesting\sscript\sin\stest/modeA.clitest\sto\sdemonstration\nthat\scan\sbe\sdone.\s\sRig\sthis\sthis\sto\sbe\srun\sby\stest/shellB.test\sduring\snormal\ntesting.
|
||||
D 2025-11-12T13:46:11.794
|
||||
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
@@ -735,7 +735,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
|
||||
F src/resolve.c 5616fbcf3b833c7c705b24371828215ad0925d0c0073216c4f153348d5753f0a
|
||||
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
||||
F src/select.c ba9cd07ffa3277883c1986085f6ddc4320f4d35d5f212ab58df79a7ecc1a576a
|
||||
F src/shell.c.in ea1a9f9eb07db0d762b2ae12d23988fdc09360f4f6beac324a2a226d9fd5f740
|
||||
F src/shell.c.in 68396182b0d542eb223fb93e41fcfdb98ffa2caac8ce06868ec1e1da962badba
|
||||
F src/sqlite.h.in 7403a952a8f1239de7525b73c4e3a0f9540ec0607ed24fec887f5832642d44b8
|
||||
F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
|
||||
F src/sqlite3ext.h 7f236ca1b175ffe03316d974ef57df79b3938466c28d2f95caef5e08c57f3a52
|
||||
@@ -1437,6 +1437,7 @@ F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93
|
||||
F test/mmapcorrupt.test 470fb44fe92e99c1d23701d156f8c17865f5b027063c9119dcfdb842791f4465
|
||||
F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3
|
||||
F test/mmapwarm.test 2272005969cd17a910077bd5082f70bc1fefad9a875afec7fc9af483898ecaf3
|
||||
F test/modeA.clitest 7d6a81c5fe60ba07b5b68c9fb624fd7cb7c75be3fc364e17c75c47d8efaaa54d
|
||||
F test/multiplex.test d74c034e52805f6de8cc5432cef8c9eb774bb64ec29b83a22effc8ca4dac1f08
|
||||
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
|
||||
F test/multiplex3.test fac575e0b1b852025575a6a8357701d80933e98b5d2fe6d35ddaa68f92f6a1f7
|
||||
@@ -1611,6 +1612,7 @@ F test/shell7.test 43fd8e511c533bab5232e95c7b4be93b243451709e89582600d4b6e67693d
|
||||
F test/shell8.test 641cf21a99c59404c24e3062923734951c4099a6b6b6520de00cf7a1249ee871
|
||||
F test/shell9.test 8742a5b390cdcef6369f5aa223e415aa4255a4129ef249b177887dc635a87209
|
||||
F test/shellA.test 1de183849ddb6b49d9f21a10a2f6f22bc66f962c0bfaed5baa5ecc3dc6d8f2d5
|
||||
F test/shellB.test d2b2f6256560145b8c027dbfc41cd2ac50b2ef25d5853f3ae80c9407f441c9d2
|
||||
F test/shmlock.test 9f1f729a7fe2c46c88b156af819ac9b72c0714ac6f7246638a73c5752b5fd13c
|
||||
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
|
||||
F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5
|
||||
@@ -1696,7 +1698,7 @@ F test/tester.tcl 463ae33b8bf75ac77451df19bd65e7c415c2e9891227c7c9e657d0a2d8e107
|
||||
F test/testloadext.c 862b848783eaed9985fbce46c65cd214664376b549fae252b364d5d1ef350a27
|
||||
F test/testrunner.tcl 86179a8e78997e9257cb8f738c5624cb23897da5297855578ba74715e64f1602 x
|
||||
F test/testrunner_data.tcl c507a9afa911c03446ed90442ffd4a98aca02882c3d51bd1177c24795674def8
|
||||
F test/testrunner_estwork.tcl 7927a84327259a32854926f68a75292e33a61e7e052fdbfcb01f18696c99c724
|
||||
F test/testrunner_estwork.tcl 81e2ae10238f50540f42fbf2d94913052a99bfb494b69e546506323f195dcff9
|
||||
F test/thread001.test a0985c117eab62c0c65526e9fa5d1360dd1cac5b03bde223902763274ce21899
|
||||
F test/thread002.test c24c83408e35ba5a952a3638b7ac03ccdf1ce4409289c54a050ac4c5f1de7502
|
||||
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
|
||||
@@ -2173,8 +2175,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
|
||||
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
||||
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 3450bc7eecb717abedbaeb56dc824e14eb35ed30322fe3dd3b4b1cbd5fd14c60
|
||||
R bae867483b903590efb761aa22052bac
|
||||
P 4c8109682e3a224fd8e015e73a9c1c7b6d56ad747d7ca7bc387bb92e1c98f731
|
||||
R e7fc6b191c336123ef02d62bdd856b8f
|
||||
U drh
|
||||
Z c473f1769dc85c25ae73a4d9b1c09693
|
||||
Z 90d2468da1196b69530a9ff9957b86e3
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
+1
-1
@@ -1 +1 @@
|
||||
4c8109682e3a224fd8e015e73a9c1c7b6d56ad747d7ca7bc387bb92e1c98f731
|
||||
3107ebb9e1602fe5bed644c6f69426bebf307772e581b17a8fa3e50bd522e566
|
||||
+15
-2
@@ -1294,6 +1294,7 @@ struct ShellState {
|
||||
sqlite3_int64 szMax; /* --maxsize argument to .open */
|
||||
char *zDestTable; /* Name of destination table when MODE_Insert */
|
||||
char *zTempFile; /* Temporary file that might need deleting */
|
||||
char *zErrPrefix; /* Alternative error message prefix */
|
||||
char zTestcase[30]; /* Name of current test case */
|
||||
char outfile[FILENAME_MAX]; /* Filename for *out */
|
||||
sqlite3_stmt *pStmt; /* Current statement if any. */
|
||||
@@ -1378,6 +1379,7 @@ static const char *qrfQuoteNames[] = { "off","off","sql","hex", "tcl", "json"};
|
||||
#define SHFLG_Lookaside 0x00000002 /* Lookaside memory is used */
|
||||
#define SHFLG_Backslash 0x00000004 /* The --backslash option is used */
|
||||
#define SHFLG_PreserveRowid 0x00000008 /* .dump preserves rowid values */
|
||||
#define SHFLG_NoErrLineno 0x00000010 /* Omit line numbers from error msgs */
|
||||
#define SHFLG_CountChanges 0x00000020 /* .changes setting */
|
||||
#define SHFLG_DumpDataOnly 0x00000100 /* .dump show data only */
|
||||
#define SHFLG_DumpNoSys 0x00000200 /* .dump omits system tables */
|
||||
@@ -1636,7 +1638,9 @@ static void shellPutsFunc(
|
||||
*/
|
||||
static char *shellErrorLocation(ShellState *p){
|
||||
char *zLoc;
|
||||
if( p->zInFile==0 || strcmp(p->zInFile,"<stdin>")==0){
|
||||
if( p->zErrPrefix ){
|
||||
zLoc = sqlite3_mprintf("%s", p->zErrPrefix);
|
||||
}else if( p->zInFile==0 || strcmp(p->zInFile,"<stdin>")==0){
|
||||
zLoc = sqlite3_mprintf("line %lld:", p->lineno);
|
||||
}else{
|
||||
zLoc = sqlite3_mprintf("%s:%lld:", p->zInFile, p->lineno);
|
||||
@@ -7276,7 +7280,15 @@ static int dotCmdMode(ShellState *p){
|
||||
i++;
|
||||
modeSetStr(&p->mode.spec.zTableName, azArg[i]);
|
||||
}
|
||||
chng = 1;
|
||||
chng = 1;
|
||||
}else if( optionMatch(z,"error-prefix") ){
|
||||
if( i+1>=nArg ){
|
||||
dotCmdError(p, i, "missing argument", 0);
|
||||
return 1;
|
||||
}
|
||||
free(p->zErrPrefix);
|
||||
p->zErrPrefix = strdup(azArg[++i]);
|
||||
chng = 1;
|
||||
}else if( z[0]=='-' ){
|
||||
dotCmdError(p, i, "bad option", "Use \".help .mode\" for more info");
|
||||
return 1;
|
||||
@@ -12514,6 +12526,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
free(argvToFree);
|
||||
#endif
|
||||
modeFree(&data.mode);
|
||||
free(data.zErrPrefix);
|
||||
free(data.zNonce);
|
||||
free(data.dot.zCopy);
|
||||
free(data.dot.azArg);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# 2025-11-12
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Test cases for the ".mode" command of the CLI.
|
||||
# To run these tests:
|
||||
#
|
||||
# ./sqlite3 <test/modeA.clitest
|
||||
#
|
||||
#
|
||||
.mode --error-prefix "Error:"
|
||||
CREATE TABLE t1(a,b,c,d,e);
|
||||
INSERT INTO t1 VALUES(1,2.5,'three',x'4444',NULL);
|
||||
INSERT INTO t1 SELECT b,c,d,e,a FROM t1;
|
||||
INSERT INTO t1 SELECT d,e,a,b,c FROM t1;
|
||||
.mode box
|
||||
|
||||
.output memory
|
||||
SELECT * FROM t1;
|
||||
.output --verify END
|
||||
┌─────┬───────┬───────┬───────┬───────┐
|
||||
│ a │ b │ c │ d │ e │
|
||||
├─────┼───────┼───────┼───────┼───────┤
|
||||
│ 1 │ 2.5 │ three │ DD │ │
|
||||
│ 2.5 │ three │ DD │ │ 1 │
|
||||
│ DD │ │ 1 │ 2.5 │ three │
|
||||
│ │ 1 │ 2.5 │ three │ DD │
|
||||
└─────┴───────┴───────┴───────┴───────┘
|
||||
END
|
||||
.null xyz
|
||||
|
||||
.output memory
|
||||
SELECT * FROM t1;
|
||||
.output --verify END
|
||||
┌─────┬───────┬───────┬───────┬───────┐
|
||||
│ a │ b │ c │ d │ e │
|
||||
├─────┼───────┼───────┼───────┼───────┤
|
||||
│ 1 │ 2.5 │ three │ DD │ xyz │
|
||||
│ 2.5 │ three │ DD │ xyz │ 1 │
|
||||
│ DD │ xyz │ 1 │ 2.5 │ three │
|
||||
│ xyz │ 1 │ 2.5 │ three │ DD │
|
||||
└─────┴───────┴───────┴───────┴───────┘
|
||||
END
|
||||
|
||||
.output memory
|
||||
.mode foo
|
||||
.output --verify END
|
||||
Error: .mode foo
|
||||
Error: ^--- unknown mode
|
||||
Error: Use ".help .mode" for more info
|
||||
END
|
||||
@@ -0,0 +1,43 @@
|
||||
# 2025-11-12
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
# TESTRUNNER: shell
|
||||
#
|
||||
# Test cases for the command-line shell using the new ".output memory"
|
||||
# feature.
|
||||
#
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set CLI [test_cli_invocation]
|
||||
|
||||
# Run an instance of the CLI on the file $name.
|
||||
# Capture the number of test cases and the number of
|
||||
# errors and increment the counts.
|
||||
#
|
||||
proc do_clitest {name} {
|
||||
set mapping [list <NAME> $name]
|
||||
set script [string map $mapping {
|
||||
catch {exec {*}$::CLI :memory: ".read $::testdir/<NAME>" 2>@stdout} res
|
||||
set ntest 0
|
||||
set nerr 0
|
||||
regexp {(\d+) tests run with (\d+) errors} $res all ntest nerr
|
||||
set_test_counter count [expr {[set_test_counter count]+$ntest-1}]
|
||||
set_test_counter errors [expr {[set_test_counter errors]+$nerr}]
|
||||
set answer "$nerr errors"
|
||||
}]
|
||||
# puts $script
|
||||
do_test shellB-$name $script {0 errors}
|
||||
}
|
||||
|
||||
do_clitest modeA.clitest
|
||||
|
||||
finish_test
|
||||
@@ -364,6 +364,7 @@ set estwork(shell6.test) 3
|
||||
set estwork(shell8.test) 104
|
||||
set estwork(shell9.test) 3
|
||||
set estwork(shellA.test) 2
|
||||
set estwork(shellB.test) 2
|
||||
set estwork(shmlock.test) 27
|
||||
set estwork(sidedelete.test) 10
|
||||
set estwork(skipscan1.test) 7
|
||||
|
||||
Reference in new issue
Block a user