Index: third_party/sqlite/src/test/shell1.test |
diff --git a/third_party/sqlite/src/test/shell1.test b/third_party/sqlite/src/test/shell1.test |
index 2fda62ee13f1ba53f605c06b020c25c15b951d21..95c3130bdd7dccf43a3c15fbadff564291d64c06 100644 |
--- a/third_party/sqlite/src/test/shell1.test |
+++ b/third_party/sqlite/src/test/shell1.test |
@@ -21,15 +21,7 @@ |
# |
set testdir [file dirname $argv0] |
source $testdir/tester.tcl |
-if {$tcl_platform(platform)=="windows"} { |
- set CLI "sqlite3.exe" |
-} else { |
- set CLI "./sqlite3" |
-} |
-if {![file executable $CLI]} { |
- finish_test |
- return |
-} |
+set CLI [test_find_cli] |
db close |
forcedelete test.db test.db-journal test.db-wal |
sqlite3 db test.db |
@@ -53,7 +45,7 @@ do_test shell1-1.1.1b { |
} {1 1} |
# error on extra options |
do_test shell1-1.1.2 { |
- catchcmd "test.db \"select 3\" \"select 4\"" "" |
+ catchcmd "test.db \"select+3\" \"select+4\"" "" |
} {0 {3 |
4}} |
# error on extra options |
@@ -84,20 +76,20 @@ do_test shell1-1.3.3 { |
# -echo print commands before execution |
do_test shell1-1.4.1 { |
- catchcmd "-echo test.db" "" |
+ catchcmd "-echo test.db" "" |
} {0 {}} |
# -[no]header turn headers on or off |
do_test shell1-1.5.1 { |
- catchcmd "-header test.db" "" |
+ catchcmd "-header test.db" "" |
} {0 {}} |
do_test shell1-1.5.2 { |
- catchcmd "-noheader test.db" "" |
+ catchcmd "-noheader test.db" "" |
} {0 {}} |
# -bail stop after hitting an error |
do_test shell1-1.6.1 { |
- catchcmd "-bail test.db" "" |
+ catchcmd "-bail test.db" "" |
} {0 {}} |
# -interactive force interactive I/O |
@@ -111,40 +103,40 @@ do_test shell1-1.7.1 { |
# -batch force batch I/O |
do_test shell1-1.8.1 { |
- catchcmd "-batch test.db" "" |
+ catchcmd "-batch test.db" "" |
} {0 {}} |
# -column set output mode to 'column' |
do_test shell1-1.9.1 { |
- catchcmd "-column test.db" "" |
+ catchcmd "-column test.db" "" |
} {0 {}} |
# -csv set output mode to 'csv' |
do_test shell1-1.10.1 { |
- catchcmd "-csv test.db" "" |
+ catchcmd "-csv test.db" "" |
} {0 {}} |
# -html set output mode to HTML |
do_test shell1-1.11.1 { |
- catchcmd "-html test.db" "" |
+ catchcmd "-html test.db" "" |
} {0 {}} |
# -line set output mode to 'line' |
do_test shell1-1.12.1 { |
- catchcmd "-line test.db" "" |
+ catchcmd "-line test.db" "" |
} {0 {}} |
# -list set output mode to 'list' |
do_test shell1-1.13.1 { |
- catchcmd "-list test.db" "" |
+ catchcmd "-list test.db" "" |
} {0 {}} |
# -separator 'x' set output field separator (|) |
do_test shell1-1.14.1 { |
- catchcmd "-separator 'x' test.db" "" |
+ catchcmd "-separator 'x' test.db" "" |
} {0 {}} |
do_test shell1-1.14.2 { |
- catchcmd "-separator x test.db" "" |
+ catchcmd "-separator x test.db" "" |
} {0 {}} |
do_test shell1-1.14.3 { |
set res [catchcmd "-separator" ""] |
@@ -155,7 +147,7 @@ do_test shell1-1.14.3 { |
# -stats print memory stats before each finalize |
do_test shell1-1.14b.1 { |
- catchcmd "-stats test.db" "" |
+ catchcmd "-stats test.db" "" |
} {0 {}} |
# -nullvalue 'text' set text string for NULL values |
@@ -183,7 +175,7 @@ do_test shell1-1.16.1 { |
# check first token handling |
do_test shell1-2.1.1 { |
- catchcmd "test.db" ".foo" |
+ catchcmd "test.db" ".foo" |
} {1 {Error: unknown command or invalid arguments: "foo". Enter ".help" for help}} |
do_test shell1-2.1.2 { |
catchcmd "test.db" ".\"foo OFF\"" |
@@ -207,10 +199,10 @@ do_test shell1-2.2.4 { |
} {0 {}} |
do_test shell1-2.2.5 { |
catchcmd "test.db" ".mode \"insert FOO" |
-} {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} |
+} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}} |
do_test shell1-2.2.6 { |
catchcmd "test.db" ".mode \'insert FOO" |
-} {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} |
+} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}} |
# check multiple tokens, and quoted tokens |
do_test shell1-2.3.1 { |
@@ -238,7 +230,7 @@ do_test shell1-2.3.7 { |
# check quoted args are unquoted |
do_test shell1-2.4.1 { |
catchcmd "test.db" ".mode FOO" |
-} {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} |
+} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}} |
do_test shell1-2.4.2 { |
catchcmd "test.db" ".mode csv" |
} {0 {}} |
@@ -281,14 +273,16 @@ do_test shell1-3.2.4 { |
catchcmd "test.db" ".bail OFF BAD" |
} {1 {Usage: .bail on|off}} |
+ifcapable vtab { |
# .databases List names and files of attached databases |
do_test shell1-3.3.1 { |
catchcmd "-csv test.db" ".databases" |
-} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/" |
+} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/" |
do_test shell1-3.3.2 { |
# extra arguments ignored |
catchcmd "test.db" ".databases BAD" |
-} "/0 +.*main +[string map {/ .} [string range [get_pwd] 0 10]].*/" |
+} "/0.+main.+[string map {/ ".{1,2}"} [string range [get_pwd] 0 10]].*/" |
+} |
# .dump ?TABLE? ... Dump the database in an SQL text format |
# If TABLE specified, only dump tables matching |
@@ -435,10 +429,10 @@ do_test shell1-3.12.3 { |
# tcl TCL list elements |
do_test shell1-3.13.1 { |
catchcmd "test.db" ".mode" |
-} {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} |
+} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}} |
do_test shell1-3.13.2 { |
catchcmd "test.db" ".mode FOO" |
-} {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} |
+} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}} |
do_test shell1-3.13.3 { |
catchcmd "test.db" ".mode csv" |
} {0 {}} |
@@ -471,10 +465,10 @@ do_test shell1-3.13.11 { |
# don't allow partial mode type matches |
do_test shell1-3.13.12 { |
catchcmd "test.db" ".mode l" |
-} {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} |
+} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}} |
do_test shell1-3.13.13 { |
catchcmd "test.db" ".mode li" |
-} {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}} |
+} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}} |
do_test shell1-3.13.14 { |
catchcmd "test.db" ".mode lin" |
} {0 {}} |
@@ -576,7 +570,7 @@ do_test shell1-3.21.2 { |
do_test shell1-3.21.3 { |
# too many arguments |
catchcmd "test.db" ".schema FOO BAD" |
-} {1 {Usage: .schema ?LIKE-PATTERN?}} |
+} {1 {Usage: .schema ?--indent? ?LIKE-PATTERN?}} |
do_test shell1-3.21.4 { |
catchcmd "test.db" { |
@@ -625,9 +619,9 @@ do_test shell1-3.23.2 { |
} {1 {Usage: .show}} |
# .stats ON|OFF Turn stats on or off |
-do_test shell1-3.23b.1 { |
- catchcmd "test.db" ".stats" |
-} {1 {Usage: .stats on|off}} |
+#do_test shell1-3.23b.1 { |
+# catchcmd "test.db" ".stats" |
+#} {1 {Usage: .stats on|off}} |
do_test shell1-3.23b.2 { |
catchcmd "test.db" ".stats ON" |
} {0 {}} |
@@ -637,7 +631,7 @@ do_test shell1-3.23b.3 { |
do_test shell1-3.23b.4 { |
# too many arguments |
catchcmd "test.db" ".stats OFF BAD" |
-} {1 {Usage: .stats on|off}} |
+} {1 {Usage: .stats ?on|off?}} |
# .tables ?TABLE? List names of tables |
# If TABLE specified, only list tables matching |
@@ -878,6 +872,8 @@ do_test shell1-5.0 { |
if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} { |
continue |
} |
+ if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue |
+ if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)=="Linux"} continue |
set hex [format %02X $i] |
set char [subst \\x$hex]; set oldChar $char |
set escapes [list] |
@@ -913,9 +909,55 @@ do_test shell1-5.0 { |
error "failed with error: $res" |
} |
if {$res ne "$oldChar\n"} { |
- error "failed with byte $hex mismatch" |
+ if {[llength $res] > 0} { |
+ set got [format %02X [scan $res %c]] |
+ } else { |
+ set got <empty> |
+ } |
+ error "failed with byte $hex mismatch, got $got" |
} |
} |
} {} |
+# These test cases do not work on MinGW |
+if 0 { |
+ |
+# The string used here is the word "test" in Chinese. |
+# In UTF-8, it is encoded as: \xE6\xB5\x8B\xE8\xAF\x95 |
+set test \u6D4B\u8BD5 |
+ |
+do_test shell1-6.0 { |
+ set fileName $test; append fileName .db |
+ catch {forcedelete $fileName} |
+ set x [catchcmdex $fileName "CREATE TABLE t1(x);\n.schema\n"] |
+ set code [lindex $x 0] |
+ set res [string trim [lindex $x 1]] |
+ if {$code ne "0"} { |
+ error "failed with error: $res" |
+ } |
+ if {$res ne "CREATE TABLE t1(x);"} { |
+ error "failed with mismatch: $res" |
+ } |
+ if {![file exists $fileName]} { |
+ error "file \"$fileName\" (Unicode) does not exist" |
+ } |
+ forcedelete $fileName |
+} {} |
+ |
+do_test shell1-6.1 { |
+ catch {forcedelete test3.db} |
+ set x [catchcmdex test3.db \ |
+ "CREATE TABLE [encoding convertto utf-8 $test](x);\n.schema\n"] |
+ set code [lindex $x 0] |
+ set res [string trim [lindex $x 1]] |
+ if {$code ne "0"} { |
+ error "failed with error: $res" |
+ } |
+ if {$res ne "CREATE TABLE ${test}(x);"} { |
+ error "failed with mismatch: $res" |
+ } |
+ forcedelete test3.db |
+} {} |
+} |
+ |
finish_test |