blob: 9dd9df55554277023094693482faea36a4cc36a8 [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 {
drh9fd301b2011-06-03 13:28:22 +0000202 set x [catchcmd "-version test.db" ""]
203 regexp {0 \{3.\d.\d+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+\}} $x
204} 1
shanehe2aa9d72009-11-06 17:20:17 +0000205
shaneha05e0c42009-11-06 03:22:54 +0000206#----------------------------------------------------------------------------
shaneh5fc25012009-11-11 04:17:07 +0000207# Test cases shell1-2.*: Basic "dot" command token parsing.
shanehe2aa9d72009-11-06 17:20:17 +0000208#
209
210# check first token handling
shaneh5fc25012009-11-11 04:17:07 +0000211do_test shell1-2.1.1 {
shanehca7dfda2009-12-17 21:07:54 +0000212 catchcmd "test.db" ".foo"
shanehe2aa9d72009-11-06 17:20:17 +0000213} {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000214do_test shell1-2.1.2 {
shanehca7dfda2009-12-17 21:07:54 +0000215 catchcmd "test.db" ".\"foo OFF\""
shanehe2aa9d72009-11-06 17:20:17 +0000216} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000217do_test shell1-2.1.3 {
shanehca7dfda2009-12-17 21:07:54 +0000218 catchcmd "test.db" ".\'foo OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000219} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
220
221# unbalanced quotes
shaneh5fc25012009-11-11 04:17:07 +0000222do_test shell1-2.2.1 {
shanehca7dfda2009-12-17 21:07:54 +0000223 catchcmd "test.db" ".\"foo OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000224} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000225do_test shell1-2.2.2 {
shanehca7dfda2009-12-17 21:07:54 +0000226 catchcmd "test.db" ".\'foo OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000227} {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000228do_test shell1-2.2.3 {
shanehca7dfda2009-12-17 21:07:54 +0000229 catchcmd "test.db" ".explain \"OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000230} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000231do_test shell1-2.2.4 {
shanehca7dfda2009-12-17 21:07:54 +0000232 catchcmd "test.db" ".explain \'OFF"
shanehe2aa9d72009-11-06 17:20:17 +0000233} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000234do_test shell1-2.2.5 {
shanehca7dfda2009-12-17 21:07:54 +0000235 catchcmd "test.db" ".mode \"insert FOO"
shanehe2aa9d72009-11-06 17:20:17 +0000236} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000237do_test shell1-2.2.6 {
shanehca7dfda2009-12-17 21:07:54 +0000238 catchcmd "test.db" ".mode \'insert FOO"
shanehe2aa9d72009-11-06 17:20:17 +0000239} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
240
241# check multiple tokens, and quoted tokens
shaneh5fc25012009-11-11 04:17:07 +0000242do_test shell1-2.3.1 {
shanehca7dfda2009-12-17 21:07:54 +0000243 catchcmd "test.db" ".explain 1"
shanehe2aa9d72009-11-06 17:20:17 +0000244} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000245do_test shell1-2.3.2 {
shanehca7dfda2009-12-17 21:07:54 +0000246 catchcmd "test.db" ".explain on"
shanehe2aa9d72009-11-06 17:20:17 +0000247} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000248do_test shell1-2.3.3 {
shanehca7dfda2009-12-17 21:07:54 +0000249 catchcmd "test.db" ".explain \"1 2 3\""
shanehe2aa9d72009-11-06 17:20:17 +0000250} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000251do_test shell1-2.3.4 {
shanehca7dfda2009-12-17 21:07:54 +0000252 catchcmd "test.db" ".explain \"OFF\""
shanehe2aa9d72009-11-06 17:20:17 +0000253} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000254do_test shell1-2.3.5 {
shanehca7dfda2009-12-17 21:07:54 +0000255 catchcmd "test.db" ".\'explain\' \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000256} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000257do_test shell1-2.3.6 {
shanehca7dfda2009-12-17 21:07:54 +0000258 catchcmd "test.db" ".explain \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000259} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000260do_test shell1-2.3.7 {
shanehca7dfda2009-12-17 21:07:54 +0000261 catchcmd "test.db" ".\'explain\' \'OFF\'"
shanehe2aa9d72009-11-06 17:20:17 +0000262} {0 {}}
263
264# check quoted args are unquoted
shaneh5fc25012009-11-11 04:17:07 +0000265do_test shell1-2.4.1 {
shanehca7dfda2009-12-17 21:07:54 +0000266 catchcmd "test.db" ".mode FOO"
shanehe2aa9d72009-11-06 17:20:17 +0000267} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000268do_test shell1-2.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000269 catchcmd "test.db" ".mode csv"
shanehe2aa9d72009-11-06 17:20:17 +0000270} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000271do_test shell1-2.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000272 catchcmd "test.db" ".mode \"csv\""
shanehe2aa9d72009-11-06 17:20:17 +0000273} {0 {}}
274
275
276#----------------------------------------------------------------------------
shaneh5fc25012009-11-11 04:17:07 +0000277# Test cases shell1-3.*: Basic test that "dot" command can be called.
shaneha05e0c42009-11-06 03:22:54 +0000278#
279
280# .backup ?DB? FILE Backup DB (default "main") to FILE
shaneh5fc25012009-11-11 04:17:07 +0000281do_test shell1-3.1.1 {
shanehca7dfda2009-12-17 21:07:54 +0000282 catchcmd "test.db" ".backup"
shanehe2aa9d72009-11-06 17:20:17 +0000283} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000284do_test shell1-3.1.2 {
shanehca7dfda2009-12-17 21:07:54 +0000285 catchcmd "test.db" ".backup FOO"
286} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000287do_test shell1-3.1.3 {
shanehca7dfda2009-12-17 21:07:54 +0000288 catchcmd "test.db" ".backup FOO BAR"
shanehe2aa9d72009-11-06 17:20:17 +0000289} {1 {Error: unknown database FOO}}
shaneh5fc25012009-11-11 04:17:07 +0000290do_test shell1-3.1.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000291 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000292 catchcmd "test.db" ".backup FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000293} {1 {Error: unknown command or invalid arguments: "backup". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000294
295# .bail ON|OFF Stop after hitting an error. Default OFF
shaneh5fc25012009-11-11 04:17:07 +0000296do_test shell1-3.2.1 {
shanehca7dfda2009-12-17 21:07:54 +0000297 catchcmd "test.db" ".bail"
shaneha05e0c42009-11-06 03:22:54 +0000298} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000299do_test shell1-3.2.2 {
shanehca7dfda2009-12-17 21:07:54 +0000300 catchcmd "test.db" ".bail ON"
shaneha05e0c42009-11-06 03:22:54 +0000301} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000302do_test shell1-3.2.3 {
shanehca7dfda2009-12-17 21:07:54 +0000303 catchcmd "test.db" ".bail OFF"
shaneha05e0c42009-11-06 03:22:54 +0000304} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000305do_test shell1-3.2.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000306 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000307 catchcmd "test.db" ".bail OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000308} {1 {Error: unknown command or invalid arguments: "bail". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000309
310# .databases List names and files of attached databases
shaneh5fc25012009-11-11 04:17:07 +0000311do_test shell1-3.3.1 {
shanehca7dfda2009-12-17 21:07:54 +0000312 set res [catchcmd "test.db" ".databases"]
shaneha05e0c42009-11-06 03:22:54 +0000313 regexp {0.*main.*test\.db} $res
314} {1}
shaneh5fc25012009-11-11 04:17:07 +0000315do_test shell1-3.3.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000316 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000317 catchcmd "test.db" ".databases BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000318} {1 {Error: unknown command or invalid arguments: "databases". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000319
320# .dump ?TABLE? ... Dump the database in an SQL text format
321# If TABLE specified, only dump tables matching
322# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000323do_test shell1-3.4.1 {
shanehca7dfda2009-12-17 21:07:54 +0000324 set res [catchcmd "test.db" ".dump"]
shaneha05e0c42009-11-06 03:22:54 +0000325 list [regexp {BEGIN TRANSACTION;} $res] \
326 [regexp {COMMIT;} $res]
327} {1 1}
shaneh5fc25012009-11-11 04:17:07 +0000328do_test shell1-3.4.2 {
shanehca7dfda2009-12-17 21:07:54 +0000329 set res [catchcmd "test.db" ".dump FOO"]
shaneha05e0c42009-11-06 03:22:54 +0000330 list [regexp {BEGIN TRANSACTION;} $res] \
331 [regexp {COMMIT;} $res]
332} {1 1}
shaneh5fc25012009-11-11 04:17:07 +0000333do_test shell1-3.4.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000334 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000335 catchcmd "test.db" ".dump FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000336} {1 {Error: unknown command or invalid arguments: "dump". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000337
338# .echo ON|OFF Turn command echo on or off
shaneh5fc25012009-11-11 04:17:07 +0000339do_test shell1-3.5.1 {
shanehca7dfda2009-12-17 21:07:54 +0000340 catchcmd "test.db" ".echo"
shaneha05e0c42009-11-06 03:22:54 +0000341} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000342do_test shell1-3.5.2 {
shanehca7dfda2009-12-17 21:07:54 +0000343 catchcmd "test.db" ".echo ON"
shaneha05e0c42009-11-06 03:22:54 +0000344} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000345do_test shell1-3.5.3 {
shanehca7dfda2009-12-17 21:07:54 +0000346 catchcmd "test.db" ".echo OFF"
shaneha05e0c42009-11-06 03:22:54 +0000347} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000348do_test shell1-3.5.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000349 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000350 catchcmd "test.db" ".echo OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000351} {1 {Error: unknown command or invalid arguments: "echo". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000352
353# .exit Exit this program
shaneh5fc25012009-11-11 04:17:07 +0000354do_test shell1-3.6.1 {
shanehca7dfda2009-12-17 21:07:54 +0000355 catchcmd "test.db" ".exit"
shaneha05e0c42009-11-06 03:22:54 +0000356} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000357do_test shell1-3.6.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000358 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000359 catchcmd "test.db" ".exit BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000360} {1 {Error: unknown command or invalid arguments: "exit". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000361
362# .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
shaneh5fc25012009-11-11 04:17:07 +0000363do_test shell1-3.7.1 {
shanehca7dfda2009-12-17 21:07:54 +0000364 catchcmd "test.db" ".explain"
shanehe2aa9d72009-11-06 17:20:17 +0000365 # explain is the exception to the booleans. without an option, it turns it on.
366} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000367do_test shell1-3.7.2 {
shanehca7dfda2009-12-17 21:07:54 +0000368 catchcmd "test.db" ".explain ON"
shaneha05e0c42009-11-06 03:22:54 +0000369} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000370do_test shell1-3.7.3 {
shanehca7dfda2009-12-17 21:07:54 +0000371 catchcmd "test.db" ".explain OFF"
shaneha05e0c42009-11-06 03:22:54 +0000372} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000373do_test shell1-3.7.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000374 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000375 catchcmd "test.db" ".explain OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000376} {1 {Error: unknown command or invalid arguments: "explain". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000377
shaneha05e0c42009-11-06 03:22:54 +0000378
379# .header(s) ON|OFF Turn display of headers on or off
shaneh5fc25012009-11-11 04:17:07 +0000380do_test shell1-3.9.1 {
shanehca7dfda2009-12-17 21:07:54 +0000381 catchcmd "test.db" ".header"
shaneha05e0c42009-11-06 03:22:54 +0000382} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000383do_test shell1-3.9.2 {
shanehca7dfda2009-12-17 21:07:54 +0000384 catchcmd "test.db" ".header ON"
shaneha05e0c42009-11-06 03:22:54 +0000385} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000386do_test shell1-3.9.3 {
shanehca7dfda2009-12-17 21:07:54 +0000387 catchcmd "test.db" ".header OFF"
shaneha05e0c42009-11-06 03:22:54 +0000388} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000389do_test shell1-3.9.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000390 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000391 catchcmd "test.db" ".header OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000392} {1 {Error: unknown command or invalid arguments: "header". Enter ".help" for help}}
393
shaneh5fc25012009-11-11 04:17:07 +0000394do_test shell1-3.9.5 {
shanehca7dfda2009-12-17 21:07:54 +0000395 catchcmd "test.db" ".headers"
shaneha05e0c42009-11-06 03:22:54 +0000396} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000397do_test shell1-3.9.6 {
shanehca7dfda2009-12-17 21:07:54 +0000398 catchcmd "test.db" ".headers ON"
shaneha05e0c42009-11-06 03:22:54 +0000399} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000400do_test shell1-3.9.7 {
shanehca7dfda2009-12-17 21:07:54 +0000401 catchcmd "test.db" ".headers OFF"
shaneha05e0c42009-11-06 03:22:54 +0000402} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000403do_test shell1-3.9.8 {
shanehe2aa9d72009-11-06 17:20:17 +0000404 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000405 catchcmd "test.db" ".headers OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000406} {1 {Error: unknown command or invalid arguments: "headers". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000407
408# .help Show this message
shaneh5fc25012009-11-11 04:17:07 +0000409do_test shell1-3.10.1 {
shanehca7dfda2009-12-17 21:07:54 +0000410 set res [catchcmd "test.db" ".help"]
shaneha05e0c42009-11-06 03:22:54 +0000411 # look for a few of the possible help commands
412 list [regexp {.help} $res] \
413 [regexp {.quit} $res] \
414 [regexp {.show} $res]
415} {1 1 1}
shaneh5fc25012009-11-11 04:17:07 +0000416do_test shell1-3.10.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000417 # we allow .help to take extra args (it is help after all)
shanehca7dfda2009-12-17 21:07:54 +0000418 set res [catchcmd "test.db" ".help BAD"]
shanehe2aa9d72009-11-06 17:20:17 +0000419 # look for a few of the possible help commands
420 list [regexp {.help} $res] \
421 [regexp {.quit} $res] \
422 [regexp {.show} $res]
423} {1 1 1}
shaneha05e0c42009-11-06 03:22:54 +0000424
425# .import FILE TABLE Import data from FILE into TABLE
shaneh5fc25012009-11-11 04:17:07 +0000426do_test shell1-3.11.1 {
shanehca7dfda2009-12-17 21:07:54 +0000427 catchcmd "test.db" ".import"
shaneha05e0c42009-11-06 03:22:54 +0000428} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000429do_test shell1-3.11.2 {
shanehca7dfda2009-12-17 21:07:54 +0000430 catchcmd "test.db" ".import FOO"
shaneha05e0c42009-11-06 03:22:54 +0000431} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000432do_test shell1-3.11.2 {
shanehca7dfda2009-12-17 21:07:54 +0000433 catchcmd "test.db" ".import FOO BAR"
shaneha05e0c42009-11-06 03:22:54 +0000434} {1 {Error: no such table: BAR}}
shaneh5fc25012009-11-11 04:17:07 +0000435do_test shell1-3.11.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000436 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000437 catchcmd "test.db" ".import FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000438} {1 {Error: unknown command or invalid arguments: "import". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000439
440# .indices ?TABLE? Show names of all indices
441# If TABLE specified, only show indices for tables
442# matching LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000443do_test shell1-3.12.1 {
shanehca7dfda2009-12-17 21:07:54 +0000444 catchcmd "test.db" ".indices"
shaneha05e0c42009-11-06 03:22:54 +0000445} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000446do_test shell1-3.12.2 {
shanehca7dfda2009-12-17 21:07:54 +0000447 catchcmd "test.db" ".indices FOO"
shaneha05e0c42009-11-06 03:22:54 +0000448} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000449do_test shell1-3.12.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000450 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000451 catchcmd "test.db" ".indices FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000452} {1 {Error: unknown command or invalid arguments: "indices". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000453
454# .mode MODE ?TABLE? Set output mode where MODE is one of:
455# csv Comma-separated values
456# column Left-aligned columns. (See .width)
457# html HTML <table> code
458# insert SQL insert statements for TABLE
459# line One value per line
460# list Values delimited by .separator string
461# tabs Tab-separated values
462# tcl TCL list elements
shaneh5fc25012009-11-11 04:17:07 +0000463do_test shell1-3.13.1 {
shanehca7dfda2009-12-17 21:07:54 +0000464 catchcmd "test.db" ".mode"
shaneha05e0c42009-11-06 03:22:54 +0000465} {1 {Error: unknown command or invalid arguments: "mode". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000466do_test shell1-3.13.2 {
shanehca7dfda2009-12-17 21:07:54 +0000467 catchcmd "test.db" ".mode FOO"
shaneha05e0c42009-11-06 03:22:54 +0000468} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000469do_test shell1-3.13.3 {
shanehca7dfda2009-12-17 21:07:54 +0000470 catchcmd "test.db" ".mode csv"
shaneha05e0c42009-11-06 03:22:54 +0000471} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000472do_test shell1-3.13.4 {
shanehca7dfda2009-12-17 21:07:54 +0000473 catchcmd "test.db" ".mode column"
shaneha05e0c42009-11-06 03:22:54 +0000474} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000475do_test shell1-3.13.5 {
shanehca7dfda2009-12-17 21:07:54 +0000476 catchcmd "test.db" ".mode html"
shaneha05e0c42009-11-06 03:22:54 +0000477} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000478do_test shell1-3.13.6 {
shanehca7dfda2009-12-17 21:07:54 +0000479 catchcmd "test.db" ".mode insert"
shaneha05e0c42009-11-06 03:22:54 +0000480} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000481do_test shell1-3.13.7 {
shanehca7dfda2009-12-17 21:07:54 +0000482 catchcmd "test.db" ".mode line"
shaneha05e0c42009-11-06 03:22:54 +0000483} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000484do_test shell1-3.13.8 {
shanehca7dfda2009-12-17 21:07:54 +0000485 catchcmd "test.db" ".mode list"
shaneha05e0c42009-11-06 03:22:54 +0000486} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000487do_test shell1-3.13.9 {
shanehca7dfda2009-12-17 21:07:54 +0000488 catchcmd "test.db" ".mode tabs"
shaneha05e0c42009-11-06 03:22:54 +0000489} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000490do_test shell1-3.13.10 {
shanehca7dfda2009-12-17 21:07:54 +0000491 catchcmd "test.db" ".mode tcl"
shaneha05e0c42009-11-06 03:22:54 +0000492} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000493do_test shell1-3.13.11 {
shanehe2aa9d72009-11-06 17:20:17 +0000494 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000495 catchcmd "test.db" ".mode tcl BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000496} {1 {Error: invalid arguments: "BAD". Enter ".help" for help}}
497
498# don't allow partial mode type matches
shaneh5fc25012009-11-11 04:17:07 +0000499do_test shell1-3.13.12 {
shanehca7dfda2009-12-17 21:07:54 +0000500 catchcmd "test.db" ".mode l"
shanehe2aa9d72009-11-06 17:20:17 +0000501} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000502do_test shell1-3.13.13 {
shanehca7dfda2009-12-17 21:07:54 +0000503 catchcmd "test.db" ".mode li"
shanehe2aa9d72009-11-06 17:20:17 +0000504} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneh5fc25012009-11-11 04:17:07 +0000505do_test shell1-3.13.14 {
shanehca7dfda2009-12-17 21:07:54 +0000506 catchcmd "test.db" ".mode lin"
shanehe2aa9d72009-11-06 17:20:17 +0000507} {1 {Error: mode should be one of: column csv html insert line list tabs tcl}}
shaneha05e0c42009-11-06 03:22:54 +0000508
509# .nullvalue STRING Print STRING in place of NULL values
shaneh5fc25012009-11-11 04:17:07 +0000510do_test shell1-3.14.1 {
shanehca7dfda2009-12-17 21:07:54 +0000511 catchcmd "test.db" ".nullvalue"
shaneha05e0c42009-11-06 03:22:54 +0000512} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000513do_test shell1-3.14.2 {
shanehca7dfda2009-12-17 21:07:54 +0000514 catchcmd "test.db" ".nullvalue FOO"
shaneha05e0c42009-11-06 03:22:54 +0000515} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000516do_test shell1-3.14.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000517 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000518 catchcmd "test.db" ".nullvalue FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000519} {1 {Error: unknown command or invalid arguments: "nullvalue". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000520
521# .output FILENAME Send output to FILENAME
shaneh5fc25012009-11-11 04:17:07 +0000522do_test shell1-3.15.1 {
shanehca7dfda2009-12-17 21:07:54 +0000523 catchcmd "test.db" ".output"
shaneha05e0c42009-11-06 03:22:54 +0000524} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000525do_test shell1-3.15.2 {
shanehca7dfda2009-12-17 21:07:54 +0000526 catchcmd "test.db" ".output FOO"
shaneha05e0c42009-11-06 03:22:54 +0000527} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000528do_test shell1-3.15.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000529 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000530 catchcmd "test.db" ".output FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000531} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000532
533# .output stdout Send output to the screen
shaneh5fc25012009-11-11 04:17:07 +0000534do_test shell1-3.16.1 {
shanehca7dfda2009-12-17 21:07:54 +0000535 catchcmd "test.db" ".output stdout"
shaneha05e0c42009-11-06 03:22:54 +0000536} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000537do_test shell1-3.16.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000538 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000539 catchcmd "test.db" ".output stdout BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000540} {1 {Error: unknown command or invalid arguments: "output". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000541
542# .prompt MAIN CONTINUE Replace the standard prompts
shaneh5fc25012009-11-11 04:17:07 +0000543do_test shell1-3.17.1 {
shanehca7dfda2009-12-17 21:07:54 +0000544 catchcmd "test.db" ".prompt"
shaneha05e0c42009-11-06 03:22:54 +0000545} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000546do_test shell1-3.17.2 {
shanehca7dfda2009-12-17 21:07:54 +0000547 catchcmd "test.db" ".prompt FOO"
shaneha05e0c42009-11-06 03:22:54 +0000548} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000549do_test shell1-3.17.3 {
shanehca7dfda2009-12-17 21:07:54 +0000550 catchcmd "test.db" ".prompt FOO BAR"
shaneha05e0c42009-11-06 03:22:54 +0000551} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000552do_test shell1-3.17.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000553 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000554 catchcmd "test.db" ".prompt FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000555} {1 {Error: unknown command or invalid arguments: "prompt". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000556
557# .quit Exit this program
shaneh5fc25012009-11-11 04:17:07 +0000558do_test shell1-3.18.1 {
shanehca7dfda2009-12-17 21:07:54 +0000559 catchcmd "test.db" ".quit"
shaneha05e0c42009-11-06 03:22:54 +0000560} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000561do_test shell1-3.18.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000562 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000563 catchcmd "test.db" ".quit BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000564} {1 {Error: unknown command or invalid arguments: "quit". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000565
566# .read FILENAME Execute SQL in FILENAME
shaneh5fc25012009-11-11 04:17:07 +0000567do_test shell1-3.19.1 {
shanehca7dfda2009-12-17 21:07:54 +0000568 catchcmd "test.db" ".read"
shaneha05e0c42009-11-06 03:22:54 +0000569} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000570do_test shell1-3.19.2 {
shaneha05e0c42009-11-06 03:22:54 +0000571 file delete -force FOO
shanehca7dfda2009-12-17 21:07:54 +0000572 catchcmd "test.db" ".read FOO"
shaneha05e0c42009-11-06 03:22:54 +0000573} {1 {Error: cannot open "FOO"}}
shaneh5fc25012009-11-11 04:17:07 +0000574do_test shell1-3.19.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000575 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000576 catchcmd "test.db" ".read FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000577} {1 {Error: unknown command or invalid arguments: "read". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000578
579# .restore ?DB? FILE Restore content of DB (default "main") from FILE
shaneh5fc25012009-11-11 04:17:07 +0000580do_test shell1-3.20.1 {
shanehca7dfda2009-12-17 21:07:54 +0000581 catchcmd "test.db" ".restore"
shaneha05e0c42009-11-06 03:22:54 +0000582} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000583do_test shell1-3.20.2 {
shanehca7dfda2009-12-17 21:07:54 +0000584 catchcmd "test.db" ".restore FOO"
585} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000586do_test shell1-3.20.3 {
shanehca7dfda2009-12-17 21:07:54 +0000587 catchcmd "test.db" ".restore FOO BAR"
shanehe2aa9d72009-11-06 17:20:17 +0000588} {1 {Error: unknown database FOO}}
shaneh5fc25012009-11-11 04:17:07 +0000589do_test shell1-3.20.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000590 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000591 catchcmd "test.db" ".restore FOO BAR BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000592} {1 {Error: unknown command or invalid arguments: "restore". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000593
594# .schema ?TABLE? Show the CREATE statements
595# If TABLE specified, only show tables matching
596# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000597do_test shell1-3.21.1 {
shanehca7dfda2009-12-17 21:07:54 +0000598 catchcmd "test.db" ".schema"
shaneha05e0c42009-11-06 03:22:54 +0000599} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000600do_test shell1-3.21.2 {
shanehca7dfda2009-12-17 21:07:54 +0000601 catchcmd "test.db" ".schema FOO"
shaneha05e0c42009-11-06 03:22:54 +0000602} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000603do_test shell1-3.21.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000604 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000605 catchcmd "test.db" ".schema FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000606} {1 {Error: unknown command or invalid arguments: "schema". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000607
608# .separator STRING Change separator used by output mode and .import
shaneh5fc25012009-11-11 04:17:07 +0000609do_test shell1-3.22.1 {
shanehca7dfda2009-12-17 21:07:54 +0000610 catchcmd "test.db" ".separator"
shaneha05e0c42009-11-06 03:22:54 +0000611} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000612do_test shell1-3.22.2 {
shanehca7dfda2009-12-17 21:07:54 +0000613 catchcmd "test.db" ".separator FOO"
shaneha05e0c42009-11-06 03:22:54 +0000614} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000615do_test shell1-3.22.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000616 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000617 catchcmd "test.db" ".separator FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000618} {1 {Error: unknown command or invalid arguments: "separator". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000619
620# .show Show the current values for various settings
shaneh5fc25012009-11-11 04:17:07 +0000621do_test shell1-3.23.1 {
shanehca7dfda2009-12-17 21:07:54 +0000622 set res [catchcmd "test.db" ".show"]
shaneha05e0c42009-11-06 03:22:54 +0000623 list [regexp {echo:} $res] \
624 [regexp {explain:} $res] \
625 [regexp {headers:} $res] \
626 [regexp {mode:} $res] \
627 [regexp {nullvalue:} $res] \
628 [regexp {output:} $res] \
629 [regexp {separator:} $res] \
shaneh642d8b82010-07-28 16:05:34 +0000630 [regexp {stats:} $res] \
shaneha05e0c42009-11-06 03:22:54 +0000631 [regexp {width:} $res]
shaneh642d8b82010-07-28 16:05:34 +0000632} {1 1 1 1 1 1 1 1 1}
shaneh5fc25012009-11-11 04:17:07 +0000633do_test shell1-3.23.2 {
shanehe2aa9d72009-11-06 17:20:17 +0000634 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000635 catchcmd "test.db" ".show BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000636} {1 {Error: unknown command or invalid arguments: "show". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000637
shaneh642d8b82010-07-28 16:05:34 +0000638# .stats ON|OFF Turn stats on or off
639do_test shell1-3.23b.1 {
640 catchcmd "test.db" ".stats"
641} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
642do_test shell1-3.23b.2 {
643 catchcmd "test.db" ".stats ON"
644} {0 {}}
645do_test shell1-3.23b.3 {
646 catchcmd "test.db" ".stats OFF"
647} {0 {}}
648do_test shell1-3.23b.4 {
649 # too many arguments
650 catchcmd "test.db" ".stats OFF BAD"
651} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
652
shaneha05e0c42009-11-06 03:22:54 +0000653# .tables ?TABLE? List names of tables
654# If TABLE specified, only list tables matching
655# LIKE pattern TABLE.
shaneh5fc25012009-11-11 04:17:07 +0000656do_test shell1-3.24.1 {
shanehca7dfda2009-12-17 21:07:54 +0000657 catchcmd "test.db" ".tables"
shaneha05e0c42009-11-06 03:22:54 +0000658} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000659do_test shell1-3.24.2 {
shanehca7dfda2009-12-17 21:07:54 +0000660 catchcmd "test.db" ".tables FOO"
shaneha05e0c42009-11-06 03:22:54 +0000661} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000662do_test shell1-3.24.3 {
shanehe2aa9d72009-11-06 17:20:17 +0000663 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000664 catchcmd "test.db" ".tables FOO BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000665} {1 {Error: unknown command or invalid arguments: "tables". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000666
667# .timeout MS Try opening locked tables for MS milliseconds
shaneh5fc25012009-11-11 04:17:07 +0000668do_test shell1-3.25.1 {
shanehca7dfda2009-12-17 21:07:54 +0000669 catchcmd "test.db" ".timeout"
shaneha05e0c42009-11-06 03:22:54 +0000670} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000671do_test shell1-3.25.2 {
shanehca7dfda2009-12-17 21:07:54 +0000672 catchcmd "test.db" ".timeout zzz"
shanehe2aa9d72009-11-06 17:20:17 +0000673 # this should be treated the same as a '0' timeout
shaneha05e0c42009-11-06 03:22:54 +0000674} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000675do_test shell1-3.25.3 {
shanehca7dfda2009-12-17 21:07:54 +0000676 catchcmd "test.db" ".timeout 1"
shaneha05e0c42009-11-06 03:22:54 +0000677} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000678do_test shell1-3.25.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000679 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000680 catchcmd "test.db" ".timeout 1 BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000681} {1 {Error: unknown command or invalid arguments: "timeout". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000682
683# .width NUM NUM ... Set column widths for "column" mode
shaneh5fc25012009-11-11 04:17:07 +0000684do_test shell1-3.26.1 {
shanehca7dfda2009-12-17 21:07:54 +0000685 catchcmd "test.db" ".width"
shanehe2aa9d72009-11-06 17:20:17 +0000686} {1 {Error: unknown command or invalid arguments: "width". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000687do_test shell1-3.26.2 {
shanehca7dfda2009-12-17 21:07:54 +0000688 catchcmd "test.db" ".width xxx"
shanehe2aa9d72009-11-06 17:20:17 +0000689 # this should be treated the same as a '0' width for col 1
shaneha05e0c42009-11-06 03:22:54 +0000690} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000691do_test shell1-3.26.3 {
shanehca7dfda2009-12-17 21:07:54 +0000692 catchcmd "test.db" ".width xxx yyy"
shanehe2aa9d72009-11-06 17:20:17 +0000693 # this should be treated the same as a '0' width for col 1 and 2
shaneha05e0c42009-11-06 03:22:54 +0000694} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000695do_test shell1-3.26.4 {
shanehca7dfda2009-12-17 21:07:54 +0000696 catchcmd "test.db" ".width 1 1"
shanehe2aa9d72009-11-06 17:20:17 +0000697 # this should be treated the same as a '1' width for col 1 and 2
shaneha05e0c42009-11-06 03:22:54 +0000698} {0 {}}
699
700# .timer ON|OFF Turn the CPU timer measurement on or off
shaneh5fc25012009-11-11 04:17:07 +0000701do_test shell1-3.27.1 {
shanehca7dfda2009-12-17 21:07:54 +0000702 catchcmd "test.db" ".timer"
shaneha05e0c42009-11-06 03:22:54 +0000703} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}}
shaneh5fc25012009-11-11 04:17:07 +0000704do_test shell1-3.27.2 {
shanehca7dfda2009-12-17 21:07:54 +0000705 catchcmd "test.db" ".timer ON"
shaneha05e0c42009-11-06 03:22:54 +0000706} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000707do_test shell1-3.27.3 {
shanehca7dfda2009-12-17 21:07:54 +0000708 catchcmd "test.db" ".timer OFF"
shaneha05e0c42009-11-06 03:22:54 +0000709} {0 {}}
shaneh5fc25012009-11-11 04:17:07 +0000710do_test shell1-3.27.4 {
shanehe2aa9d72009-11-06 17:20:17 +0000711 # too many arguments
shanehca7dfda2009-12-17 21:07:54 +0000712 catchcmd "test.db" ".timer OFF BAD"
shanehe2aa9d72009-11-06 17:20:17 +0000713} {1 {Error: unknown command or invalid arguments: "timer". Enter ".help" for help}}
shaneha05e0c42009-11-06 03:22:54 +0000714
drh53a9d152011-04-25 18:20:04 +0000715do_test shell1-3-28.1 {
716 catchcmd test.db \
717 ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
718} "0 {(123) hello\n456}"
719
drh74bec6b2010-07-19 15:01:43 +0000720puts "CLI tests completed successfully"