1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-06 15:49:35 +03:00

Modified CLI to raise an error when extra command line options are passed.

Added tests to verify correct handling, as well as other basic handling
of command line options. Ticket [f5cb008a65].

FossilOrigin-Name: 09b4f19f100fe82a8321b9ded99e679b7eedc1fa
This commit is contained in:
shaneh
2009-11-11 04:17:07 +00:00
parent e76173b7c0
commit 5fc250100e
5 changed files with 429 additions and 268 deletions

View File

@@ -1,8 +1,5 @@
-----BEGIN PGP SIGNED MESSAGE----- C Modified\sCLI\sto\sraise\san\serror\swhen\sextra\scommand\sline\soptions\sare\spassed.\s\s\nAdded\stests\sto\sverify\scorrect\shandling,\sas\swell\sas\sother\sbasic\shandling\nof\scommand\sline\soptions.\sTicket\s[f5cb008a65].
Hash: SHA1 D 2009-11-11T04:17:07
C Additional\stest\scases\sfor\sthe\scoalesce()\sand\sifnull()\sfunctions.
D 2009-11-11T01:14:18
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 53f3dfa49f28ab5b80cb083fb7c9051e596bcfa1 F Makefile.in 53f3dfa49f28ab5b80cb083fb7c9051e596bcfa1
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -164,7 +161,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c aa3cb21e1ecd905c071fce8fb64d1a166cefc239 F src/resolve.c aa3cb21e1ecd905c071fce8fb64d1a166cefc239
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c ecd7fb2fcb8d207dd381338377b5bacce0b38a2d F src/select.c ecd7fb2fcb8d207dd381338377b5bacce0b38a2d
F src/shell.c 360ed53f8672a16b0767bf59e947a9ba7bfe7e21 F src/shell.c f4948cb6d30665d755a6b5e0ec313d1094aab828
F src/sqlite.h.in 4464e9772122f0447305d425e04d122b6f1bffec F src/sqlite.h.in 4464e9772122f0447305d425e04d122b6f1bffec
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
F src/sqliteInt.h ee54fe752ba5672b7ca52bdd0e300c3902103d93 F src/sqliteInt.h ee54fe752ba5672b7ca52bdd0e300c3902103d93
@@ -757,8 +754,8 @@ F tool/mksqlite3h.tcl eb100dce83f24b501b325b340f8b5eb8e5106b3b
F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
F tool/shell1.test 37959b1fd1be383b945227830031710028ad6683 F tool/shell1.test f85b976bef45f435fa39bf3690501cd5c0bdbb86
F tool/shell2.test 2058b96a870048aef485223103f6059a58675f3e F tool/shell2.test c985140ca75d96dad5bef8a5f49ed51b9c002dfb
F tool/showdb.c 8ab8b3b53884312aafb7ef60982e255a6c31d238 F tool/showdb.c 8ab8b3b53884312aafb7ef60982e255a6c31d238
F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87 F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87
F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
@@ -770,14 +767,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 30055b257c3c65f8123cad5ac6c62c4c6ca2c900 P d0591258b62df4fa610b7ac2a2af0344cf82f231
R f47af5b75e0e8e616f1fd8b931ddb5b3 R c7bfb4d38e343350d9b6f47a36dab0d7
U drh U shaneh
Z 3b5efed677f45a2948478d37ad1216cc Z 4e81a4c5bff85317d313a2cdd47185b8
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFK+g/toxKgR168RlERAjaZAJ4lZcZqcztQ7x0Q3/6iUvbKhaxjwwCfasc4
Gd5rMrr89fVbrffFtkNRS+A=
=P4HI
-----END PGP SIGNATURE-----

View File

@@ -1 +1 @@
d0591258b62df4fa610b7ac2a2af0344cf82f231 09b4f19f100fe82a8321b9ded99e679b7eedc1fa

View File

@@ -3294,6 +3294,7 @@ static int process_sqliterc(
** Show available command line options ** Show available command line options
*/ */
static const char zOptions[] = static const char zOptions[] =
" -help show this message\n"
" -init filename read/process named file\n" " -init filename read/process named file\n"
" -echo print commands before execution\n" " -echo print commands before execution\n"
" -[no]header turn headers on or off\n" " -[no]header turn headers on or off\n"
@@ -3391,6 +3392,11 @@ int main(int argc, char **argv){
if( i<argc ){ if( i<argc ){
zFirstCmd = argv[i++]; zFirstCmd = argv[i++];
} }
if( i<argc ){
fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
fprintf(stderr,"Use -help for a list of options.\n");
return 1;
}
data.out = stdout; data.out = stdout;
#ifdef SQLITE_OMIT_MEMORYDB #ifdef SQLITE_OMIT_MEMORYDB
@@ -3441,10 +3447,20 @@ int main(int argc, char **argv){
memcpy(data.separator,",",2); memcpy(data.separator,",",2);
}else if( strcmp(z,"-separator")==0 ){ }else if( strcmp(z,"-separator")==0 ){
i++; i++;
if(i>=argc){
fprintf(stderr,"%s: Error: missing argument for option: %s\n", Argv0, z);
fprintf(stderr,"Use -help for a list of options.\n");
return 1;
}
sqlite3_snprintf(sizeof(data.separator), data.separator, sqlite3_snprintf(sizeof(data.separator), data.separator,
"%.*s",(int)sizeof(data.separator)-1,argv[i]); "%.*s",(int)sizeof(data.separator)-1,argv[i]);
}else if( strcmp(z,"-nullvalue")==0 ){ }else if( strcmp(z,"-nullvalue")==0 ){
i++; i++;
if(i>=argc){
fprintf(stderr,"%s: Error: missing argument for option: %s\n", Argv0, z);
fprintf(stderr,"Use -help for a list of options.\n");
return 1;
}
sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue, sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
"%.*s",(int)sizeof(data.nullvalue)-1,argv[i]); "%.*s",(int)sizeof(data.nullvalue)-1,argv[i]);
}else if( strcmp(z,"-header")==0 ){ }else if( strcmp(z,"-header")==0 ){

View File

@@ -16,12 +16,15 @@
# Test plan: # Test plan:
# #
# shell1-1.*: Basic "dot" command token parsing. # shell1-1.*: Basic command line option handling.
# shell1-2.*: Basic test that "dot" command can be called. # shell1-2.*: Basic "dot" command token parsing.
# shell1-3.*: Basic test that "dot" command can be called.
# #
package require sqlite3 package require sqlite3
set CLI "./sqlite"
proc do_test {name cmd expected} { proc do_test {name cmd expected} {
puts -nonewline "$name ..." puts -nonewline "$name ..."
set res [uplevel $cmd] set res [uplevel $cmd]
@@ -44,189 +47,327 @@ proc catchsql {sql} {
list $rc $msg list $rc $msg
} }
proc catchcmd {cmd} { proc catchcmd {db cmd} {
global CLI
set out [open cmds.txt w] set out [open cmds.txt w]
puts $out $cmd puts $out $cmd
close $out close $out
set rc [catch { exec ./sqlite test.db < cmds.txt } msg] set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg list $rc $msg
} }
file delete -force test.db test.db.journal file delete -force test.db test.db.journal
sqlite3 db test.db sqlite3 db test.db
#----------------------------------------------------------------------------
# Test cases shell1-1.*: Basic command line option handling.
#
# invalid option
do_test shell1-1.1.1 {
set res [catchcmd "-bad test.db" ""]
set rc [lindex $res 0]
list $rc \
[regexp {Error: unknown option: -bad} $res]
} {1 1}
# error on extra options
do_test shell1-1.1.2 {
set res [catchcmd "-bad test.db \"select 3\" \"select 4\"" ""]
set rc [lindex $res 0]
list $rc \
[regexp {Error: too many options: "select 4"} $res]
} {1 1}
# error on extra options
do_test shell1-1.3.2 {
set res [catchcmd "-bad FOO test.db BAD" ".quit"]
set rc [lindex $res 0]
list $rc \
[regexp {Error: too many options: "BAD"} $res]
} {1 1}
# -help
do_test shell1-1.2.1 {
set res [catchcmd "-help test.db" ""]
set rc [lindex $res 0]
list $rc \
[regexp {Usage} $res] \
[regexp {\-init} $res] \
[regexp {\-version} $res]
} {1 1 1 1}
# -init filename read/process named file
do_test shell1-1.3.1 {
catchcmd "-init FOO test.db" ""
} {0 {}}
do_test shell1-1.3.2 {
set res [catchcmd "-init FOO test.db .quit BAD" ""]
set rc [lindex $res 0]
list $rc \
[regexp {Error: too many options: "BAD"} $res]
} {1 1}
# -echo print commands before execution
do_test shell1-1.4.1 {
catchcmd "-echo test.db" ""
} {0 {}}
# -[no]header turn headers on or off
do_test shell1-1.5.1 {
catchcmd "-header test.db" ""
} {0 {}}
do_test shell1-1.5.2 {
catchcmd "-noheader test.db" ""
} {0 {}}
# -bail stop after hitting an error
do_test shell1-1.6.1 {
catchcmd "-bail test.db" ""
} {0 {}}
# -interactive force interactive I/O
do_test shell1-1.7.1 {
set res [catchcmd "-interactive test.db" ".quit"]
set rc [lindex $res 0]
list $rc \
[regexp {SQLite version} $res] \
[regexp {Enter SQL statements} $res]
} {0 1 1}
# -batch force batch I/O
do_test shell1-1.8.1 {
catchcmd "-batch test.db" ""
} {0 {}}
# -column set output mode to 'column'
do_test shell1-1.9.1 {
catchcmd "-column test.db" ""
} {0 {}}
# -csv set output mode to 'csv'
do_test shell1-1.10.1 {
catchcmd "-csv test.db" ""
} {0 {}}
# -html set output mode to HTML
do_test shell1-1.11.1 {
catchcmd "-html test.db" ""
} {0 {}}
# -line set output mode to 'line'
do_test shell1-1.12.1 {
catchcmd "-line test.db" ""
} {0 {}}
# -list set output mode to 'list'
do_test shell1-1.13.1 {
catchcmd "-list test.db" ""
} {0 {}}
# -separator 'x' set output field separator (|)
do_test shell1-1.14.1 {
catchcmd "-separator 'x' test.db" ""
} {0 {}}
do_test shell1-1.14.2 {
catchcmd "-separator x test.db" ""
} {0 {}}
do_test shell1-1.14.3 {
set res [catchcmd "-separator" ""]
set rc [lindex $res 0]
list $rc \
[regexp {Error: missing argument for option: -separator} $res]
} {1 1}
# -nullvalue 'text' set text string for NULL values
do_test shell1-1.15.1 {
catchcmd "-nullvalue 'x' test.db" ""
} {0 {}}
do_test shell1-1.15.2 {
catchcmd "-nullvalue x test.db" ""
} {0 {}}
do_test shell1-1.15.3 {
set res [catchcmd "-nullvalue" ""]
set rc [lindex $res 0]
list $rc \
[regexp {Error: missing argument for option: -nullvalue} $res]
} {1 1}
# -version show SQLite version
do_test shell1-1.16.1 {
catchcmd "-version test.db" ""
} {0 3.6.20}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Test cases shell1-1.* Basic "dot" command token parsing. # Test cases shell1-2.*: Basic "dot" command token parsing.
# #
# check first token handling # check first token handling
do_test shell1-1.1.1 { do_test shell1-2.1.1 {
catchcmd ".foo" catchcmd " test.db" ".foo"
} {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}}
do_test shell1-1.1.2 { do_test shell1-2.1.2 {
catchcmd ".\"foo OFF\"" catchcmd " test.db" ".\"foo OFF\""
} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
do_test shell1-1.1.3 { do_test shell1-2.1.3 {
catchcmd ".\'foo OFF\'" catchcmd " test.db" ".\'foo OFF\'"
} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
# unbalanced quotes # unbalanced quotes
do_test shell1-1.2.1 { do_test shell1-2.2.1 {
catchcmd ".\"foo OFF" catchcmd " test.db" ".\"foo OFF"
} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
do_test shell1-1.2.2 { do_test shell1-2.2.2 {
catchcmd ".\'foo OFF" catchcmd " test.db" ".\'foo OFF"
} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
do_test shell1-1.2.3 { do_test shell1-2.2.3 {
catchcmd ".explain \"OFF" catchcmd " test.db" ".explain \"OFF"
} {0 {}} } {0 {}}
do_test shell1-1.2.4 { do_test shell1-2.2.4 {
catchcmd ".explain \'OFF" catchcmd " test.db" ".explain \'OFF"
} {0 {}} } {0 {}}
do_test shell1-1.2.5 { do_test shell1-2.2.5 {
catchcmd ".mode \"insert FOO" catchcmd " test.db" ".mode \"insert FOO"
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
do_test shell1-1.2.6 { do_test shell1-2.2.6 {
catchcmd ".mode \'insert FOO" catchcmd " test.db" ".mode \'insert FOO"
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
# check multiple tokens, and quoted tokens # check multiple tokens, and quoted tokens
do_test shell1-1.3.1 { do_test shell1-2.3.1 {
catchcmd ".explain 1" catchcmd " test.db" ".explain 1"
} {0 {}} } {0 {}}
do_test shell1-1.3.2 { do_test shell1-2.3.2 {
catchcmd ".explain on" catchcmd " test.db" ".explain on"
} {0 {}} } {0 {}}
do_test shell1-1.3.3 { do_test shell1-2.3.3 {
catchcmd ".explain \"1 2 3\"" catchcmd " test.db" ".explain \"1 2 3\""
} {0 {}} } {0 {}}
do_test shell1-1.3.4 { do_test shell1-2.3.4 {
catchcmd ".explain \"OFF\"" catchcmd " test.db" ".explain \"OFF\""
} {0 {}} } {0 {}}
do_test shell1-1.3.5 { do_test shell1-2.3.5 {
catchcmd ".\'explain\' \'OFF\'" catchcmd " test.db" ".\'explain\' \'OFF\'"
} {0 {}} } {0 {}}
do_test shell1-1.3.6 { do_test shell1-2.3.6 {
catchcmd ".explain \'OFF\'" catchcmd " test.db" ".explain \'OFF\'"
} {0 {}} } {0 {}}
do_test shell1-1.3.7 { do_test shell1-2.3.7 {
catchcmd ".\'explain\' \'OFF\'" catchcmd " test.db" ".\'explain\' \'OFF\'"
} {0 {}} } {0 {}}
# check quoted args are unquoted # check quoted args are unquoted
do_test shell1-1.4.1 { do_test shell1-2.4.1 {
catchcmd ".mode FOO" catchcmd " test.db" ".mode FOO"
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
do_test shell1-1.4.2 { do_test shell1-2.4.2 {
catchcmd ".mode csv" catchcmd " test.db" ".mode csv"
} {0 {}} } {0 {}}
do_test shell1-1.4.2 { do_test shell1-2.4.2 {
catchcmd ".mode \"csv\"" catchcmd " test.db" ".mode \"csv\""
} {0 {}} } {0 {}}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Test cases shell1-2.* Basic test that "dot" command can be called. # Test cases shell1-3.*: Basic test that "dot" command can be called.
# #
# .backup ?DB? FILE Backup DB (default "main") to FILE # .backup ?DB? FILE Backup DB (default "main") to FILE
do_test shell1-2.1.1 { do_test shell1-3.1.1 {
catchcmd ".backup" catchcmd " test.db" ".backup"
} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}}
do_test shell1-2.1.2 { do_test shell1-3.1.2 {
# catchcmd ".backup FOO" # catchcmd " test.db" ".backup FOO"
#TBD!!! this asserts currently #TBD!!! this asserts currently
} {} } {}
do_test shell1-2.1.3 { do_test shell1-3.1.3 {
catchcmd ".backup FOO BAR" catchcmd " test.db" ".backup FOO BAR"
} {1 {Error: unknown database FOO}} } {1 {Error: unknown database FOO}}
do_test shell1-2.1.4 { do_test shell1-3.1.4 {
# too many arguments # too many arguments
catchcmd ".backup FOO BAR BAD" catchcmd " test.db" ".backup FOO BAR BAD"
} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}}
# .bail ON|OFF Stop after hitting an error. Default OFF # .bail ON|OFF Stop after hitting an error. Default OFF
do_test shell1-2.2.1 { do_test shell1-3.2.1 {
catchcmd ".bail" catchcmd " test.db" ".bail"
} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}}
do_test shell1-2.2.2 { do_test shell1-3.2.2 {
catchcmd ".bail ON" catchcmd " test.db" ".bail ON"
} {0 {}} } {0 {}}
do_test shell1-2.2.3 { do_test shell1-3.2.3 {
catchcmd ".bail OFF" catchcmd " test.db" ".bail OFF"
} {0 {}} } {0 {}}
do_test shell1-2.2.4 { do_test shell1-3.2.4 {
# too many arguments # too many arguments
catchcmd ".bail OFF BAD" catchcmd " test.db" ".bail OFF BAD"
} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}}
# .databases List names and files of attached databases # .databases List names and files of attached databases
do_test shell1-2.3.1 { do_test shell1-3.3.1 {
set res [catchcmd ".databases"] set res [catchcmd " test.db" ".databases"]
regexp {0.*main.*test\.db} $res regexp {0.*main.*test\.db} $res
} {1} } {1}
do_test shell1-2.3.2 { do_test shell1-3.3.2 {
# too many arguments # too many arguments
catchcmd ".databases BAD" catchcmd " test.db" ".databases BAD"
} {1 {Error: unknown command or invalid arguments: "databases". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "databases". Enter ".help" for help}}
# .dump ?TABLE? ... Dump the database in an SQL text format # .dump ?TABLE? ... Dump the database in an SQL text format
# If TABLE specified, only dump tables matching # If TABLE specified, only dump tables matching
# LIKE pattern TABLE. # LIKE pattern TABLE.
do_test shell1-2.4.1 { do_test shell1-3.4.1 {
set res [catchcmd ".dump"] set res [catchcmd " test.db" ".dump"]
list [regexp {BEGIN TRANSACTION;} $res] \ list [regexp {BEGIN TRANSACTION;} $res] \
[regexp {COMMIT;} $res] [regexp {COMMIT;} $res]
} {1 1} } {1 1}
do_test shell1-2.4.2 { do_test shell1-3.4.2 {
set res [catchcmd ".dump FOO"] set res [catchcmd " test.db" ".dump FOO"]
list [regexp {BEGIN TRANSACTION;} $res] \ list [regexp {BEGIN TRANSACTION;} $res] \
[regexp {COMMIT;} $res] [regexp {COMMIT;} $res]
} {1 1} } {1 1}
do_test shell1-2.4.3 { do_test shell1-3.4.3 {
# too many arguments # too many arguments
catchcmd ".dump FOO BAD" catchcmd " test.db" ".dump FOO BAD"
} {1 {Error: unknown command or invalid arguments: "dump". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "dump". Enter ".help" for help}}
# .echo ON|OFF Turn command echo on or off # .echo ON|OFF Turn command echo on or off
do_test shell1-2.5.1 { do_test shell1-3.5.1 {
catchcmd ".echo" catchcmd " test.db" ".echo"
} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}}
do_test shell1-2.5.2 { do_test shell1-3.5.2 {
catchcmd ".echo ON" catchcmd " test.db" ".echo ON"
} {0 {}} } {0 {}}
do_test shell1-2.5.3 { do_test shell1-3.5.3 {
catchcmd ".echo OFF" catchcmd " test.db" ".echo OFF"
} {0 {}} } {0 {}}
do_test shell1-2.5.4 { do_test shell1-3.5.4 {
# too many arguments # too many arguments
catchcmd ".echo OFF BAD" catchcmd " test.db" ".echo OFF BAD"
} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}}
# .exit Exit this program # .exit Exit this program
do_test shell1-2.6.1 { do_test shell1-3.6.1 {
catchcmd ".exit" catchcmd " test.db" ".exit"
} {0 {}} } {0 {}}
do_test shell1-2.6.2 { do_test shell1-3.6.2 {
# too many arguments # too many arguments
catchcmd ".exit BAD" catchcmd " test.db" ".exit BAD"
} {1 {Error: unknown command or invalid arguments: "exit". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "exit". Enter ".help" for help}}
# .explain ON|OFF Turn output mode suitable for EXPLAIN on or off. # .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
do_test shell1-2.7.1 { do_test shell1-3.7.1 {
catchcmd ".explain" catchcmd " test.db" ".explain"
# explain is the exception to the booleans. without an option, it turns it on. # explain is the exception to the booleans. without an option, it turns it on.
} {0 {}} } {0 {}}
do_test shell1-2.7.2 { do_test shell1-3.7.2 {
catchcmd ".explain ON" catchcmd " test.db" ".explain ON"
} {0 {}} } {0 {}}
do_test shell1-2.7.3 { do_test shell1-3.7.3 {
catchcmd ".explain OFF" catchcmd " test.db" ".explain OFF"
} {0 {}} } {0 {}}
do_test shell1-2.7.4 { do_test shell1-3.7.4 {
# too many arguments # too many arguments
catchcmd ".explain OFF BAD" catchcmd " test.db" ".explain OFF BAD"
} {1 {Error: unknown command or invalid arguments: "explain". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "explain". Enter ".help" for help}}
# .genfkey ?OPTIONS? Options are: # .genfkey ?OPTIONS? Options are:
@@ -235,53 +376,53 @@ do_test shell1-2.7.4 {
# --exec: Execute generated SQL immediately # --exec: Execute generated SQL immediately
# See file tool/genfkey.README in the source # See file tool/genfkey.README in the source
# distribution for further information. # distribution for further information.
do_test shell1-2.8.1 { do_test shell1-3.8.1 {
catchcmd ".genfkey" catchcmd " test.db" ".genfkey"
} {0 {}} } {0 {}}
do_test shell1-2.8.2 { do_test shell1-3.8.2 {
catchcmd ".genfkey FOO" catchcmd " test.db" ".genfkey FOO"
} {1 {unknown option: FOO}} } {1 {unknown option: FOO}}
# .header(s) ON|OFF Turn display of headers on or off # .header(s) ON|OFF Turn display of headers on or off
do_test shell1-2.9.1 { do_test shell1-3.9.1 {
catchcmd ".header" catchcmd " test.db" ".header"
} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}}
do_test shell1-2.9.2 { do_test shell1-3.9.2 {
catchcmd ".header ON" catchcmd " test.db" ".header ON"
} {0 {}} } {0 {}}
do_test shell1-2.9.3 { do_test shell1-3.9.3 {
catchcmd ".header OFF" catchcmd " test.db" ".header OFF"
} {0 {}} } {0 {}}
do_test shell1-2.9.4 { do_test shell1-3.9.4 {
# too many arguments # too many arguments
catchcmd ".header OFF BAD" catchcmd " test.db" ".header OFF BAD"
} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}}
do_test shell1-2.9.5 { do_test shell1-3.9.5 {
catchcmd ".headers" catchcmd " test.db" ".headers"
} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}}
do_test shell1-2.9.6 { do_test shell1-3.9.6 {
catchcmd ".headers ON" catchcmd " test.db" ".headers ON"
} {0 {}} } {0 {}}
do_test shell1-2.9.7 { do_test shell1-3.9.7 {
catchcmd ".headers OFF" catchcmd " test.db" ".headers OFF"
} {0 {}} } {0 {}}
do_test shell1-2.9.8 { do_test shell1-3.9.8 {
# too many arguments # too many arguments
catchcmd ".headers OFF BAD" catchcmd " test.db" ".headers OFF BAD"
} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}}
# .help Show this message # .help Show this message
do_test shell1-2.10.1 { do_test shell1-3.10.1 {
set res [catchcmd ".help"] set res [catchcmd " test.db" ".help"]
# look for a few of the possible help commands # look for a few of the possible help commands
list [regexp {.help} $res] \ list [regexp {.help} $res] \
[regexp {.quit} $res] \ [regexp {.quit} $res] \
[regexp {.show} $res] [regexp {.show} $res]
} {1 1 1} } {1 1 1}
do_test shell1-2.10.2 { do_test shell1-3.10.2 {
# we allow .help to take extra args (it is help after all) # we allow .help to take extra args (it is help after all)
set res [catchcmd ".help BAD"] set res [catchcmd " test.db" ".help BAD"]
# look for a few of the possible help commands # look for a few of the possible help commands
list [regexp {.help} $res] \ list [regexp {.help} $res] \
[regexp {.quit} $res] \ [regexp {.quit} $res] \
@@ -289,32 +430,32 @@ do_test shell1-2.10.2 {
} {1 1 1} } {1 1 1}
# .import FILE TABLE Import data from FILE into TABLE # .import FILE TABLE Import data from FILE into TABLE
do_test shell1-2.11.1 { do_test shell1-3.11.1 {
catchcmd ".import" catchcmd " test.db" ".import"
} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
do_test shell1-2.11.2 { do_test shell1-3.11.2 {
catchcmd ".import FOO" catchcmd " test.db" ".import FOO"
} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
do_test shell1-2.11.2 { do_test shell1-3.11.2 {
catchcmd ".import FOO BAR" catchcmd " test.db" ".import FOO BAR"
} {1 {Error: no such table: BAR}} } {1 {Error: no such table: BAR}}
do_test shell1-2.11.3 { do_test shell1-3.11.3 {
# too many arguments # too many arguments
catchcmd ".import FOO BAR BAD" catchcmd " test.db" ".import FOO BAR BAD"
} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
# .indices ?TABLE? Show names of all indices # .indices ?TABLE? Show names of all indices
# If TABLE specified, only show indices for tables # If TABLE specified, only show indices for tables
# matching LIKE pattern TABLE. # matching LIKE pattern TABLE.
do_test shell1-2.12.1 { do_test shell1-3.12.1 {
catchcmd ".indices" catchcmd " test.db" ".indices"
} {0 {}} } {0 {}}
do_test shell1-2.12.2 { do_test shell1-3.12.2 {
catchcmd ".indices FOO" catchcmd " test.db" ".indices FOO"
} {0 {}} } {0 {}}
do_test shell1-2.12.3 { do_test shell1-3.12.3 {
# too many arguments # too many arguments
catchcmd ".indices FOO BAD" catchcmd " test.db" ".indices FOO BAD"
} {1 {Error: unknown command or invalid arguments: "indices". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "indices". Enter ".help" for help}}
# .mode MODE ?TABLE? Set output mode where MODE is one of: # .mode MODE ?TABLE? Set output mode where MODE is one of:
@@ -326,167 +467,167 @@ do_test shell1-2.12.3 {
# list Values delimited by .separator string # list Values delimited by .separator string
# tabs Tab-separated values # tabs Tab-separated values
# tcl TCL list elements # tcl TCL list elements
do_test shell1-2.13.1 { do_test shell1-3.13.1 {
catchcmd ".mode" catchcmd " test.db" ".mode"
} {1 {Error: unknown command or invalid arguments: "mode". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "mode". Enter ".help" for help}}
do_test shell1-2.13.2 { do_test shell1-3.13.2 {
catchcmd ".mode FOO" catchcmd " test.db" ".mode FOO"
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
do_test shell1-2.13.3 { do_test shell1-3.13.3 {
catchcmd ".mode csv" catchcmd " test.db" ".mode csv"
} {0 {}} } {0 {}}
do_test shell1-2.13.4 { do_test shell1-3.13.4 {
catchcmd ".mode column" catchcmd " test.db" ".mode column"
} {0 {}} } {0 {}}
do_test shell1-2.13.5 { do_test shell1-3.13.5 {
catchcmd ".mode html" catchcmd " test.db" ".mode html"
} {0 {}} } {0 {}}
do_test shell1-2.13.6 { do_test shell1-3.13.6 {
catchcmd ".mode insert" catchcmd " test.db" ".mode insert"
} {0 {}} } {0 {}}
do_test shell1-2.13.7 { do_test shell1-3.13.7 {
catchcmd ".mode line" catchcmd " test.db" ".mode line"
} {0 {}} } {0 {}}
do_test shell1-2.13.8 { do_test shell1-3.13.8 {
catchcmd ".mode list" catchcmd " test.db" ".mode list"
} {0 {}} } {0 {}}
do_test shell1-2.13.9 { do_test shell1-3.13.9 {
catchcmd ".mode tabs" catchcmd " test.db" ".mode tabs"
} {0 {}} } {0 {}}
do_test shell1-2.13.10 { do_test shell1-3.13.10 {
catchcmd ".mode tcl" catchcmd " test.db" ".mode tcl"
} {0 {}} } {0 {}}
do_test shell1-2.13.11 { do_test shell1-3.13.11 {
# too many arguments # too many arguments
catchcmd ".mode tcl BAD" catchcmd " test.db" ".mode tcl BAD"
} {1 {Error: invalid arguments: "BAD". Enter ".help" for help}} } {1 {Error: invalid arguments: "BAD". Enter ".help" for help}}
# don't allow partial mode type matches # don't allow partial mode type matches
do_test shell1-2.13.12 { do_test shell1-3.13.12 {
catchcmd ".mode l" catchcmd " test.db" ".mode l"
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
do_test shell1-2.13.13 { do_test shell1-3.13.13 {
catchcmd ".mode li" catchcmd " test.db" ".mode li"
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
do_test shell1-2.13.14 { do_test shell1-3.13.14 {
catchcmd ".mode lin" catchcmd " test.db" ".mode lin"
} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
# .nullvalue STRING Print STRING in place of NULL values # .nullvalue STRING Print STRING in place of NULL values
do_test shell1-2.14.1 { do_test shell1-3.14.1 {
catchcmd ".nullvalue" catchcmd " test.db" ".nullvalue"
} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}}
do_test shell1-2.14.2 { do_test shell1-3.14.2 {
catchcmd ".nullvalue FOO" catchcmd " test.db" ".nullvalue FOO"
} {0 {}} } {0 {}}
do_test shell1-2.14.3 { do_test shell1-3.14.3 {
# too many arguments # too many arguments
catchcmd ".nullvalue FOO BAD" catchcmd " test.db" ".nullvalue FOO BAD"
} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}}
# .output FILENAME Send output to FILENAME # .output FILENAME Send output to FILENAME
do_test shell1-2.15.1 { do_test shell1-3.15.1 {
catchcmd ".output" catchcmd " test.db" ".output"
} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
do_test shell1-2.15.2 { do_test shell1-3.15.2 {
catchcmd ".output FOO" catchcmd " test.db" ".output FOO"
} {0 {}} } {0 {}}
do_test shell1-2.15.3 { do_test shell1-3.15.3 {
# too many arguments # too many arguments
catchcmd ".output FOO BAD" catchcmd " test.db" ".output FOO BAD"
} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
# .output stdout Send output to the screen # .output stdout Send output to the screen
do_test shell1-2.16.1 { do_test shell1-3.16.1 {
catchcmd ".output stdout" catchcmd " test.db" ".output stdout"
} {0 {}} } {0 {}}
do_test shell1-2.16.2 { do_test shell1-3.16.2 {
# too many arguments # too many arguments
catchcmd ".output stdout BAD" catchcmd " test.db" ".output stdout BAD"
} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
# .prompt MAIN CONTINUE Replace the standard prompts # .prompt MAIN CONTINUE Replace the standard prompts
do_test shell1-2.17.1 { do_test shell1-3.17.1 {
catchcmd ".prompt" catchcmd " test.db" ".prompt"
} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}}
do_test shell1-2.17.2 { do_test shell1-3.17.2 {
catchcmd ".prompt FOO" catchcmd " test.db" ".prompt FOO"
} {0 {}} } {0 {}}
do_test shell1-2.17.3 { do_test shell1-3.17.3 {
catchcmd ".prompt FOO BAR" catchcmd " test.db" ".prompt FOO BAR"
} {0 {}} } {0 {}}
do_test shell1-2.17.4 { do_test shell1-3.17.4 {
# too many arguments # too many arguments
catchcmd ".prompt FOO BAR BAD" catchcmd " test.db" ".prompt FOO BAR BAD"
} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}}
# .quit Exit this program # .quit Exit this program
do_test shell1-2.18.1 { do_test shell1-3.18.1 {
catchcmd ".quit" catchcmd " test.db" ".quit"
} {0 {}} } {0 {}}
do_test shell1-2.18.2 { do_test shell1-3.18.2 {
# too many arguments # too many arguments
catchcmd ".quit BAD" catchcmd " test.db" ".quit BAD"
} {1 {Error: unknown command or invalid arguments: "quit". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "quit". Enter ".help" for help}}
# .read FILENAME Execute SQL in FILENAME # .read FILENAME Execute SQL in FILENAME
do_test shell1-2.19.1 { do_test shell1-3.19.1 {
catchcmd ".read" catchcmd " test.db" ".read"
} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}}
do_test shell1-2.19.2 { do_test shell1-3.19.2 {
file delete -force FOO file delete -force FOO
catchcmd ".read FOO" catchcmd " test.db" ".read FOO"
} {1 {Error: cannot open "FOO"}} } {1 {Error: cannot open "FOO"}}
do_test shell1-2.19.3 { do_test shell1-3.19.3 {
# too many arguments # too many arguments
catchcmd ".read FOO BAD" catchcmd " test.db" ".read FOO BAD"
} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}}
# .restore ?DB? FILE Restore content of DB (default "main") from FILE # .restore ?DB? FILE Restore content of DB (default "main") from FILE
do_test shell1-2.20.1 { do_test shell1-3.20.1 {
catchcmd ".restore" catchcmd " test.db" ".restore"
} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}}
do_test shell1-2.20.2 { do_test shell1-3.20.2 {
# catchcmd ".restore FOO" # catchcmd " test.db" ".restore FOO"
#TBD!!! this asserts currently #TBD!!! this asserts currently
} {} } {}
do_test shell1-2.20.3 { do_test shell1-3.20.3 {
catchcmd ".restore FOO BAR" catchcmd " test.db" ".restore FOO BAR"
} {1 {Error: unknown database FOO}} } {1 {Error: unknown database FOO}}
do_test shell1-2.20.4 { do_test shell1-3.20.4 {
# too many arguments # too many arguments
catchcmd ".restore FOO BAR BAD" catchcmd " test.db" ".restore FOO BAR BAD"
} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}}
# .schema ?TABLE? Show the CREATE statements # .schema ?TABLE? Show the CREATE statements
# If TABLE specified, only show tables matching # If TABLE specified, only show tables matching
# LIKE pattern TABLE. # LIKE pattern TABLE.
do_test shell1-2.21.1 { do_test shell1-3.21.1 {
catchcmd ".schema" catchcmd " test.db" ".schema"
} {0 {}} } {0 {}}
do_test shell1-2.21.2 { do_test shell1-3.21.2 {
catchcmd ".schema FOO" catchcmd " test.db" ".schema FOO"
} {0 {}} } {0 {}}
do_test shell1-2.21.3 { do_test shell1-3.21.3 {
# too many arguments # too many arguments
catchcmd ".schema FOO BAD" catchcmd " test.db" ".schema FOO BAD"
} {1 {Error: unknown command or invalid arguments: "schema". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "schema". Enter ".help" for help}}
# .separator STRING Change separator used by output mode and .import # .separator STRING Change separator used by output mode and .import
do_test shell1-2.22.1 { do_test shell1-3.22.1 {
catchcmd ".separator" catchcmd " test.db" ".separator"
} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}}
do_test shell1-2.22.2 { do_test shell1-3.22.2 {
catchcmd ".separator FOO" catchcmd " test.db" ".separator FOO"
} {0 {}} } {0 {}}
do_test shell1-2.22.3 { do_test shell1-3.22.3 {
# too many arguments # too many arguments
catchcmd ".separator FOO BAD" catchcmd " test.db" ".separator FOO BAD"
} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}}
# .show Show the current values for various settings # .show Show the current values for various settings
do_test shell1-2.23.1 { do_test shell1-3.23.1 {
set res [catchcmd ".show"] set res [catchcmd " test.db" ".show"]
list [regexp {echo:} $res] \ list [regexp {echo:} $res] \
[regexp {explain:} $res] \ [regexp {explain:} $res] \
[regexp {headers:} $res] \ [regexp {headers:} $res] \
@@ -496,71 +637,71 @@ do_test shell1-2.23.1 {
[regexp {separator:} $res] \ [regexp {separator:} $res] \
[regexp {width:} $res] [regexp {width:} $res]
} {1 1 1 1 1 1 1 1} } {1 1 1 1 1 1 1 1}
do_test shell1-2.23.2 { do_test shell1-3.23.2 {
# too many arguments # too many arguments
catchcmd ".show BAD" catchcmd " test.db" ".show BAD"
} {1 {Error: unknown command or invalid arguments: "show". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "show". Enter ".help" for help}}
# .tables ?TABLE? List names of tables # .tables ?TABLE? List names of tables
# If TABLE specified, only list tables matching # If TABLE specified, only list tables matching
# LIKE pattern TABLE. # LIKE pattern TABLE.
do_test shell1-2.24.1 { do_test shell1-3.24.1 {
catchcmd ".tables" catchcmd " test.db" ".tables"
} {0 {}} } {0 {}}
do_test shell1-2.24.2 { do_test shell1-3.24.2 {
catchcmd ".tables FOO" catchcmd " test.db" ".tables FOO"
} {0 {}} } {0 {}}
do_test shell1-2.24.3 { do_test shell1-3.24.3 {
# too many arguments # too many arguments
catchcmd ".tables FOO BAD" catchcmd " test.db" ".tables FOO BAD"
} {1 {Error: unknown command or invalid arguments: "tables". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "tables". Enter ".help" for help}}
# .timeout MS Try opening locked tables for MS milliseconds # .timeout MS Try opening locked tables for MS milliseconds
do_test shell1-2.25.1 { do_test shell1-3.25.1 {
catchcmd ".timeout" catchcmd " test.db" ".timeout"
} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}}
do_test shell1-2.25.2 { do_test shell1-3.25.2 {
catchcmd ".timeout zzz" catchcmd " test.db" ".timeout zzz"
# this should be treated the same as a '0' timeout # this should be treated the same as a '0' timeout
} {0 {}} } {0 {}}
do_test shell1-2.25.3 { do_test shell1-3.25.3 {
catchcmd ".timeout 1" catchcmd " test.db" ".timeout 1"
} {0 {}} } {0 {}}
do_test shell1-2.25.4 { do_test shell1-3.25.4 {
# too many arguments # too many arguments
catchcmd ".timeout 1 BAD" catchcmd " test.db" ".timeout 1 BAD"
} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}}
# .width NUM NUM ... Set column widths for "column" mode # .width NUM NUM ... Set column widths for "column" mode
do_test shell1-2.26.1 { do_test shell1-3.26.1 {
catchcmd ".width" catchcmd " test.db" ".width"
} {1 {Error: unknown command or invalid arguments: "width". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "width". Enter ".help" for help}}
do_test shell1-2.26.2 { do_test shell1-3.26.2 {
catchcmd ".width xxx" catchcmd " test.db" ".width xxx"
# this should be treated the same as a '0' width for col 1 # this should be treated the same as a '0' width for col 1
} {0 {}} } {0 {}}
do_test shell1-2.26.3 { do_test shell1-3.26.3 {
catchcmd ".width xxx yyy" catchcmd " test.db" ".width xxx yyy"
# this should be treated the same as a '0' width for col 1 and 2 # this should be treated the same as a '0' width for col 1 and 2
} {0 {}} } {0 {}}
do_test shell1-2.26.4 { do_test shell1-3.26.4 {
catchcmd ".width 1 1" catchcmd " test.db" ".width 1 1"
# this should be treated the same as a '1' width for col 1 and 2 # this should be treated the same as a '1' width for col 1 and 2
} {0 {}} } {0 {}}
# .timer ON|OFF Turn the CPU timer measurement on or off # .timer ON|OFF Turn the CPU timer measurement on or off
do_test shell1-2.27.1 { do_test shell1-3.27.1 {
catchcmd ".timer" catchcmd " test.db" ".timer"
} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}}
do_test shell1-2.27.2 { do_test shell1-3.27.2 {
catchcmd ".timer ON" catchcmd " test.db" ".timer ON"
} {0 {}} } {0 {}}
do_test shell1-2.27.3 { do_test shell1-3.27.3 {
catchcmd ".timer OFF" catchcmd " test.db" ".timer OFF"
} {0 {}} } {0 {}}
do_test shell1-2.27.4 { do_test shell1-3.27.4 {
# too many arguments # too many arguments
catchcmd ".timer OFF BAD" catchcmd " test.db" ".timer OFF BAD"
} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}} } {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}}
# #

View File

@@ -21,6 +21,8 @@
package require sqlite3 package require sqlite3
set CLI "./sqlite"
proc do_test {name cmd expected} { proc do_test {name cmd expected} {
puts -nonewline "$name ..." puts -nonewline "$name ..."
set res [uplevel $cmd] set res [uplevel $cmd]
@@ -43,11 +45,13 @@ proc catchsql {sql} {
list $rc $msg list $rc $msg
} }
proc catchcmd {options db cmd} { proc catchcmd {db cmd} {
global CLI
set out [open cmds.txt w] set out [open cmds.txt w]
puts $out $cmd puts $out $cmd
close $out close $out
set rc [catch { exec ./sqlite $options $db < cmds.txt } msg] set line "exec $CLI $db < cmds.txt"
set rc [catch { eval $line } msg]
list $rc $msg list $rc $msg
} }
@@ -60,12 +64,22 @@ sqlite3 db test.db
# #
# Batch mode not creating databases. # Batch mode not creating databases.
# Reported on mailing list by Ken Zalewski <kennyz@nycap.rr.com>. # Reported on mailing list by Ken Zalewski.
# Ticket [aeff892c57]. # Ticket [aeff892c57].
do_test shell2-1.1.1 { do_test shell2-1.1.1 {
file delete -force foo.db file delete -force foo.db
set rc [ catchcmd "-batch" "foo.db" "CREATE TABLE t1(a);" ] set rc [ catchcmd "-batch foo.db" "CREATE TABLE t1(a);" ]
set fexist [file exist foo.db] set fexist [file exist foo.db]
list $rc $fexist list $rc $fexist
} {{0 {}} 1} } {{0 {}} 1}
# Shell silently ignores extra parameters.
# Ticket [f5cb008a65].
do_test shell2-1.2.1 {
set rc [catch { eval exec $CLI \":memory:\" \"select 3\" \"select 4\" } msg]
list $rc \
[regexp {Error: too many options: "select 4"} $msg]
} {1 1}