SQLite

Check-in [650b32825a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix test issues for Windows portability.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 650b32825a85baff11b8e568649fd797066c8ab1
User & Date: mistachkin 2013-09-13 23:26:47.163
Context
2013-09-13
23:27
Fix Windows SDK compiler warning. (check-in: d5fc3f1dab user: mistachkin tags: trunk)
23:26
Fix test issues for Windows portability. (check-in: 650b32825a user: mistachkin tags: trunk)
22:38
VSIX tooling changes to support Visual Studio 2013. (check-in: d56fac4031 user: mistachkin tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/bigfile2.test.
53
54
55
56
57
58
59
60
61
62
  execsql { INSERT INTO t1 VALUES(3, $str) }
  db close
  sqlite3 db test.db
  db one { SELECT b FROM t1 WHERE a = 3 }
} $str

db close
file delete test.db

finish_test







|


53
54
55
56
57
58
59
60
61
62
  execsql { INSERT INTO t1 VALUES(3, $str) }
  db close
  sqlite3 db test.db
  db one { SELECT b FROM t1 WHERE a = 3 }
} $str

db close
delete_file test.db

finish_test
Changes to test/quota.test.
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
} 
foreach file [glob -nocomplain quota-test-A*] {
  forcedelete $file
}
do_test quota-4.4.1 {
  set ::quota {}
  sqlite3_quota_set $::quotagroup 10000 quota_callback
  file delete -force ./quota-test-A1.db ./quota-test-A2.db
  sqlite3 db ./quota-test-A1.db
  db eval {
     CREATE TABLE t1(x);
     INSERT INTO t1 VALUES(randomblob(5000));
  }
  quota_list
} [list $quotagroup]







|







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
} 
foreach file [glob -nocomplain quota-test-A*] {
  forcedelete $file
}
do_test quota-4.4.1 {
  set ::quota {}
  sqlite3_quota_set $::quotagroup 10000 quota_callback
  forcedelete ./quota-test-A1.db ./quota-test-A2.db
  sqlite3 db ./quota-test-A1.db
  db eval {
     CREATE TABLE t1(x);
     INSERT INTO t1 VALUES(randomblob(5000));
  }
  quota_list
} [list $quotagroup]
Changes to test/quota2.test.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

source $testdir/malloc_common.tcl

db close
sqlite3_quota_initialize "" 1

foreach dir {quota2a/x1 quota2a/x2 quota2a quota2b quota2c} {
  file delete -force $dir
}
foreach dir {quota2a quota2a/x1 quota2a/x2 quota2b quota2c} {
  file mkdir $dir
}

# The standard_path procedure converts a pathname into a standard format
# that is the same across platforms.







|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

source $testdir/malloc_common.tcl

db close
sqlite3_quota_initialize "" 1

foreach dir {quota2a/x1 quota2a/x2 quota2a quota2b quota2c} {
  forcedelete $dir
}
foreach dir {quota2a quota2a/x1 quota2a/x2 quota2b quota2c} {
  file mkdir $dir
}

# The standard_path procedure converts a pathname into a standard format
# that is the same across platforms.
Changes to test/shell1.test.
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
} {1 {Error: unknown command or invalid arguments:  "quit". Enter ".help" for help}}

# .read FILENAME         Execute SQL in FILENAME
do_test shell1-3.19.1 {
  catchcmd "test.db" ".read"
} {1 {Error: unknown command or invalid arguments:  "read". Enter ".help" for help}}
do_test shell1-3.19.2 {
  file delete -force FOO
  catchcmd "test.db" ".read FOO"
} {1 {Error: cannot open "FOO"}}
do_test shell1-3.19.3 {
  # too many arguments
  catchcmd "test.db" ".read FOO BAD"
} {1 {Error: unknown command or invalid arguments:  "read". Enter ".help" for help}}








|







532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
} {1 {Error: unknown command or invalid arguments:  "quit". Enter ".help" for help}}

# .read FILENAME         Execute SQL in FILENAME
do_test shell1-3.19.1 {
  catchcmd "test.db" ".read"
} {1 {Error: unknown command or invalid arguments:  "read". Enter ".help" for help}}
do_test shell1-3.19.2 {
  forcedelete FOO
  catchcmd "test.db" ".read FOO"
} {1 {Error: cannot open "FOO"}}
do_test shell1-3.19.3 {
  # too many arguments
  catchcmd "test.db" ".read FOO BAD"
} {1 {Error: unknown command or invalid arguments:  "read". Enter ".help" for help}}

Changes to test/shell2.test.
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#   shell2-1.*: Misc. test of various tickets and reported errors.
#

# Batch mode not creating databases.  
# Reported on mailing list by Ken Zalewski.
# Ticket [aeff892c57].
do_test shell2-1.1.1 {
  file delete -force foo.db
  set rc [ catchcmd "-batch foo.db" "CREATE TABLE t1(a);" ]
  set fexist [file exist foo.db]
  list $rc $fexist
} {{0 {}} 1}

# Shell silently ignores extra parameters.
# Ticket [f5cb008a65].







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#   shell2-1.*: Misc. test of various tickets and reported errors.
#

# Batch mode not creating databases.  
# Reported on mailing list by Ken Zalewski.
# Ticket [aeff892c57].
do_test shell2-1.1.1 {
  forcedelete foo.db
  set rc [ catchcmd "-batch foo.db" "CREATE TABLE t1(a);" ]
  set fexist [file exist foo.db]
  list $rc $fexist
} {{0 {}} 1}

# Shell silently ignores extra parameters.
# Ticket [f5cb008a65].
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

# Shell not echoing all commands with echo on.
# Ticket [eb620916be].

# Test with echo off
# NB. whitespace is important
do_test shell2-1.4.1 {
  file delete -force foo.db
  catchcmd "foo.db" {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 1}

# Test with echo on using command line option
# NB. whitespace is important
do_test shell2-1.4.2 {
  file delete -force foo.db
  catchcmd "-echo foo.db" {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;
1}}

# Test with echo on using dot command
# NB. whitespace is important
do_test shell2-1.4.3 {
  file delete -force foo.db
  catchcmd "foo.db" {.echo ON
CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;
1}}

# Test with echo on using dot command and 
# turning off mid- processing.
# NB. whitespace is important
do_test shell2-1.4.4 {
  file delete -force foo.db
  catchcmd "foo.db" {.echo ON
CREATE TABLE foo(a);
.echo OFF
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 {CREATE TABLE foo(a);
.echo OFF
1}}

# Test with echo on using dot command and 
# multiple commands per line.
# NB. whitespace is important
do_test shell2-1.4.5 {
  file delete -force foo.db
  catchcmd "foo.db" {.echo ON
CREATE TABLE foo1(a);
INSERT INTO foo1(a) VALUES(1);
CREATE TABLE foo2(b);
INSERT INTO foo2(b) VALUES(1);
SELECT * FROM foo1; SELECT * FROM foo2;
INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);







|








|











|













|













|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

# Shell not echoing all commands with echo on.
# Ticket [eb620916be].

# Test with echo off
# NB. whitespace is important
do_test shell2-1.4.1 {
  forcedelete foo.db
  catchcmd "foo.db" {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 1}

# Test with echo on using command line option
# NB. whitespace is important
do_test shell2-1.4.2 {
  forcedelete foo.db
  catchcmd "-echo foo.db" {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;
1}}

# Test with echo on using dot command
# NB. whitespace is important
do_test shell2-1.4.3 {
  forcedelete foo.db
  catchcmd "foo.db" {.echo ON
CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 {CREATE TABLE foo(a);
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;
1}}

# Test with echo on using dot command and 
# turning off mid- processing.
# NB. whitespace is important
do_test shell2-1.4.4 {
  forcedelete foo.db
  catchcmd "foo.db" {.echo ON
CREATE TABLE foo(a);
.echo OFF
INSERT INTO foo(a) VALUES(1);
SELECT * FROM foo;}
} {0 {CREATE TABLE foo(a);
.echo OFF
1}}

# Test with echo on using dot command and 
# multiple commands per line.
# NB. whitespace is important
do_test shell2-1.4.5 {
  forcedelete foo.db
  catchcmd "foo.db" {.echo ON
CREATE TABLE foo1(a);
INSERT INTO foo1(a) VALUES(1);
CREATE TABLE foo2(b);
INSERT INTO foo2(b) VALUES(1);
SELECT * FROM foo1; SELECT * FROM foo2;
INSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
1
2}}

# Test with echo on and headers on using dot command and 
# multiple commands per line.
# NB. whitespace is important
do_test shell2-1.4.6 {
  file delete -force foo.db
  catchcmd "foo.db" {.echo ON
.headers ON
CREATE TABLE foo1(a);
INSERT INTO foo1(a) VALUES(1);
CREATE TABLE foo2(b);
INSERT INTO foo2(b) VALUES(1);
SELECT * FROM foo1; SELECT * FROM foo2;







|







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
1
2}}

# Test with echo on and headers on using dot command and 
# multiple commands per line.
# NB. whitespace is important
do_test shell2-1.4.6 {
  forcedelete foo.db
  catchcmd "foo.db" {.echo ON
.headers ON
CREATE TABLE foo1(a);
INSERT INTO foo1(a) VALUES(1);
CREATE TABLE foo2(b);
INSERT INTO foo2(b) VALUES(1);
SELECT * FROM foo1; SELECT * FROM foo2;
Changes to test/shell3.test.
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#----------------------------------------------------------------------------
#   shell3-1.*: Basic tests for running SQL statments from command line.
#

# Run SQL statement from command line
do_test shell3-1.1 {
  file delete -force foo.db
  set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ]
  set fexist [file exist foo.db]
  list $rc $fexist
} {{0 {}} 1}
do_test shell3-1.2 {
  catchcmd "foo.db" ".tables"
} {0 t1}







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#----------------------------------------------------------------------------
#   shell3-1.*: Basic tests for running SQL statments from command line.
#

# Run SQL statement from command line
do_test shell3-1.1 {
  forcedelete foo.db
  set rc [ catchcmd "foo.db \"CREATE TABLE t1(a);\"" ]
  set fexist [file exist foo.db]
  list $rc $fexist
} {{0 {}} 1}
do_test shell3-1.2 {
  catchcmd "foo.db" ".tables"
} {0 t1}
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

#----------------------------------------------------------------------------
#   shell3-2.*: Basic tests for running SQL file from command line.
#

# Run SQL file from command line
do_test shell3-2.1 {
  file delete -force foo.db
  set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ]
  set fexist [file exist foo.db]
  list $rc $fexist
} {{0 {}} 1}
do_test shell3-2.2 {
  catchcmd "foo.db" ".tables"
} {0 t1}







|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

#----------------------------------------------------------------------------
#   shell3-2.*: Basic tests for running SQL file from command line.
#

# Run SQL file from command line
do_test shell3-2.1 {
  forcedelete foo.db
  set rc [ catchcmd "foo.db" "CREATE TABLE t1(a);" ]
  set fexist [file exist foo.db]
  list $rc $fexist
} {{0 {}} 1}
do_test shell3-2.2 {
  catchcmd "foo.db" ".tables"
} {0 t1}
Changes to test/shell5.test.
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
}
if {![file executable $CLI]} {
  finish_test
  return
}
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db

#----------------------------------------------------------------------------
# Test cases shell5-1.*: Basic handling of the .import and .separator commands.
#

# .import FILE TABLE     Import data from FILE into TABLE
do_test shell5-1.1.1 {







<







28
29
30
31
32
33
34

35
36
37
38
39
40
41
}
if {![file executable $CLI]} {
  finish_test
  return
}
db close
forcedelete test.db test.db-journal test.db-wal


#----------------------------------------------------------------------------
# Test cases shell5-1.*: Basic handling of the .import and .separator commands.
#

# .import FILE TABLE     Import data from FILE into TABLE
do_test shell5-1.1.1 {
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  set res [catchcmd "test.db" {.separator ,
.show}]
  list [regexp {separator: \",\"} $res]
} {1}

# import file doesn't exist
do_test shell5-1.4.1 {
  file delete -force FOO
  set res [catchcmd "test.db" {CREATE TABLE t1(a, b);
.import FOO t1}]
} {1 {Error: cannot open "FOO"}}

# empty import file
do_test shell5-1.4.2 {
  file delete -force shell5.csv
  set in [open shell5.csv w]
  close $in
  set res [catchcmd "test.db" {.import shell5.csv t1
SELECT COUNT(*) FROM t1;}]
} {0 0}

# import file with 1 row, 1 column (expecting 2 cols)







|






|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  set res [catchcmd "test.db" {.separator ,
.show}]
  list [regexp {separator: \",\"} $res]
} {1}

# import file doesn't exist
do_test shell5-1.4.1 {
  forcedelete FOO
  set res [catchcmd "test.db" {CREATE TABLE t1(a, b);
.import FOO t1}]
} {1 {Error: cannot open "FOO"}}

# empty import file
do_test shell5-1.4.2 {
  forcedelete shell5.csv
  set in [open shell5.csv w]
  close $in
  set res [catchcmd "test.db" {.import shell5.csv t1
SELECT COUNT(*) FROM t1;}]
} {0 0}

# import file with 1 row, 1 column (expecting 2 cols)
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247

248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
.import shell5.csv t3
SELECT COUNT(*) FROM t3;}]
} [list 0 $rows]

# Inport from a pipe.  (Unix only, as it requires "awk")
if {$tcl_platform(platform)=="unix"} {
  do_test shell5-1.8 {
    file delete -force test.db
    catchcmd test.db {.mode csv
.import "|awk 'END{print \"x,y\";for(i=1;i<=5;i++){print i \",this is \" i}}'" t1
SELECT * FROM t1;}
  } {0 {1,"this is 1"
2,"this is 2"
3,"this is 3"
4,"this is 4"
5,"this is 5"}}
}

# Import columns containing quoted strings
do_test shell5-1.9 {
  set out [open shell5.csv w]

  puts $out {1,"",11}
  puts $out {2,"x",22}
  puts $out {3,"""",33}
  puts $out {4,"hello",44}
  puts $out "5,55,\"\"\r"
  puts $out {6,66,"x"}
  puts $out {7,77,""""}
  puts $out {8,88,"hello"}
  puts $out {"",9,99}
  puts $out {"x",10,110}
  puts $out {"""",11,121}
  puts $out {"hello",12,132}
  close $out
  file delete -force test.db
  catchcmd test.db {.mode csv
    CREATE TABLE t1(a,b,c);
.import shell5.csv t1
  }
  sqlite3 db test.db
  db eval {SELECT *, '|' FROM t1 ORDER BY rowid}
} {1 {} 11 | 2 x 22 | 3 {"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {"} | 8 88 hello | {} 9 99 | x 10 110 | {"} 11 121 | hello 12 132 |}
db close

finish_test







|













>













|










226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
.import shell5.csv t3
SELECT COUNT(*) FROM t3;}]
} [list 0 $rows]

# Inport from a pipe.  (Unix only, as it requires "awk")
if {$tcl_platform(platform)=="unix"} {
  do_test shell5-1.8 {
    forcedelete test.db
    catchcmd test.db {.mode csv
.import "|awk 'END{print \"x,y\";for(i=1;i<=5;i++){print i \",this is \" i}}'" t1
SELECT * FROM t1;}
  } {0 {1,"this is 1"
2,"this is 2"
3,"this is 3"
4,"this is 4"
5,"this is 5"}}
}

# Import columns containing quoted strings
do_test shell5-1.9 {
  set out [open shell5.csv w]
  fconfigure $out -translation lf
  puts $out {1,"",11}
  puts $out {2,"x",22}
  puts $out {3,"""",33}
  puts $out {4,"hello",44}
  puts $out "5,55,\"\"\r"
  puts $out {6,66,"x"}
  puts $out {7,77,""""}
  puts $out {8,88,"hello"}
  puts $out {"",9,99}
  puts $out {"x",10,110}
  puts $out {"""",11,121}
  puts $out {"hello",12,132}
  close $out
  forcedelete test.db
  catchcmd test.db {.mode csv
    CREATE TABLE t1(a,b,c);
.import shell5.csv t1
  }
  sqlite3 db test.db
  db eval {SELECT *, '|' FROM t1 ORDER BY rowid}
} {1 {} 11 | 2 x 22 | 3 {"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {"} | 8 88 hello | {} 9 99 | x 10 110 | {"} 11 121 | hello 12 132 |}
db close

finish_test