blob: f21601a456a23a8a2922b027188d8223d8e985c7 [file] [log] [blame]
shaneha05e0c42009-11-06 03:22:54 +00001# 2009 Nov 11
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12# The focus of this file is testing the CLI shell tool.
13#
14# $Id: shell1.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
15#
16
17# Test plan:
18#
shaneh5fc25012009-11-11 04:17:07 +000019# shell1-1.*: Basic command line option handling.
20# shell1-2.*: Basic "dot" command token parsing.
21# shell1-3.*: Basic test that "dot" command can be called.
shaneha05e0c42009-11-06 03:22:54 +000022#
23
24package require sqlite3
25
shanehca7dfda2009-12-17 21:07:54 +000026set CLI "./sqlite3"
shaneh5fc25012009-11-11 04:17:07 +000027
shaneha05e0c42009-11-06 03:22:54 +000028proc do_test {name cmd expected} {
29 puts -nonewline "$name ..."
30 set res [uplevel $cmd]
31 if {$res eq $expected} {
32 puts Ok
33 } else {
34 puts Error
35 puts " Got: $res"
36 puts " Expected: $expected"
shanehe2aa9d72009-11-06 17:20:17 +000037 exit
shaneha05e0c42009-11-06 03:22:54 +000038 }
39}
40
41proc execsql {sql} {
42 uplevel [list db eval $sql]
43}
44
45proc catchsql {sql} {
46 set rc [catch {uplevel [list db eval $sql]} msg]
47 list $rc $msg
48}
49
shanehca7dfda2009-12-17 21:07:54 +000050proc catchcmd {db {cmd ""}} {
shaneh5fc25012009-11-11 04:17:07 +000051 global CLI
shaneha05e0c42009-11-06 03:22:54 +000052 set out [open cmds.txt w]
53 puts $out $cmd
54 close $out
shaneh5fc25012009-11-11 04:17:07 +000055 set line "exec $CLI $db < cmds.txt"
56 set rc [catch { eval $line } msg]
shaneha05e0c42009-11-06 03:22:54 +000057 list $rc $msg
58}
59
60file delete -force test.db test.db.journal
61sqlite3 db test.db
62
shaneh5fc25012009-11-11 04:17:07 +000063#----------------------------------------------------------------------------
64# Test cases shell1-1.*: Basic command line option handling.
65#
66
67# invalid option
68do_test shell1-1.1.1 {
69 set res [catchcmd "-bad test.db" ""]
70 set rc [lindex $res 0]
71 list $rc \
72 [regexp {Error: unknown option: -bad} $res]
73} {1 1}
74# error on extra options
75do_test shell1-1.1.2 {
76 set res [catchcmd "-bad test.db \"select 3\" \"select 4\"" ""]
77 set rc [lindex $res 0]
78 list $rc \
79 [regexp {Error: too many options: "select 4"} $res]
80} {1 1}
81# error on extra options
shanehca7dfda2009-12-17 21:07:54 +000082do_test shell1-1.1.3 {
shaneh5fc25012009-11-11 04:17:07 +000083 set res [catchcmd "-bad FOO test.db BAD" ".quit"]
84 set rc [lindex $res 0]
85 list $rc \
86 [regexp {Error: too many options: "BAD"} $res]
87} {1 1}
88
89# -help
90do_test shell1-1.2.1 {
91 set res [catchcmd "-help test.db" ""]
92 set rc [lindex $res 0]
93 list $rc \
94 [regexp {Usage} $res] \
95 [regexp {\-init} $res] \
96 [regexp {\-version} $res]
97} {1 1 1 1}
98
99# -init filename read/process named file
100do_test shell1-1.3.1 {
shanehca7dfda2009-12-17 21:07:54 +0000101 catchcmd "-init FOO test.db" ""
shaneh5fc25012009-11-11 04:17:07 +0000102} {0 {}}
103do_test shell1-1.3.2 {
104 set res [catchcmd "-init FOO test.db .quit BAD" ""]
105 set rc [lindex $res 0]
106 list $rc \
107 [regexp {Error: too many options: "BAD"} $res]
108} {1 1}
109
110# -echo print commands before execution
111do_test shell1-1.4.1 {
112 catchcmd "-echo test.db" ""
113} {0 {}}
114
115# -[no]header turn headers on or off
116do_test shell1-1.5.1 {
117 catchcmd "-header test.db" ""
118} {0 {}}
119do_test shell1-1.5.2 {
120 catchcmd "-noheader test.db" ""
121} {0 {}}
122
123# -bail stop after hitting an error
124do_test shell1-1.6.1 {
125 catchcmd "-bail test.db" ""
126} {0 {}}
127
128# -interactive force interactive I/O
129do_test shell1-1.7.1 {
130 set res [catchcmd "-interactive test.db" ".quit"]
131 set rc [lindex $res 0]
132 list $rc \
133 [regexp {SQLite version} $res] \
134 [regexp {Enter SQL statements} $res]
135} {0 1 1}
136
137# -batch force batch I/O
138do_test shell1-1.8.1 {
139 catchcmd "-batch test.db" ""
140} {0 {}}
141
142# -column set output mode to 'column'
143do_test shell1-1.9.1 {
144 catchcmd "-column test.db" ""
145} {0 {}}
146
147# -csv set output mode to 'csv'
148do_test shell1-1.10.1 {
149 catchcmd "-csv test.db" ""
150} {0 {}}
151
152# -html set output mode to HTML
153do_test shell1-1.11.1 {
154 catchcmd "-html test.db" ""
155} {0 {}}
156
157# -line set output mode to 'line'
158do_test shell1-1.12.1 {
159 catchcmd "-line test.db" ""
160} {0 {}}
161
162# -list set output mode to 'list'
163do_test shell1-1.13.1 {
164 catchcmd "-list test.db" ""
165} {0 {}}
166
167# -separator 'x' set output field separator (|)
168do_test shell1-1.14.1 {
169 catchcmd "-separator 'x' test.db" ""
170} {0 {}}
171do_test shell1-1.14.2 {
172 catchcmd "-separator x test.db" ""
173} {0 {}}
174do_test shell1-1.14.3 {
175 set res [catchcmd "-separator" ""]
176 set rc [lindex $res 0]
177 list $rc \
178 [regexp {Error: missing argument for option: -separator} $res]
179} {1 1}
180
shaneh642d8b82010-07-28 16:05:34 +0000181# -stats print memory stats before each finalize
182do_test shell1-1.14b.1 {
183 catchcmd "-stats test.db" ""
184} {0 {}}
185
shaneh5fc25012009-11-11 04:17:07 +0000186# -nullvalue 'text' set text string for NULL values
187do_test shell1-1.15.1 {
188 catchcmd "-nullvalue 'x' test.db" ""
189} {0 {}}
190do_test shell1-1.15.2 {
191 catchcmd "-nullvalue x test.db" ""
192} {0 {}}
193do_test shell1-1.15.3 {
194 set res [catchcmd "-nullvalue" ""]
195 set rc [lindex $res 0]
196 list $rc \
197 [regexp {Error: missing argument for option: -nullvalue} $res]
198} {1 1}
199
200# -version show SQLite version
201do_test shell1-1.16.1 {
202 catchcmd "-version test.db" ""
shaneh642d8b82010-07-28 16:05:34 +0000203} {0 3.7.1}
shanehe2aa9d72009-11-06 17:20:17 +0000204
shaneha05e0c42009-11-06 03:22:54 +0000205#----------------------------------------------------------------------------
shaneh5fc25012009-11-11 04:17:07 +0000206# Test cases shell1-2.*: Basic "dot" command token parsing.
shanehe2aa9d72009-11-06 17:20:17 +0000207#
208
209# check first token handling
shaneh5fc25012009-11-11 04:17:07 +0000210do_test shell1-2.1.1 {
shanehca7dfda2009-12-17 21:07:54 +0000211 catchcmd "test.db" ".foo"
shanehe2aa9d72009-11-06 17:20:17 +0000212} {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000213do_test shell1-2.1.2 {
shanehca7dfda2009-12-17 21:07:54 +0000214 catchcmd "test.db" ".\"foo OFF\""
shanehe2aa9d72009-11-06 17:20:17 +0000215} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000216do_test shell1-2.1.3 {
shanehca7dfda2009-12-17 21:07:54 +0000217 catchcmd "test.db" ".\'foo OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000218} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
219
220# unbalanced quotes
shaneh5fc25012009-11-11 04:17:07 +0000221do_test shell1-2.2.1 {
shanehca7dfda2009-12-17 21:07:54 +0000222 catchcmd "test.db" ".\"foo OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000223} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000224do_test shell1-2.2.2 {
shanehca7dfda2009-12-17 21:07:54 +0000225 catchcmd "test.db" ".\'foo OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000226} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000227do_test shell1-2.2.3 {
shanehca7dfda2009-12-17 21:07:54 +0000228 catchcmd "test.db" ".explain \"OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000229} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000230do_test shell1-2.2.4 {
shanehca7dfda2009-12-17 21:07:54 +0000231 catchcmd "test.db" ".explain \'OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000232} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000233do_test shell1-2.2.5 {
shanehca7dfda2009-12-17 21:07:54 +0000234 catchcmd "test.db" ".mode \"insert FOO"
shanehe2aa9d72009-11-06 17:20:17 +0000235} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000236do_test shell1-2.2.6 {
shanehca7dfda2009-12-17 21:07:54 +0000237 catchcmd "test.db" ".mode \'insert FOO"
shanehe2aa9d72009-11-06 17:20:17 +0000238} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
239
240# check multiple tokens, and quoted tokens
shaneh5fc25012009-11-11 04:17:07 +0000241do_test shell1-2.3.1 {
shanehca7dfda2009-12-17 21:07:54 +0000242 catchcmd "test.db" ".explain 1"
shanehe2aa9d72009-11-06 17:20:17 +0000243} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000244do_test shell1-2.3.2 {
shanehca7dfda2009-12-17 21:07:54 +0000245 catchcmd "test.db" ".explain on"
shanehe2aa9d72009-11-06 17:20:17 +0000246} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000247do_test shell1-2.3.3 {
shanehca7dfda2009-12-17 21:07:54 +0000248 catchcmd "test.db" ".explain \"1 2 3\""
shanehe2aa9d72009-11-06 17:20:17 +0000249} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000250do_test shell1-2.3.4 {
shanehca7dfda2009-12-17 21:07:54 +0000251 catchcmd "test.db" ".explain \"OFF\""
shanehe2aa9d72009-11-06 17:20:17 +0000252} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000253do_test shell1-2.3.5 {
shanehca7dfda2009-12-17 21:07:54 +0000254 catchcmd "test.db" ".\'explain\' \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000255} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000256do_test shell1-2.3.6 {
shanehca7dfda2009-12-17 21:07:54 +0000257 catchcmd "test.db" ".explain \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000258} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000259do_test shell1-2.3.7 {
shanehca7dfda2009-12-17 21:07:54 +0000260 catchcmd "test.db" ".\'explain\' \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000261} {0 {}}
262
263# check quoted args are unquoted
shaneh5fc25012009-11-11 04:17:07 +0000264do_test shell1-2.4.1 {
shanehca7dfda2009-12-17 21:07:54 +0000265 catchcmd "test.db" ".mode FOO"
shanehe2aa9d72009-11-06 17:20:17 +0000266} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000267do_test shell1-2.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000268 catchcmd "test.db" ".mode csv"
shanehe2aa9d72009-11-06 17:20:17 +0000269} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000270do_test shell1-2.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000271 catchcmd "test.db" ".mode \"csv\""
shanehe2aa9d72009-11-06 17:20:17 +0000272} {0 {}}
273
274
275#----------------------------------------------------------------------------
shaneh5fc25012009-11-11 04:17:07 +0000276# Test cases shell1-3.*: Basic test that "dot" command can be called.
shaneha05e0c42009-11-06 03:22:54 +0000277#
278
279# .backup ?DB? FILE Backup DB (default "main") to FILE
shaneh5fc25012009-11-11 04:17:07 +0000280do_test shell1-3.1.1 {
shanehca7dfda2009-12-17 21:07:54 +0000281 catchcmd "test.db" ".backup"
shanehe2aa9d72009-11-06 17:20:17 +0000282} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000283do_test shell1-3.1.2 {
shanehca7dfda2009-12-17 21:07:54 +0000284 catchcmd "test.db" ".backup FOO"
285} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000286do_test shell1-3.1.3 {
shanehca7dfda2009-12-17 21:07:54 +0000287 catchcmd "test.db" ".backup FOO BAR"
shanehe2aa9d72009-11-06 17:20:17 +0000288} {1 {Error: unknown database FOO}}
shaneh5fc25012009-11-11 04:17:07 +0000289do_test shell1-3.1.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000290 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000291 catchcmd "test.db" ".backup FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000292} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000293
294# .bail ON|OFF Stop after hitting an error. Default OFF
shaneh5fc25012009-11-11 04:17:07 +0000295do_test shell1-3.2.1 {
shanehca7dfda2009-12-17 21:07:54 +0000296 catchcmd "test.db" ".bail"
shaneha05e0c42009-11-06 03:22:54 +0000297} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000298do_test shell1-3.2.2 {
shanehca7dfda2009-12-17 21:07:54 +0000299 catchcmd "test.db" ".bail ON"
shaneha05e0c42009-11-06 03:22:54 +0000300} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000301do_test shell1-3.2.3 {
shanehca7dfda2009-12-17 21:07:54 +0000302 catchcmd "test.db" ".bail OFF"
shaneha05e0c42009-11-06 03:22:54 +0000303} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000304do_test shell1-3.2.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000305 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000306 catchcmd "test.db" ".bail OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000307} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000308
309# .databases List names and files of attached databases
shaneh5fc25012009-11-11 04:17:07 +0000310do_test shell1-3.3.1 {
shanehca7dfda2009-12-17 21:07:54 +0000311 set res [catchcmd "test.db" ".databases"]
shaneha05e0c42009-11-06 03:22:54 +0000312 regexp {0.*main.*test\.db} $res
313} {1}
shaneh5fc25012009-11-11 04:17:07 +0000314do_test shell1-3.3.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000315 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000316 catchcmd "test.db" ".databases BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000317} {1 {Error: unknown command or invalid arguments: "databases". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000318
319# .dump ?TABLE? ... Dump the database in an SQL text format
320# If TABLE specified, only dump tables matching
321# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000322do_test shell1-3.4.1 {
shanehca7dfda2009-12-17 21:07:54 +0000323 set res [catchcmd "test.db" ".dump"]
shaneha05e0c42009-11-06 03:22:54 +0000324 list [regexp {BEGIN TRANSACTION;} $res] \
325 [regexp {COMMIT;} $res]
326} {1 1}
shaneh5fc25012009-11-11 04:17:07 +0000327do_test shell1-3.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000328 set res [catchcmd "test.db" ".dump FOO"]
shaneha05e0c42009-11-06 03:22:54 +0000329 list [regexp {BEGIN TRANSACTION;} $res] \
330 [regexp {COMMIT;} $res]
331} {1 1}
shaneh5fc25012009-11-11 04:17:07 +0000332do_test shell1-3.4.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000333 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000334 catchcmd "test.db" ".dump FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000335} {1 {Error: unknown command or invalid arguments: "dump". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000336
337# .echo ON|OFF Turn command echo on or off
shaneh5fc25012009-11-11 04:17:07 +0000338do_test shell1-3.5.1 {
shanehca7dfda2009-12-17 21:07:54 +0000339 catchcmd "test.db" ".echo"
shaneha05e0c42009-11-06 03:22:54 +0000340} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000341do_test shell1-3.5.2 {
shanehca7dfda2009-12-17 21:07:54 +0000342 catchcmd "test.db" ".echo ON"
shaneha05e0c42009-11-06 03:22:54 +0000343} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000344do_test shell1-3.5.3 {
shanehca7dfda2009-12-17 21:07:54 +0000345 catchcmd "test.db" ".echo OFF"
shaneha05e0c42009-11-06 03:22:54 +0000346} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000347do_test shell1-3.5.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000348 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000349 catchcmd "test.db" ".echo OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000350} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000351
352# .exit Exit this program
shaneh5fc25012009-11-11 04:17:07 +0000353do_test shell1-3.6.1 {
shanehca7dfda2009-12-17 21:07:54 +0000354 catchcmd "test.db" ".exit"
shaneha05e0c42009-11-06 03:22:54 +0000355} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000356do_test shell1-3.6.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000357 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000358 catchcmd "test.db" ".exit BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000359} {1 {Error: unknown command or invalid arguments: "exit". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000360
361# .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
shaneh5fc25012009-11-11 04:17:07 +0000362do_test shell1-3.7.1 {
shanehca7dfda2009-12-17 21:07:54 +0000363 catchcmd "test.db" ".explain"
shanehe2aa9d72009-11-06 17:20:17 +0000364 # explain is the exception to the booleans. without an option, it turns it on.
365} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000366do_test shell1-3.7.2 {
shanehca7dfda2009-12-17 21:07:54 +0000367 catchcmd "test.db" ".explain ON"
shaneha05e0c42009-11-06 03:22:54 +0000368} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000369do_test shell1-3.7.3 {
shanehca7dfda2009-12-17 21:07:54 +0000370 catchcmd "test.db" ".explain OFF"
shaneha05e0c42009-11-06 03:22:54 +0000371} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000372do_test shell1-3.7.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000373 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000374 catchcmd "test.db" ".explain OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000375} {1 {Error: unknown command or invalid arguments: "explain". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000376
shaneha05e0c42009-11-06 03:22:54 +0000377
378# .header(s) ON|OFF Turn display of headers on or off
shaneh5fc25012009-11-11 04:17:07 +0000379do_test shell1-3.9.1 {
shanehca7dfda2009-12-17 21:07:54 +0000380 catchcmd "test.db" ".header"
shaneha05e0c42009-11-06 03:22:54 +0000381} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000382do_test shell1-3.9.2 {
shanehca7dfda2009-12-17 21:07:54 +0000383 catchcmd "test.db" ".header ON"
shaneha05e0c42009-11-06 03:22:54 +0000384} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000385do_test shell1-3.9.3 {
shanehca7dfda2009-12-17 21:07:54 +0000386 catchcmd "test.db" ".header OFF"
shaneha05e0c42009-11-06 03:22:54 +0000387} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000388do_test shell1-3.9.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000389 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000390 catchcmd "test.db" ".header OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000391} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}}
392
shaneh5fc25012009-11-11 04:17:07 +0000393do_test shell1-3.9.5 {
shanehca7dfda2009-12-17 21:07:54 +0000394 catchcmd "test.db" ".headers"
shaneha05e0c42009-11-06 03:22:54 +0000395} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000396do_test shell1-3.9.6 {
shanehca7dfda2009-12-17 21:07:54 +0000397 catchcmd "test.db" ".headers ON"
shaneha05e0c42009-11-06 03:22:54 +0000398} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000399do_test shell1-3.9.7 {
shanehca7dfda2009-12-17 21:07:54 +0000400 catchcmd "test.db" ".headers OFF"
shaneha05e0c42009-11-06 03:22:54 +0000401} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000402do_test shell1-3.9.8 {
shanehe2aa9d72009-11-06 17:20:17 +0000403 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000404 catchcmd "test.db" ".headers OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000405} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000406
407# .help Show this message
shaneh5fc25012009-11-11 04:17:07 +0000408do_test shell1-3.10.1 {
shanehca7dfda2009-12-17 21:07:54 +0000409 set res [catchcmd "test.db" ".help"]
shaneha05e0c42009-11-06 03:22:54 +0000410 # look for a few of the possible help commands
411 list [regexp {.help} $res] \
412 [regexp {.quit} $res] \
413 [regexp {.show} $res]
414} {1 1 1}
shaneh5fc25012009-11-11 04:17:07 +0000415do_test shell1-3.10.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000416 # we allow .help to take extra args (it is help after all)
shanehca7dfda2009-12-17 21:07:54 +0000417 set res [catchcmd "test.db" ".help BAD"]
shanehe2aa9d72009-11-06 17:20:17 +0000418 # look for a few of the possible help commands
419 list [regexp {.help} $res] \
420 [regexp {.quit} $res] \
421 [regexp {.show} $res]
422} {1 1 1}
shaneha05e0c42009-11-06 03:22:54 +0000423
424# .import FILE TABLE Import data from FILE into TABLE
shaneh5fc25012009-11-11 04:17:07 +0000425do_test shell1-3.11.1 {
shanehca7dfda2009-12-17 21:07:54 +0000426 catchcmd "test.db" ".import"
shaneha05e0c42009-11-06 03:22:54 +0000427} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000428do_test shell1-3.11.2 {
shanehca7dfda2009-12-17 21:07:54 +0000429 catchcmd "test.db" ".import FOO"
shaneha05e0c42009-11-06 03:22:54 +0000430} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000431do_test shell1-3.11.2 {
shanehca7dfda2009-12-17 21:07:54 +0000432 catchcmd "test.db" ".import FOO BAR"
shaneha05e0c42009-11-06 03:22:54 +0000433} {1 {Error: no such table: BAR}}
shaneh5fc25012009-11-11 04:17:07 +0000434do_test shell1-3.11.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000435 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000436 catchcmd "test.db" ".import FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000437} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000438
439# .indices ?TABLE? Show names of all indices
440# If TABLE specified, only show indices for tables
441# matching LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000442do_test shell1-3.12.1 {
shanehca7dfda2009-12-17 21:07:54 +0000443 catchcmd "test.db" ".indices"
shaneha05e0c42009-11-06 03:22:54 +0000444} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000445do_test shell1-3.12.2 {
shanehca7dfda2009-12-17 21:07:54 +0000446 catchcmd "test.db" ".indices FOO"
shaneha05e0c42009-11-06 03:22:54 +0000447} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000448do_test shell1-3.12.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000449 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000450 catchcmd "test.db" ".indices FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000451} {1 {Error: unknown command or invalid arguments: "indices". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000452
453# .mode MODE ?TABLE? Set output mode where MODE is one of:
454# csv Comma-separated values
455# column Left-aligned columns. (See .width)
456# html HTML <table> code
457# insert SQL insert statements for TABLE
458# line One value per line
459# list Values delimited by .separator string
460# tabs Tab-separated values
461# tcl TCL list elements
shaneh5fc25012009-11-11 04:17:07 +0000462do_test shell1-3.13.1 {
shanehca7dfda2009-12-17 21:07:54 +0000463 catchcmd "test.db" ".mode"
shaneha05e0c42009-11-06 03:22:54 +0000464} {1 {Error: unknown command or invalid arguments: "mode". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000465do_test shell1-3.13.2 {
shanehca7dfda2009-12-17 21:07:54 +0000466 catchcmd "test.db" ".mode FOO"
shaneha05e0c42009-11-06 03:22:54 +0000467} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000468do_test shell1-3.13.3 {
shanehca7dfda2009-12-17 21:07:54 +0000469 catchcmd "test.db" ".mode csv"
shaneha05e0c42009-11-06 03:22:54 +0000470} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000471do_test shell1-3.13.4 {
shanehca7dfda2009-12-17 21:07:54 +0000472 catchcmd "test.db" ".mode column"
shaneha05e0c42009-11-06 03:22:54 +0000473} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000474do_test shell1-3.13.5 {
shanehca7dfda2009-12-17 21:07:54 +0000475 catchcmd "test.db" ".mode html"
shaneha05e0c42009-11-06 03:22:54 +0000476} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000477do_test shell1-3.13.6 {
shanehca7dfda2009-12-17 21:07:54 +0000478 catchcmd "test.db" ".mode insert"
shaneha05e0c42009-11-06 03:22:54 +0000479} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000480do_test shell1-3.13.7 {
shanehca7dfda2009-12-17 21:07:54 +0000481 catchcmd "test.db" ".mode line"
shaneha05e0c42009-11-06 03:22:54 +0000482} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000483do_test shell1-3.13.8 {
shanehca7dfda2009-12-17 21:07:54 +0000484 catchcmd "test.db" ".mode list"
shaneha05e0c42009-11-06 03:22:54 +0000485} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000486do_test shell1-3.13.9 {
shanehca7dfda2009-12-17 21:07:54 +0000487 catchcmd "test.db" ".mode tabs"
shaneha05e0c42009-11-06 03:22:54 +0000488} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000489do_test shell1-3.13.10 {
shanehca7dfda2009-12-17 21:07:54 +0000490 catchcmd "test.db" ".mode tcl"
shaneha05e0c42009-11-06 03:22:54 +0000491} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000492do_test shell1-3.13.11 {
shanehe2aa9d72009-11-06 17:20:17 +0000493 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000494 catchcmd "test.db" ".mode tcl BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000495} {1 {Error: invalid arguments: "BAD". Enter ".help" for help}}
496
497# don't allow partial mode type matches
shaneh5fc25012009-11-11 04:17:07 +0000498do_test shell1-3.13.12 {
shanehca7dfda2009-12-17 21:07:54 +0000499 catchcmd "test.db" ".mode l"
shanehe2aa9d72009-11-06 17:20:17 +0000500} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000501do_test shell1-3.13.13 {
shanehca7dfda2009-12-17 21:07:54 +0000502 catchcmd "test.db" ".mode li"
shanehe2aa9d72009-11-06 17:20:17 +0000503} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000504do_test shell1-3.13.14 {
shanehca7dfda2009-12-17 21:07:54 +0000505 catchcmd "test.db" ".mode lin"
shanehe2aa9d72009-11-06 17:20:17 +0000506} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneha05e0c42009-11-06 03:22:54 +0000507
508# .nullvalue STRING Print STRING in place of NULL values
shaneh5fc25012009-11-11 04:17:07 +0000509do_test shell1-3.14.1 {
shanehca7dfda2009-12-17 21:07:54 +0000510 catchcmd "test.db" ".nullvalue"
shaneha05e0c42009-11-06 03:22:54 +0000511} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000512do_test shell1-3.14.2 {
shanehca7dfda2009-12-17 21:07:54 +0000513 catchcmd "test.db" ".nullvalue FOO"
shaneha05e0c42009-11-06 03:22:54 +0000514} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000515do_test shell1-3.14.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000516 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000517 catchcmd "test.db" ".nullvalue FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000518} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000519
520# .output FILENAME Send output to FILENAME
shaneh5fc25012009-11-11 04:17:07 +0000521do_test shell1-3.15.1 {
shanehca7dfda2009-12-17 21:07:54 +0000522 catchcmd "test.db" ".output"
shaneha05e0c42009-11-06 03:22:54 +0000523} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000524do_test shell1-3.15.2 {
shanehca7dfda2009-12-17 21:07:54 +0000525 catchcmd "test.db" ".output FOO"
shaneha05e0c42009-11-06 03:22:54 +0000526} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000527do_test shell1-3.15.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000528 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000529 catchcmd "test.db" ".output FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000530} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000531
532# .output stdout Send output to the screen
shaneh5fc25012009-11-11 04:17:07 +0000533do_test shell1-3.16.1 {
shanehca7dfda2009-12-17 21:07:54 +0000534 catchcmd "test.db" ".output stdout"
shaneha05e0c42009-11-06 03:22:54 +0000535} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000536do_test shell1-3.16.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000537 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000538 catchcmd "test.db" ".output stdout BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000539} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000540
541# .prompt MAIN CONTINUE Replace the standard prompts
shaneh5fc25012009-11-11 04:17:07 +0000542do_test shell1-3.17.1 {
shanehca7dfda2009-12-17 21:07:54 +0000543 catchcmd "test.db" ".prompt"
shaneha05e0c42009-11-06 03:22:54 +0000544} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000545do_test shell1-3.17.2 {
shanehca7dfda2009-12-17 21:07:54 +0000546 catchcmd "test.db" ".prompt FOO"
shaneha05e0c42009-11-06 03:22:54 +0000547} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000548do_test shell1-3.17.3 {
shanehca7dfda2009-12-17 21:07:54 +0000549 catchcmd "test.db" ".prompt FOO BAR"
shaneha05e0c42009-11-06 03:22:54 +0000550} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000551do_test shell1-3.17.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000552 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000553 catchcmd "test.db" ".prompt FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000554} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000555
556# .quit Exit this program
shaneh5fc25012009-11-11 04:17:07 +0000557do_test shell1-3.18.1 {
shanehca7dfda2009-12-17 21:07:54 +0000558 catchcmd "test.db" ".quit"
shaneha05e0c42009-11-06 03:22:54 +0000559} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000560do_test shell1-3.18.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000561 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000562 catchcmd "test.db" ".quit BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000563} {1 {Error: unknown command or invalid arguments: "quit". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000564
565# .read FILENAME Execute SQL in FILENAME
shaneh5fc25012009-11-11 04:17:07 +0000566do_test shell1-3.19.1 {
shanehca7dfda2009-12-17 21:07:54 +0000567 catchcmd "test.db" ".read"
shaneha05e0c42009-11-06 03:22:54 +0000568} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000569do_test shell1-3.19.2 {
shaneha05e0c42009-11-06 03:22:54 +0000570 file delete -force FOO
shanehca7dfda2009-12-17 21:07:54 +0000571 catchcmd "test.db" ".read FOO"
shaneha05e0c42009-11-06 03:22:54 +0000572} {1 {Error: cannot open "FOO"}}
shaneh5fc25012009-11-11 04:17:07 +0000573do_test shell1-3.19.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000574 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000575 catchcmd "test.db" ".read FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000576} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000577
578# .restore ?DB? FILE Restore content of DB (default "main") from FILE
shaneh5fc25012009-11-11 04:17:07 +0000579do_test shell1-3.20.1 {
shanehca7dfda2009-12-17 21:07:54 +0000580 catchcmd "test.db" ".restore"
shaneha05e0c42009-11-06 03:22:54 +0000581} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000582do_test shell1-3.20.2 {
shanehca7dfda2009-12-17 21:07:54 +0000583 catchcmd "test.db" ".restore FOO"
584} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000585do_test shell1-3.20.3 {
shanehca7dfda2009-12-17 21:07:54 +0000586 catchcmd "test.db" ".restore FOO BAR"
shanehe2aa9d72009-11-06 17:20:17 +0000587} {1 {Error: unknown database FOO}}
shaneh5fc25012009-11-11 04:17:07 +0000588do_test shell1-3.20.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000589 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000590 catchcmd "test.db" ".restore FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000591} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000592
593# .schema ?TABLE? Show the CREATE statements
594# If TABLE specified, only show tables matching
595# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000596do_test shell1-3.21.1 {
shanehca7dfda2009-12-17 21:07:54 +0000597 catchcmd "test.db" ".schema"
shaneha05e0c42009-11-06 03:22:54 +0000598} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000599do_test shell1-3.21.2 {
shanehca7dfda2009-12-17 21:07:54 +0000600 catchcmd "test.db" ".schema FOO"
shaneha05e0c42009-11-06 03:22:54 +0000601} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000602do_test shell1-3.21.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000603 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000604 catchcmd "test.db" ".schema FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000605} {1 {Error: unknown command or invalid arguments: "schema". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000606
607# .separator STRING Change separator used by output mode and .import
shaneh5fc25012009-11-11 04:17:07 +0000608do_test shell1-3.22.1 {
shanehca7dfda2009-12-17 21:07:54 +0000609 catchcmd "test.db" ".separator"
shaneha05e0c42009-11-06 03:22:54 +0000610} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000611do_test shell1-3.22.2 {
shanehca7dfda2009-12-17 21:07:54 +0000612 catchcmd "test.db" ".separator FOO"
shaneha05e0c42009-11-06 03:22:54 +0000613} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000614do_test shell1-3.22.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000615 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000616 catchcmd "test.db" ".separator FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000617} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000618
619# .show Show the current values for various settings
shaneh5fc25012009-11-11 04:17:07 +0000620do_test shell1-3.23.1 {
shanehca7dfda2009-12-17 21:07:54 +0000621 set res [catchcmd "test.db" ".show"]
shaneha05e0c42009-11-06 03:22:54 +0000622 list [regexp {echo:} $res] \
623 [regexp {explain:} $res] \
624 [regexp {headers:} $res] \
625 [regexp {mode:} $res] \
626 [regexp {nullvalue:} $res] \
627 [regexp {output:} $res] \
628 [regexp {separator:} $res] \
shaneh642d8b82010-07-28 16:05:34 +0000629 [regexp {stats:} $res] \
shaneha05e0c42009-11-06 03:22:54 +0000630 [regexp {width:} $res]
shaneh642d8b82010-07-28 16:05:34 +0000631} {1 1 1 1 1 1 1 1 1}
shaneh5fc25012009-11-11 04:17:07 +0000632do_test shell1-3.23.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000633 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000634 catchcmd "test.db" ".show BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000635} {1 {Error: unknown command or invalid arguments: "show". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000636
shaneh642d8b82010-07-28 16:05:34 +0000637# .stats ON|OFF Turn stats on or off
638do_test shell1-3.23b.1 {
639 catchcmd "test.db" ".stats"
640} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
641do_test shell1-3.23b.2 {
642 catchcmd "test.db" ".stats ON"
643} {0 {}}
644do_test shell1-3.23b.3 {
645 catchcmd "test.db" ".stats OFF"
646} {0 {}}
647do_test shell1-3.23b.4 {
648 # too many arguments
649 catchcmd "test.db" ".stats OFF BAD"
650} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
651
shaneha05e0c42009-11-06 03:22:54 +0000652# .tables ?TABLE? List names of tables
653# If TABLE specified, only list tables matching
654# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000655do_test shell1-3.24.1 {
shanehca7dfda2009-12-17 21:07:54 +0000656 catchcmd "test.db" ".tables"
shaneha05e0c42009-11-06 03:22:54 +0000657} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000658do_test shell1-3.24.2 {
shanehca7dfda2009-12-17 21:07:54 +0000659 catchcmd "test.db" ".tables FOO"
shaneha05e0c42009-11-06 03:22:54 +0000660} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000661do_test shell1-3.24.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000662 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000663 catchcmd "test.db" ".tables FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000664} {1 {Error: unknown command or invalid arguments: "tables". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000665
666# .timeout MS Try opening locked tables for MS milliseconds
shaneh5fc25012009-11-11 04:17:07 +0000667do_test shell1-3.25.1 {
shanehca7dfda2009-12-17 21:07:54 +0000668 catchcmd "test.db" ".timeout"
shaneha05e0c42009-11-06 03:22:54 +0000669} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000670do_test shell1-3.25.2 {
shanehca7dfda2009-12-17 21:07:54 +0000671 catchcmd "test.db" ".timeout zzz"
shanehe2aa9d72009-11-06 17:20:17 +0000672 # this should be treated the same as a '0' timeout
shaneha05e0c42009-11-06 03:22:54 +0000673} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000674do_test shell1-3.25.3 {
shanehca7dfda2009-12-17 21:07:54 +0000675 catchcmd "test.db" ".timeout 1"
shaneha05e0c42009-11-06 03:22:54 +0000676} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000677do_test shell1-3.25.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000678 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000679 catchcmd "test.db" ".timeout 1 BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000680} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000681
682# .width NUM NUM ... Set column widths for "column" mode
shaneh5fc25012009-11-11 04:17:07 +0000683do_test shell1-3.26.1 {
shanehca7dfda2009-12-17 21:07:54 +0000684 catchcmd "test.db" ".width"
shanehe2aa9d72009-11-06 17:20:17 +0000685} {1 {Error: unknown command or invalid arguments: "width". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000686do_test shell1-3.26.2 {
shanehca7dfda2009-12-17 21:07:54 +0000687 catchcmd "test.db" ".width xxx"
shanehe2aa9d72009-11-06 17:20:17 +0000688 # this should be treated the same as a '0' width for col 1
shaneha05e0c42009-11-06 03:22:54 +0000689} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000690do_test shell1-3.26.3 {
shanehca7dfda2009-12-17 21:07:54 +0000691 catchcmd "test.db" ".width xxx yyy"
shanehe2aa9d72009-11-06 17:20:17 +0000692 # this should be treated the same as a '0' width for col 1 and 2
shaneha05e0c42009-11-06 03:22:54 +0000693} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000694do_test shell1-3.26.4 {
shanehca7dfda2009-12-17 21:07:54 +0000695 catchcmd "test.db" ".width 1 1"
shanehe2aa9d72009-11-06 17:20:17 +0000696 # this should be treated the same as a '1' width for col 1 and 2
shaneha05e0c42009-11-06 03:22:54 +0000697} {0 {}}
698
699# .timer ON|OFF Turn the CPU timer measurement on or off
shaneh5fc25012009-11-11 04:17:07 +0000700do_test shell1-3.27.1 {
shanehca7dfda2009-12-17 21:07:54 +0000701 catchcmd "test.db" ".timer"
shaneha05e0c42009-11-06 03:22:54 +0000702} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000703do_test shell1-3.27.2 {
shanehca7dfda2009-12-17 21:07:54 +0000704 catchcmd "test.db" ".timer ON"
shaneha05e0c42009-11-06 03:22:54 +0000705} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000706do_test shell1-3.27.3 {
shanehca7dfda2009-12-17 21:07:54 +0000707 catchcmd "test.db" ".timer OFF"
shaneha05e0c42009-11-06 03:22:54 +0000708} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000709do_test shell1-3.27.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000710 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000711 catchcmd "test.db" ".timer OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000712} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000713
drh74bec6b2010-07-19 15:01:43 +0000714puts "CLI tests completed successfully"