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 #***********************************************************************
13 # The focus of this file is testing the CLI shell tool.
15 # $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
20 # shell3-1.*: Basic tests for running SQL statments from command line.
21 # shell3-2.*: Basic tests for running SQL file from command line.
22 # shell3-3.*: Basic tests for processing odd SQL constructs.
24 set testdir [file dirname $argv0]
25 source $testdir/tester.tcl
26 set CLI [test_cli_invocation]
28 forcedelete test.db test.db-journal test.db-wal
32 # There are inconsistencies in command-line argument quoting on Windows.
33 # In particular, individual applications are responsible for command-line
34 # parsing in Windows, not the shell. Depending on whether the sqlite3.exe
35 # program is compiled with MinGW or MSVC, the command-line parsing is
36 # different. This causes problems for the tests below. To avoid
37 # issues, these tests are disabled for windows.
39 if {$::tcl_platform(platform)=="windows"} {
44 #----------------------------------------------------------------------------
45 # shell3-1.*: Basic tests for running SQL statments from command line.
48 # Run SQL statement from command line
51 set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ]
52 set fexist [file exist foo.db]
56 catchcmd "foo.db" ".tables"
59 catchcmd "foo.db \"DROP TABLE t1;\""
62 catchcmd "foo.db" ".tables"
65 catchcmd "foo.db \"CREATE TABLE t1(a); DROP TABLE t1;\""
68 catchcmd "foo.db" ".tables"
71 catchcmd "foo.db \"CREATE TABLE\""
72 } {1 {Error: in prepare, incomplete input}}
74 #----------------------------------------------------------------------------
75 # shell3-2.*: Basic tests for running SQL file from command line.
78 # Run SQL file from command line
81 set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ]
82 set fexist [file exist foo.db]
86 catchcmd "foo.db" ".tables"
89 catchcmd "foo.db" "DROP TABLE t1;"
92 catchcmd "foo.db" ".tables"
95 catchcmd "foo.db" "CREATE TABLE t1(a); DROP TABLE t1;"
98 catchcmd "foo.db" ".tables"
101 catchcmd "foo.db" "CREATE TABLE"
102 } {1 {Parse error near line 1: incomplete input}}
105 #----------------------------------------------------------------------------
106 # shell3-3.*: Basic tests for processing odd SQL constructs.
109 # Run combinations of odd identifiers, comments, semicolon placement
112 set rc [ catchcmd "foo.db" {CREATE TABLE t1("
115 ); CREATE TABLE t2("a[""b""]");
117 INSERT INTO t1 VALUES ('
119 INSERT INTO t2 VALUES ('
123 SELECT * from t1 limit 1;
124 SELECT * from t2 limit 1;
126 set fexist [file exist foo.db]