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

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/test/shell2.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
(Empty)
1 # 2009 Nov 11
2 #
3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
5 #
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.
9 #
10 #***********************************************************************
11 #
12 # The focus of this file is testing the CLI shell tool.
13 #
14 # $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
15 #
16
17 # Test plan:
18 #
19 # shell2-1.*: Misc. test of various tickets and reported errors.
20 #
21 set testdir [file dirname $argv0]
22 source $testdir/tester.tcl
23 if {$tcl_platform(platform)=="windows"} {
24 set CLI "sqlite3.exe"
25 } else {
26 set CLI "./sqlite3"
27 }
28 if {![file executable $CLI]} {
29 finish_test
30 return
31 }
32 db close
33 forcedelete test.db test.db-journal test.db-wal
34 sqlite3 db test.db
35
36
37 #----------------------------------------------------------------------------
38 # shell2-1.*: Misc. test of various tickets and reported errors.
39 #
40
41 # Batch mode not creating databases.
42 # Reported on mailing list by Ken Zalewski.
43 # Ticket [aeff892c57].
44 do_test shell2-1.1.1 {
45 forcedelete foo.db
46 set rc [ catchcmd "-batch foo.db" "CREATE TABLE t1(a);" ]
47 set fexist [file exist foo.db]
48 list $rc $fexist
49 } {{0 {}} 1}
50
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]
55 list $rc \
56 [regexp {Error: too many options: "select 4"} $msg]
57 } {1 1}
58
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.
62 #
63 do_test shell2-1.3 {
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;
70 END;
71
72 UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1;
73 }
74 } {1 {Error: near line 9: too many levels of trigger recursion}}
75
76
77
78 # Shell not echoing all commands with echo on.
79 # Ticket [eb620916be].
80
81 # Test with echo off
82 # NB. whitespace is important
83 do_test shell2-1.4.1 {
84 forcedelete foo.db
85 catchcmd "foo.db" {CREATE TABLE foo(a);
86 INSERT INTO foo(a) VALUES(1);
87 SELECT * FROM foo;}
88 } {0 1}
89
90 # Test with echo on using command line option
91 # NB. whitespace is important
92 do_test shell2-1.4.2 {
93 forcedelete foo.db
94 catchcmd "-echo foo.db" {CREATE TABLE foo(a);
95 INSERT INTO foo(a) VALUES(1);
96 SELECT * FROM foo;}
97 } {0 {CREATE TABLE foo(a);
98 INSERT INTO foo(a) VALUES(1);
99 SELECT * FROM foo;
100 1}}
101
102 # Test with echo on using dot command
103 # NB. whitespace is important
104 do_test shell2-1.4.3 {
105 forcedelete foo.db
106 catchcmd "foo.db" {.echo ON
107 CREATE TABLE foo(a);
108 INSERT INTO foo(a) VALUES(1);
109 SELECT * FROM foo;}
110 } {0 {CREATE TABLE foo(a);
111 INSERT INTO foo(a) VALUES(1);
112 SELECT * FROM foo;
113 1}}
114
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 {
119 forcedelete foo.db
120 catchcmd "foo.db" {.echo ON
121 CREATE TABLE foo(a);
122 .echo OFF
123 INSERT INTO foo(a) VALUES(1);
124 SELECT * FROM foo;}
125 } {0 {CREATE TABLE foo(a);
126 .echo OFF
127 1}}
128
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 {
133 forcedelete foo.db
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;
142 }
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);
147 SELECT * FROM foo1;
148 1
149 SELECT * FROM foo2;
150 1
151 INSERT INTO foo1(a) VALUES(2);
152 INSERT INTO foo2(b) VALUES(2);
153 SELECT * FROM foo1;
154 1
155 2
156 SELECT * FROM foo2;
157 1
158 2
159 }}
160
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 {
165 forcedelete foo.db
166 catchcmd "foo.db" {.echo ON
167 .headers 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;
175 }
176 } {0 {.headers ON
177 CREATE TABLE foo1(a);
178 INSERT INTO foo1(a) VALUES(1);
179 CREATE TABLE foo2(b);
180 INSERT INTO foo2(b) VALUES(1);
181 SELECT * FROM foo1;
182 a
183 1
184 SELECT * FROM foo2;
185 b
186 1
187 INSERT INTO foo1(a) VALUES(2);
188 INSERT INTO foo2(b) VALUES(2);
189 SELECT * FROM foo1;
190 a
191 1
192 2
193 SELECT * FROM foo2;
194 b
195 1
196 2
197 }}
198
199 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/test/shell1.test ('k') | third_party/sqlite/sqlite-src-3080704/test/shell3.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698