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 # shell2-1.*: Misc. test of various tickets and reported errors.
21 set testdir [file dirname $argv0]
22 source $testdir/tester.tcl
23 if {$tcl_platform(platform)=="windows"} {
28 if {![file executable $CLI]} {
33 forcedelete test.db test.db-journal test.db-wal
37 #----------------------------------------------------------------------------
38 # shell2-1.*: Misc. test of various tickets and reported errors.
41 # Batch mode not creating databases.
42 # Reported on mailing list by Ken Zalewski.
43 # Ticket [aeff892c57].
44 do_test shell2-1.1.1 {
46 set rc [ catchcmd "-batch foo.db" "CREATE TABLE t1(a);" ]
47 set fexist [file exist foo.db]
51 # Shell silently ignores extra parameters.
52 # Ticket [f5cb008a65].
53 do_test shell2-1.2.1 {
54 set rc [catch { eval exec $CLI \":memory:\" \"select 3\" \"select 4\" } msg]
56 [regexp {Error: too many options: "select 4"} $msg]
59 # Test a problem reported on the mailing list. The shell was at one point
60 # returning the generic SQLITE_ERROR message ("SQL error or missing database")
61 # instead of the "too many levels..." message in the test below.
64 catchcmd "-batch test.db" {
65 PRAGMA recursive_triggers = ON;
66 CREATE TABLE t5(a PRIMARY KEY, b, c);
67 INSERT INTO t5 VALUES(1, 2, 3);
68 CREATE TRIGGER au_tble AFTER UPDATE ON t5 BEGIN
69 UPDATE OR IGNORE t5 SET a = new.a, c = 10;
72 UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1;
74 } {1 {Error: near line 9: too many levels of trigger recursion}}
78 # Shell not echoing all commands with echo on.
79 # Ticket [eb620916be].
82 # NB. whitespace is important
83 do_test shell2-1.4.1 {
85 catchcmd "foo.db" {CREATE TABLE foo(a);
86 INSERT INTO foo(a) VALUES(1);
90 # Test with echo on using command line option
91 # NB. whitespace is important
92 do_test shell2-1.4.2 {
94 catchcmd "-echo foo.db" {CREATE TABLE foo(a);
95 INSERT INTO foo(a) VALUES(1);
97 } {0 {CREATE TABLE foo(a);
98 INSERT INTO foo(a) VALUES(1);
102 # Test with echo on using dot command
103 # NB. whitespace is important
104 do_test shell2-1.4.3 {
106 catchcmd "foo.db" {.echo ON
108 INSERT INTO foo(a) VALUES(1);
110 } {0 {CREATE TABLE foo(a);
111 INSERT INTO foo(a) VALUES(1);
115 # Test with echo on using dot command and
116 # turning off mid- processing.
117 # NB. whitespace is important
118 do_test shell2-1.4.4 {
120 catchcmd "foo.db" {.echo ON
123 INSERT INTO foo(a) VALUES(1);
125 } {0 {CREATE TABLE foo(a);
129 # Test with echo on using dot command and
130 # multiple commands per line.
131 # NB. whitespace is important
132 do_test shell2-1.4.5 {
134 catchcmd "foo.db" {.echo ON
135 CREATE TABLE foo1(a);
136 INSERT INTO foo1(a) VALUES(1);
137 CREATE TABLE foo2(b);
138 INSERT INTO foo2(b) VALUES(1);
139 SELECT * FROM foo1; SELECT * FROM foo2;
140 INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);
141 SELECT * FROM foo1; SELECT * FROM foo2;
143 } {0 {CREATE TABLE foo1(a);
144 INSERT INTO foo1(a) VALUES(1);
145 CREATE TABLE foo2(b);
146 INSERT INTO foo2(b) VALUES(1);
151 INSERT INTO foo1(a) VALUES(2);
152 INSERT INTO foo2(b) VALUES(2);
161 # Test with echo on and headers on using dot command and
162 # multiple commands per line.
163 # NB. whitespace is important
164 do_test shell2-1.4.6 {
166 catchcmd "foo.db" {.echo ON
168 CREATE TABLE foo1(a);
169 INSERT INTO foo1(a) VALUES(1);
170 CREATE TABLE foo2(b);
171 INSERT INTO foo2(b) VALUES(1);
172 SELECT * FROM foo1; SELECT * FROM foo2;
173 INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);
174 SELECT * FROM foo1; SELECT * FROM foo2;
177 CREATE TABLE foo1(a);
178 INSERT INTO foo1(a) VALUES(1);
179 CREATE TABLE foo2(b);
180 INSERT INTO foo2(b) VALUES(1);
187 INSERT INTO foo1(a) VALUES(2);
188 INSERT INTO foo2(b) VALUES(2);