OLD | NEW |
| (Empty) |
1 # 2009 Dec 16 | |
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 # shell3-1.*: Basic tests for running SQL statments from command line. | |
20 # shell3-2.*: Basic tests for running SQL file from command line. | |
21 # | |
22 set testdir [file dirname $argv0] | |
23 source $testdir/tester.tcl | |
24 if {$tcl_platform(platform)=="windows"} { | |
25 set CLI "sqlite3.exe" | |
26 } else { | |
27 set CLI "./sqlite3" | |
28 } | |
29 if {![file executable $CLI]} { | |
30 finish_test | |
31 return | |
32 } | |
33 db close | |
34 forcedelete test.db test.db-journal test.db-wal | |
35 sqlite3 db test.db | |
36 | |
37 #---------------------------------------------------------------------------- | |
38 # shell3-1.*: Basic tests for running SQL statments from command line. | |
39 # | |
40 | |
41 # Run SQL statement from command line | |
42 do_test shell3-1.1 { | |
43 forcedelete foo.db | |
44 set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ] | |
45 set fexist [file exist foo.db] | |
46 list $rc $fexist | |
47 } {{0 {}} 1} | |
48 do_test shell3-1.2 { | |
49 catchcmd "foo.db" ".tables" | |
50 } {0 t1} | |
51 do_test shell3-1.3 { | |
52 catchcmd "foo.db \"DROP TABLE t1;\"" | |
53 } {0 {}} | |
54 do_test shell3-1.4 { | |
55 catchcmd "foo.db" ".tables" | |
56 } {0 {}} | |
57 do_test shell3-1.5 { | |
58 catchcmd "foo.db \"CREATE TABLE t1(a); DROP TABLE t1;\"" | |
59 } {0 {}} | |
60 do_test shell3-1.6 { | |
61 catchcmd "foo.db" ".tables" | |
62 } {0 {}} | |
63 do_test shell3-1.7 { | |
64 catchcmd "foo.db \"CREATE TABLE\"" | |
65 } {1 {Error: near "TABLE": syntax error}} | |
66 | |
67 #---------------------------------------------------------------------------- | |
68 # shell3-2.*: Basic tests for running SQL file from command line. | |
69 # | |
70 | |
71 # Run SQL file from command line | |
72 do_test shell3-2.1 { | |
73 forcedelete foo.db | |
74 set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ] | |
75 set fexist [file exist foo.db] | |
76 list $rc $fexist | |
77 } {{0 {}} 1} | |
78 do_test shell3-2.2 { | |
79 catchcmd "foo.db" ".tables" | |
80 } {0 t1} | |
81 do_test shell3-2.3 { | |
82 catchcmd "foo.db" "DROP TABLE t1;" | |
83 } {0 {}} | |
84 do_test shell3-2.4 { | |
85 catchcmd "foo.db" ".tables" | |
86 } {0 {}} | |
87 do_test shell3-2.5 { | |
88 catchcmd "foo.db" "CREATE TABLE t1(a); DROP TABLE t1;" | |
89 } {0 {}} | |
90 do_test shell3-2.6 { | |
91 catchcmd "foo.db" ".tables" | |
92 } {0 {}} | |
93 do_test shell3-2.7 { | |
94 catchcmd "foo.db" "CREATE TABLE" | |
95 } {1 {Error: incomplete SQL: CREATE TABLE}} | |
96 | |
97 finish_test | |
OLD | NEW |