Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/sqlite/src/test/shell1.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/shared3.test ('k') | third_party/sqlite/src/test/shell2.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2009 Nov 11 1 # 2009 Nov 11
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # 11 #
12 # The focus of this file is testing the CLI shell tool. 12 # The focus of this file is testing the CLI shell tool.
13 # 13 #
14 # 14 #
15 15
16 # Test plan: 16 # Test plan:
17 # 17 #
18 # shell1-1.*: Basic command line option handling. 18 # shell1-1.*: Basic command line option handling.
19 # shell1-2.*: Basic "dot" command token parsing. 19 # shell1-2.*: Basic "dot" command token parsing.
20 # shell1-3.*: Basic test that "dot" command can be called. 20 # shell1-3.*: Basic test that "dot" command can be called.
21 # 21 #
22 set testdir [file dirname $argv0] 22 set testdir [file dirname $argv0]
23 source $testdir/tester.tcl 23 source $testdir/tester.tcl
24 if {$tcl_platform(platform)=="windows"} { 24 set CLI [test_find_cli]
25 set CLI "sqlite3.exe"
26 } else {
27 set CLI "./sqlite3"
28 }
29 if {![file executable $CLI]} {
30 finish_test
31 return
32 }
33 db close 25 db close
34 forcedelete test.db test.db-journal test.db-wal 26 forcedelete test.db test.db-journal test.db-wal
35 sqlite3 db test.db 27 sqlite3 db test.db
36 28
37 #---------------------------------------------------------------------------- 29 #----------------------------------------------------------------------------
38 # Test cases shell1-1.*: Basic command line option handling. 30 # Test cases shell1-1.*: Basic command line option handling.
39 # 31 #
40 32
41 # invalid option 33 # invalid option
42 do_test shell1-1.1.1 { 34 do_test shell1-1.1.1 {
43 set res [catchcmd "-bad test.db" ""] 35 set res [catchcmd "-bad test.db" ""]
44 set rc [lindex $res 0] 36 set rc [lindex $res 0]
45 list $rc \ 37 list $rc \
46 [regexp {Error: unknown option: -bad} $res] 38 [regexp {Error: unknown option: -bad} $res]
47 } {1 1} 39 } {1 1}
48 do_test shell1-1.1.1b { 40 do_test shell1-1.1.1b {
49 set res [catchcmd "test.db -bad" ""] 41 set res [catchcmd "test.db -bad" ""]
50 set rc [lindex $res 0] 42 set rc [lindex $res 0]
51 list $rc \ 43 list $rc \
52 [regexp {Error: unknown option: -bad} $res] 44 [regexp {Error: unknown option: -bad} $res]
53 } {1 1} 45 } {1 1}
54 # error on extra options 46 # error on extra options
55 do_test shell1-1.1.2 { 47 do_test shell1-1.1.2 {
56 catchcmd "test.db \"select 3\" \"select 4\"" "" 48 catchcmd "test.db \"select+3\" \"select+4\"" ""
57 } {0 {3 49 } {0 {3
58 4}} 50 4}}
59 # error on extra options 51 # error on extra options
60 do_test shell1-1.1.3 { 52 do_test shell1-1.1.3 {
61 catchcmd "test.db FOO test.db BAD" ".quit" 53 catchcmd "test.db FOO test.db BAD" ".quit"
62 } {1 {Error: near "FOO": syntax error}} 54 } {1 {Error: near "FOO": syntax error}}
63 55
64 # -help 56 # -help
65 do_test shell1-1.2.1 { 57 do_test shell1-1.2.1 {
66 set res [catchcmd "-help test.db" ""] 58 set res [catchcmd "-help test.db" ""]
(...skipping 10 matching lines...) Expand all
77 } {0 {}} 69 } {0 {}}
78 do_test shell1-1.3.2 { 70 do_test shell1-1.3.2 {
79 catchcmd "-init FOO test.db .quit BAD" "" 71 catchcmd "-init FOO test.db .quit BAD" ""
80 } {0 {}} 72 } {0 {}}
81 do_test shell1-1.3.3 { 73 do_test shell1-1.3.3 {
82 catchcmd "-init FOO test.db BAD .quit" "" 74 catchcmd "-init FOO test.db BAD .quit" ""
83 } {1 {Error: near "BAD": syntax error}} 75 } {1 {Error: near "BAD": syntax error}}
84 76
85 # -echo print commands before execution 77 # -echo print commands before execution
86 do_test shell1-1.4.1 { 78 do_test shell1-1.4.1 {
87 catchcmd "-echo test.db" "" 79 catchcmd "-echo test.db" ""
88 } {0 {}} 80 } {0 {}}
89 81
90 # -[no]header turn headers on or off 82 # -[no]header turn headers on or off
91 do_test shell1-1.5.1 { 83 do_test shell1-1.5.1 {
92 catchcmd "-header test.db" "" 84 catchcmd "-header test.db" ""
93 } {0 {}} 85 } {0 {}}
94 do_test shell1-1.5.2 { 86 do_test shell1-1.5.2 {
95 catchcmd "-noheader test.db" "" 87 catchcmd "-noheader test.db" ""
96 } {0 {}} 88 } {0 {}}
97 89
98 # -bail stop after hitting an error 90 # -bail stop after hitting an error
99 do_test shell1-1.6.1 { 91 do_test shell1-1.6.1 {
100 catchcmd "-bail test.db" "" 92 catchcmd "-bail test.db" ""
101 } {0 {}} 93 } {0 {}}
102 94
103 # -interactive force interactive I/O 95 # -interactive force interactive I/O
104 do_test shell1-1.7.1 { 96 do_test shell1-1.7.1 {
105 set res [catchcmd "-interactive test.db" ".quit"] 97 set res [catchcmd "-interactive test.db" ".quit"]
106 set rc [lindex $res 0] 98 set rc [lindex $res 0]
107 list $rc \ 99 list $rc \
108 [regexp {SQLite version} $res] \ 100 [regexp {SQLite version} $res] \
109 [regexp {Enter ".help" for usage hints} $res] 101 [regexp {Enter ".help" for usage hints} $res]
110 } {0 1 1} 102 } {0 1 1}
111 103
112 # -batch force batch I/O 104 # -batch force batch I/O
113 do_test shell1-1.8.1 { 105 do_test shell1-1.8.1 {
114 catchcmd "-batch test.db" "" 106 catchcmd "-batch test.db" ""
115 } {0 {}} 107 } {0 {}}
116 108
117 # -column set output mode to 'column' 109 # -column set output mode to 'column'
118 do_test shell1-1.9.1 { 110 do_test shell1-1.9.1 {
119 catchcmd "-column test.db" "" 111 catchcmd "-column test.db" ""
120 } {0 {}} 112 } {0 {}}
121 113
122 # -csv set output mode to 'csv' 114 # -csv set output mode to 'csv'
123 do_test shell1-1.10.1 { 115 do_test shell1-1.10.1 {
124 catchcmd "-csv test.db" "" 116 catchcmd "-csv test.db" ""
125 } {0 {}} 117 } {0 {}}
126 118
127 # -html set output mode to HTML 119 # -html set output mode to HTML
128 do_test shell1-1.11.1 { 120 do_test shell1-1.11.1 {
129 catchcmd "-html test.db" "" 121 catchcmd "-html test.db" ""
130 } {0 {}} 122 } {0 {}}
131 123
132 # -line set output mode to 'line' 124 # -line set output mode to 'line'
133 do_test shell1-1.12.1 { 125 do_test shell1-1.12.1 {
134 catchcmd "-line test.db" "" 126 catchcmd "-line test.db" ""
135 } {0 {}} 127 } {0 {}}
136 128
137 # -list set output mode to 'list' 129 # -list set output mode to 'list'
138 do_test shell1-1.13.1 { 130 do_test shell1-1.13.1 {
139 catchcmd "-list test.db" "" 131 catchcmd "-list test.db" ""
140 } {0 {}} 132 } {0 {}}
141 133
142 # -separator 'x' set output field separator (|) 134 # -separator 'x' set output field separator (|)
143 do_test shell1-1.14.1 { 135 do_test shell1-1.14.1 {
144 catchcmd "-separator 'x' test.db" "" 136 catchcmd "-separator 'x' test.db" ""
145 } {0 {}} 137 } {0 {}}
146 do_test shell1-1.14.2 { 138 do_test shell1-1.14.2 {
147 catchcmd "-separator x test.db" "" 139 catchcmd "-separator x test.db" ""
148 } {0 {}} 140 } {0 {}}
149 do_test shell1-1.14.3 { 141 do_test shell1-1.14.3 {
150 set res [catchcmd "-separator" ""] 142 set res [catchcmd "-separator" ""]
151 set rc [lindex $res 0] 143 set rc [lindex $res 0]
152 list $rc \ 144 list $rc \
153 [regexp {Error: missing argument to -separator} $res] 145 [regexp {Error: missing argument to -separator} $res]
154 } {1 1} 146 } {1 1}
155 147
156 # -stats print memory stats before each finalize 148 # -stats print memory stats before each finalize
157 do_test shell1-1.14b.1 { 149 do_test shell1-1.14b.1 {
158 catchcmd "-stats test.db" "" 150 catchcmd "-stats test.db" ""
159 } {0 {}} 151 } {0 {}}
160 152
161 # -nullvalue 'text' set text string for NULL values 153 # -nullvalue 'text' set text string for NULL values
162 do_test shell1-1.15.1 { 154 do_test shell1-1.15.1 {
163 catchcmd "-nullvalue 'x' test.db" "" 155 catchcmd "-nullvalue 'x' test.db" ""
164 } {0 {}} 156 } {0 {}}
165 do_test shell1-1.15.2 { 157 do_test shell1-1.15.2 {
166 catchcmd "-nullvalue x test.db" "" 158 catchcmd "-nullvalue x test.db" ""
167 } {0 {}} 159 } {0 {}}
168 do_test shell1-1.15.3 { 160 do_test shell1-1.15.3 {
169 set res [catchcmd "-nullvalue" ""] 161 set res [catchcmd "-nullvalue" ""]
170 set rc [lindex $res 0] 162 set rc [lindex $res 0]
171 list $rc \ 163 list $rc \
172 [regexp {Error: missing argument to -nullvalue} $res] 164 [regexp {Error: missing argument to -nullvalue} $res]
173 } {1 1} 165 } {1 1}
174 166
175 # -version show SQLite version 167 # -version show SQLite version
176 do_test shell1-1.16.1 { 168 do_test shell1-1.16.1 {
177 set x [catchcmd "-version test.db" ""] 169 set x [catchcmd "-version test.db" ""]
178 } {/3.[0-9.]+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+/} 170 } {/3.[0-9.]+ 20\d\d-[01]\d-\d\d \d\d:\d\d:\d\d [0-9a-f]+/}
179 171
180 #---------------------------------------------------------------------------- 172 #----------------------------------------------------------------------------
181 # Test cases shell1-2.*: Basic "dot" command token parsing. 173 # Test cases shell1-2.*: Basic "dot" command token parsing.
182 # 174 #
183 175
184 # check first token handling 176 # check first token handling
185 do_test shell1-2.1.1 { 177 do_test shell1-2.1.1 {
186 catchcmd "test.db" ".foo" 178 catchcmd "test.db" ".foo"
187 } {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for hel p}} 179 } {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for hel p}}
188 do_test shell1-2.1.2 { 180 do_test shell1-2.1.2 {
189 catchcmd "test.db" ".\"foo OFF\"" 181 catchcmd "test.db" ".\"foo OFF\""
190 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} 182 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
191 do_test shell1-2.1.3 { 183 do_test shell1-2.1.3 {
192 catchcmd "test.db" ".\'foo OFF\'" 184 catchcmd "test.db" ".\'foo OFF\'"
193 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} 185 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
194 186
195 # unbalanced quotes 187 # unbalanced quotes
196 do_test shell1-2.2.1 { 188 do_test shell1-2.2.1 {
197 catchcmd "test.db" ".\"foo OFF" 189 catchcmd "test.db" ".\"foo OFF"
198 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} 190 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
199 do_test shell1-2.2.2 { 191 do_test shell1-2.2.2 {
200 catchcmd "test.db" ".\'foo OFF" 192 catchcmd "test.db" ".\'foo OFF"
201 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} 193 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
202 do_test shell1-2.2.3 { 194 do_test shell1-2.2.3 {
203 catchcmd "test.db" ".explain \"OFF" 195 catchcmd "test.db" ".explain \"OFF"
204 } {0 {}} 196 } {0 {}}
205 do_test shell1-2.2.4 { 197 do_test shell1-2.2.4 {
206 catchcmd "test.db" ".explain \'OFF" 198 catchcmd "test.db" ".explain \'OFF"
207 } {0 {}} 199 } {0 {}}
208 do_test shell1-2.2.5 { 200 do_test shell1-2.2.5 {
209 catchcmd "test.db" ".mode \"insert FOO" 201 catchcmd "test.db" ".mode \"insert FOO"
210 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} 202 } {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
211 do_test shell1-2.2.6 { 203 do_test shell1-2.2.6 {
212 catchcmd "test.db" ".mode \'insert FOO" 204 catchcmd "test.db" ".mode \'insert FOO"
213 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} 205 } {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
214 206
215 # check multiple tokens, and quoted tokens 207 # check multiple tokens, and quoted tokens
216 do_test shell1-2.3.1 { 208 do_test shell1-2.3.1 {
217 catchcmd "test.db" ".explain 1" 209 catchcmd "test.db" ".explain 1"
218 } {0 {}} 210 } {0 {}}
219 do_test shell1-2.3.2 { 211 do_test shell1-2.3.2 {
220 catchcmd "test.db" ".explain on" 212 catchcmd "test.db" ".explain on"
221 } {0 {}} 213 } {0 {}}
222 do_test shell1-2.3.3 { 214 do_test shell1-2.3.3 {
223 catchcmd "test.db" ".explain \"1 2 3\"" 215 catchcmd "test.db" ".explain \"1 2 3\""
224 } {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}} 216 } {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}}
225 do_test shell1-2.3.4 { 217 do_test shell1-2.3.4 {
226 catchcmd "test.db" ".explain \"OFF\"" 218 catchcmd "test.db" ".explain \"OFF\""
227 } {0 {}} 219 } {0 {}}
228 do_test shell1-2.3.5 { 220 do_test shell1-2.3.5 {
229 catchcmd "test.db" ".\'explain\' \'OFF\'" 221 catchcmd "test.db" ".\'explain\' \'OFF\'"
230 } {0 {}} 222 } {0 {}}
231 do_test shell1-2.3.6 { 223 do_test shell1-2.3.6 {
232 catchcmd "test.db" ".explain \'OFF\'" 224 catchcmd "test.db" ".explain \'OFF\'"
233 } {0 {}} 225 } {0 {}}
234 do_test shell1-2.3.7 { 226 do_test shell1-2.3.7 {
235 catchcmd "test.db" ".\'explain\' \'OFF\'" 227 catchcmd "test.db" ".\'explain\' \'OFF\'"
236 } {0 {}} 228 } {0 {}}
237 229
238 # check quoted args are unquoted 230 # check quoted args are unquoted
239 do_test shell1-2.4.1 { 231 do_test shell1-2.4.1 {
240 catchcmd "test.db" ".mode FOO" 232 catchcmd "test.db" ".mode FOO"
241 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} 233 } {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
242 do_test shell1-2.4.2 { 234 do_test shell1-2.4.2 {
243 catchcmd "test.db" ".mode csv" 235 catchcmd "test.db" ".mode csv"
244 } {0 {}} 236 } {0 {}}
245 do_test shell1-2.4.2 { 237 do_test shell1-2.4.2 {
246 catchcmd "test.db" ".mode \"csv\"" 238 catchcmd "test.db" ".mode \"csv\""
247 } {0 {}} 239 } {0 {}}
248 240
249 241
250 #---------------------------------------------------------------------------- 242 #----------------------------------------------------------------------------
251 # Test cases shell1-3.*: Basic test that "dot" command can be called. 243 # Test cases shell1-3.*: Basic test that "dot" command can be called.
(...skipping 22 matching lines...) Expand all
274 catchcmd "test.db" ".bail ON" 266 catchcmd "test.db" ".bail ON"
275 } {0 {}} 267 } {0 {}}
276 do_test shell1-3.2.3 { 268 do_test shell1-3.2.3 {
277 catchcmd "test.db" ".bail OFF" 269 catchcmd "test.db" ".bail OFF"
278 } {0 {}} 270 } {0 {}}
279 do_test shell1-3.2.4 { 271 do_test shell1-3.2.4 {
280 # too many arguments 272 # too many arguments
281 catchcmd "test.db" ".bail OFF BAD" 273 catchcmd "test.db" ".bail OFF BAD"
282 } {1 {Usage: .bail on|off}} 274 } {1 {Usage: .bail on|off}}
283 275
276 ifcapable vtab {
284 # .databases List names and files of attached databases 277 # .databases List names and files of attached databases
285 do_test shell1-3.3.1 { 278 do_test shell1-3.3.1 {
286 catchcmd "-csv test.db" ".databases" 279 catchcmd "-csv test.db" ".databases"
287 } "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/" 280 } "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
288 do_test shell1-3.3.2 { 281 do_test shell1-3.3.2 {
289 # extra arguments ignored 282 # extra arguments ignored
290 catchcmd "test.db" ".databases BAD" 283 catchcmd "test.db" ".databases BAD"
291 } "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/" 284 } "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/"
285 }
292 286
293 # .dump ?TABLE? ... Dump the database in an SQL text format 287 # .dump ?TABLE? ... Dump the database in an SQL text format
294 # If TABLE specified, only dump tables matching 288 # If TABLE specified, only dump tables matching
295 # LIKE pattern TABLE. 289 # LIKE pattern TABLE.
296 do_test shell1-3.4.1 { 290 do_test shell1-3.4.1 {
297 set res [catchcmd "test.db" ".dump"] 291 set res [catchcmd "test.db" ".dump"]
298 list [regexp {BEGIN TRANSACTION;} $res] \ 292 list [regexp {BEGIN TRANSACTION;} $res] \
299 [regexp {COMMIT;} $res] 293 [regexp {COMMIT;} $res]
300 } {1 1} 294 } {1 1}
301 do_test shell1-3.4.2 { 295 do_test shell1-3.4.2 {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 # csv Comma-separated values 422 # csv Comma-separated values
429 # column Left-aligned columns. (See .width) 423 # column Left-aligned columns. (See .width)
430 # html HTML <table> code 424 # html HTML <table> code
431 # insert SQL insert statements for TABLE 425 # insert SQL insert statements for TABLE
432 # line One value per line 426 # line One value per line
433 # list Values delimited by .separator strings 427 # list Values delimited by .separator strings
434 # tabs Tab-separated values 428 # tabs Tab-separated values
435 # tcl TCL list elements 429 # tcl TCL list elements
436 do_test shell1-3.13.1 { 430 do_test shell1-3.13.1 {
437 catchcmd "test.db" ".mode" 431 catchcmd "test.db" ".mode"
438 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} 432 } {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
439 do_test shell1-3.13.2 { 433 do_test shell1-3.13.2 {
440 catchcmd "test.db" ".mode FOO" 434 catchcmd "test.db" ".mode FOO"
441 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} 435 } {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
442 do_test shell1-3.13.3 { 436 do_test shell1-3.13.3 {
443 catchcmd "test.db" ".mode csv" 437 catchcmd "test.db" ".mode csv"
444 } {0 {}} 438 } {0 {}}
445 do_test shell1-3.13.4 { 439 do_test shell1-3.13.4 {
446 catchcmd "test.db" ".mode column" 440 catchcmd "test.db" ".mode column"
447 } {0 {}} 441 } {0 {}}
448 do_test shell1-3.13.5 { 442 do_test shell1-3.13.5 {
449 catchcmd "test.db" ".mode html" 443 catchcmd "test.db" ".mode html"
450 } {0 {}} 444 } {0 {}}
451 do_test shell1-3.13.6 { 445 do_test shell1-3.13.6 {
(...skipping 12 matching lines...) Expand all
464 catchcmd "test.db" ".mode tcl" 458 catchcmd "test.db" ".mode tcl"
465 } {0 {}} 459 } {0 {}}
466 do_test shell1-3.13.11 { 460 do_test shell1-3.13.11 {
467 # extra arguments ignored 461 # extra arguments ignored
468 catchcmd "test.db" ".mode tcl BAD" 462 catchcmd "test.db" ".mode tcl BAD"
469 } {0 {}} 463 } {0 {}}
470 464
471 # don't allow partial mode type matches 465 # don't allow partial mode type matches
472 do_test shell1-3.13.12 { 466 do_test shell1-3.13.12 {
473 catchcmd "test.db" ".mode l" 467 catchcmd "test.db" ".mode l"
474 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} 468 } {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
475 do_test shell1-3.13.13 { 469 do_test shell1-3.13.13 {
476 catchcmd "test.db" ".mode li" 470 catchcmd "test.db" ".mode li"
477 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} 471 } {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}
478 do_test shell1-3.13.14 { 472 do_test shell1-3.13.14 {
479 catchcmd "test.db" ".mode lin" 473 catchcmd "test.db" ".mode lin"
480 } {0 {}} 474 } {0 {}}
481 475
482 # .nullvalue STRING Print STRING in place of NULL values 476 # .nullvalue STRING Print STRING in place of NULL values
483 do_test shell1-3.14.1 { 477 do_test shell1-3.14.1 {
484 catchcmd "test.db" ".nullvalue" 478 catchcmd "test.db" ".nullvalue"
485 } {1 {Usage: .nullvalue STRING}} 479 } {1 {Usage: .nullvalue STRING}}
486 do_test shell1-3.14.2 { 480 do_test shell1-3.14.2 {
487 catchcmd "test.db" ".nullvalue FOO" 481 catchcmd "test.db" ".nullvalue FOO"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 # LIKE pattern TABLE. 563 # LIKE pattern TABLE.
570 do_test shell1-3.21.1 { 564 do_test shell1-3.21.1 {
571 catchcmd "test.db" ".schema" 565 catchcmd "test.db" ".schema"
572 } {0 {}} 566 } {0 {}}
573 do_test shell1-3.21.2 { 567 do_test shell1-3.21.2 {
574 catchcmd "test.db" ".schema FOO" 568 catchcmd "test.db" ".schema FOO"
575 } {0 {}} 569 } {0 {}}
576 do_test shell1-3.21.3 { 570 do_test shell1-3.21.3 {
577 # too many arguments 571 # too many arguments
578 catchcmd "test.db" ".schema FOO BAD" 572 catchcmd "test.db" ".schema FOO BAD"
579 } {1 {Usage: .schema ?LIKE-PATTERN?}} 573 } {1 {Usage: .schema ?--indent? ?LIKE-PATTERN?}}
580 574
581 do_test shell1-3.21.4 { 575 do_test shell1-3.21.4 {
582 catchcmd "test.db" { 576 catchcmd "test.db" {
583 CREATE TABLE t1(x); 577 CREATE TABLE t1(x);
584 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1; 578 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
585 CREATE VIEW v1 AS SELECT y+1 FROM v2; 579 CREATE VIEW v1 AS SELECT y+1 FROM v2;
586 } 580 }
587 catchcmd "test.db" ".schema" 581 catchcmd "test.db" ".schema"
588 } {0 {CREATE TABLE t1(x); 582 } {0 {CREATE TABLE t1(x);
589 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1; 583 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
(...skipping 28 matching lines...) Expand all
618 [regexp {rowseparator:} $res] \ 612 [regexp {rowseparator:} $res] \
619 [regexp {stats:} $res] \ 613 [regexp {stats:} $res] \
620 [regexp {width:} $res] 614 [regexp {width:} $res]
621 } {1 1 1 1 1 1 1 1 1 1} 615 } {1 1 1 1 1 1 1 1 1 1}
622 do_test shell1-3.23.2 { 616 do_test shell1-3.23.2 {
623 # too many arguments 617 # too many arguments
624 catchcmd "test.db" ".show BAD" 618 catchcmd "test.db" ".show BAD"
625 } {1 {Usage: .show}} 619 } {1 {Usage: .show}}
626 620
627 # .stats ON|OFF Turn stats on or off 621 # .stats ON|OFF Turn stats on or off
628 do_test shell1-3.23b.1 { 622 #do_test shell1-3.23b.1 {
629 catchcmd "test.db" ".stats" 623 # catchcmd "test.db" ".stats"
630 } {1 {Usage: .stats on|off}} 624 #} {1 {Usage: .stats on|off}}
631 do_test shell1-3.23b.2 { 625 do_test shell1-3.23b.2 {
632 catchcmd "test.db" ".stats ON" 626 catchcmd "test.db" ".stats ON"
633 } {0 {}} 627 } {0 {}}
634 do_test shell1-3.23b.3 { 628 do_test shell1-3.23b.3 {
635 catchcmd "test.db" ".stats OFF" 629 catchcmd "test.db" ".stats OFF"
636 } {0 {}} 630 } {0 {}}
637 do_test shell1-3.23b.4 { 631 do_test shell1-3.23b.4 {
638 # too many arguments 632 # too many arguments
639 catchcmd "test.db" ".stats OFF BAD" 633 catchcmd "test.db" ".stats OFF BAD"
640 } {1 {Usage: .stats on|off}} 634 } {1 {Usage: .stats ?on|off?}}
641 635
642 # .tables ?TABLE? List names of tables 636 # .tables ?TABLE? List names of tables
643 # If TABLE specified, only list tables matching 637 # If TABLE specified, only list tables matching
644 # LIKE pattern TABLE. 638 # LIKE pattern TABLE.
645 do_test shell1-3.24.1 { 639 do_test shell1-3.24.1 {
646 catchcmd "test.db" ".tables" 640 catchcmd "test.db" ".tables"
647 } {0 {}} 641 } {0 {}}
648 do_test shell1-3.24.2 { 642 do_test shell1-3.24.2 {
649 catchcmd "test.db" ".tables FOO" 643 catchcmd "test.db" ".tables FOO"
650 } {0 {}} 644 } {0 {}}
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 for {set i 1} {$i < 256} {incr i} { 865 for {set i 1} {$i < 256} {incr i} {
872 # 866 #
873 # NOTE: Due to how the Tcl [exec] command works (i.e. where it treats 867 # NOTE: Due to how the Tcl [exec] command works (i.e. where it treats
874 # command channels opened for it as textual ones), the carriage 868 # command channels opened for it as textual ones), the carriage
875 # return character (and on Windows, the end-of-file character) 869 # return character (and on Windows, the end-of-file character)
876 # cannot be used here. 870 # cannot be used here.
877 # 871 #
878 if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} { 872 if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} {
879 continue 873 continue
880 } 874 }
875 if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue
876 if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue
881 set hex [format %02X $i] 877 set hex [format %02X $i]
882 set char [subst \\x$hex]; set oldChar $char 878 set char [subst \\x$hex]; set oldChar $char
883 set escapes [list] 879 set escapes [list]
884 if {$tcl_platform(platform)=="windows"} { 880 if {$tcl_platform(platform)=="windows"} {
885 # 881 #
886 # NOTE: On Windows, we need to escape all the whitespace characters, 882 # NOTE: On Windows, we need to escape all the whitespace characters,
887 # the alarm (\a) character, and those with special meaning to 883 # the alarm (\a) character, and those with special meaning to
888 # the SQLite shell itself. 884 # the SQLite shell itself.
889 # 885 #
890 set escapes [list \ 886 set escapes [list \
(...skipping 15 matching lines...) Expand all
906 " " "\" \"" \" \\\" ' \"'\" \\ \\\\] 902 " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
907 } 903 }
908 set char [string map $escapes $char] 904 set char [string map $escapes $char]
909 set x [catchcmdex test.db ".print $char\n"] 905 set x [catchcmdex test.db ".print $char\n"]
910 set code [lindex $x 0] 906 set code [lindex $x 0]
911 set res [lindex $x 1] 907 set res [lindex $x 1]
912 if {$code ne "0"} { 908 if {$code ne "0"} {
913 error "failed with error: $res" 909 error "failed with error: $res"
914 } 910 }
915 if {$res ne "$oldChar\n"} { 911 if {$res ne "$oldChar\n"} {
916 error "failed with byte $hex mismatch" 912 if {[llength $res] > 0} {
913 set got [format %02X [scan $res %c]]
914 } else {
915 set got <empty>
916 }
917 error "failed with byte $hex mismatch, got $got"
917 } 918 }
918 } 919 }
919 } {} 920 } {}
920 921
922 # These test cases do not work on MinGW
923 if 0 {
924
925 # The string used here is the word "test" in Chinese.
926 # In UTF-8, it is encoded as: \xE6\xB5\x8B\xE8\xAF\x95
927 set test \u6D4B\u8BD5
928
929 do_test shell1-6.0 {
930 set fileName $test; append fileName .db
931 catch {forcedelete $fileName}
932 set x [catchcmdex $fileName "CREATE TABLE t1(x);\n.schema\n"]
933 set code [lindex $x 0]
934 set res [string trim [lindex $x 1]]
935 if {$code ne "0"} {
936 error "failed with error: $res"
937 }
938 if {$res ne "CREATE TABLE t1(x);"} {
939 error "failed with mismatch: $res"
940 }
941 if {![file exists $fileName]} {
942 error "file \"$fileName\" (Unicode) does not exist"
943 }
944 forcedelete $fileName
945 } {}
946
947 do_test shell1-6.1 {
948 catch {forcedelete test3.db}
949 set x [catchcmdex test3.db \
950 "CREATE TABLE [encoding convertto utf-8 $test](x);\n.schema\n"]
951 set code [lindex $x 0]
952 set res [string trim [lindex $x 1]]
953 if {$code ne "0"} {
954 error "failed with error: $res"
955 }
956 if {$res ne "CREATE TABLE ${test}(x);"} {
957 error "failed with mismatch: $res"
958 }
959 forcedelete test3.db
960 } {}
961 }
962
921 finish_test 963 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/shared3.test ('k') | third_party/sqlite/src/test/shell2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698