3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # The focus of this file is testing the CLI shell tool.
14 # $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
19 # shell3-1.*: Basic tests for running SQL statments from command line.
20 # shell3-2.*: Basic tests for running SQL file from command line.
21 # shell3-3.*: Basic tests for processing odd SQL constructs.
23 set testdir [file dirname $argv0]
24 source $testdir/tester.tcl
25 set CLI [test_cli_invocation]
27 forcedelete test.db test.db-journal test.db-wal
31 # There are inconsistencies in command-line argument quoting on Windows.
32 # In particular, individual applications are responsible for command-line
33 # parsing in Windows, not the shell. Depending on whether the sqlite3.exe
34 # program is compiled with MinGW or MSVC, the command-line parsing is
35 # different. This causes problems for the tests below. To avoid
36 # issues, these tests are disabled for windows.
38 if {$::tcl_platform(platform)=="windows"} {
43 #----------------------------------------------------------------------------
44 # shell3-1.*: Basic tests for running SQL statments from command line.
47 # Run SQL statement from command line
50 set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ]
51 set fexist [file exist foo.db]
55 catchcmd "foo.db" ".tables"
58 catchcmd "foo.db \"DROP TABLE t1;\""
61 catchcmd "foo.db" ".tables"
64 catchcmd "foo.db \"CREATE TABLE t1(a); DROP TABLE t1;\""
67 catchcmd "foo.db" ".tables"
70 catchcmd "foo.db \"CREATE TABLE\""
71 } {1 {Error: in prepare, incomplete input}}
73 #----------------------------------------------------------------------------
74 # shell3-2.*: Basic tests for running SQL file from command line.
77 # Run SQL file from command line
80 set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ]
81 set fexist [file exist foo.db]
85 catchcmd "foo.db" ".tables"
88 catchcmd "foo.db" "DROP TABLE t1;"
91 catchcmd "foo.db" ".tables"
94 catchcmd "foo.db" "CREATE TABLE t1(a); DROP TABLE t1;"
97 catchcmd "foo.db" ".tables"
100 catchcmd "foo.db" "CREATE TABLE"
101 } {1 {Parse error near line 1: incomplete input}}
104 #----------------------------------------------------------------------------
105 # shell3-3.*: Basic tests for processing odd SQL constructs.
108 # Run combinations of odd identifiers, comments, semicolon placement
111 set rc [ catchcmd "foo.db" {CREATE TABLE t1("
114 ); CREATE TABLE t2("a[""b""]");
116 INSERT INTO t1 VALUES ('
118 INSERT INTO t2 VALUES ('
122 SELECT * from t1 limit 1;
123 SELECT * from t2 limit 1;
125 set fexist [file exist foo.db]