/ Check-in [93caabb6]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add the catchcmd_collapse_space command and use it to help make shell testing more robust against TCL space escapes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 93caabb66082f76ef161a51ac822b919517a7171
User & Date: drh 2016-03-25 17:09:16
Context
2016-03-25
17:19
In the Win32 VFS, avoid trying to use rand_s() on Windows CE. check-in: 183350fa user: mistachkin tags: trunk
17:09
Add the catchcmd_collapse_space command and use it to help make shell testing more robust against TCL space escapes. check-in: 93caabb6 user: drh tags: trunk
12:10
Fix two instances of undefined behavior in the C code - both harmless for all current compilers. check-in: 99fd194c user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/shell1.test.

271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
do_test shell1-3.2.4 {
  # too many arguments
  catchcmd "test.db" ".bail OFF BAD"
} {1 {Usage: .bail on|off}}

# .databases             List names and files of attached databases
do_test shell1-3.3.1 {
  set x [catchcmd "-csv test.db" ".databases"]
  set x [subst -nocommands -novariables $x]
} "/0.+main.+[string map {/ .} [string range [get_pwd] 0 10]].*/"
do_test shell1-3.3.2 {
  # extra arguments ignored
  set x [catchcmd "test.db" ".databases BAD"]
  set x [subst -nocommands -novariables $x]
} "/0.+main.+[string map {/ .} [string range [get_pwd] 0 10]].*/"

# .dump ?TABLE? ...      Dump the database in an SQL text format
#                          If TABLE specified, only dump tables matching
#                          LIKE pattern TABLE.
do_test shell1-3.4.1 {
  set res [catchcmd "test.db" ".dump"]







|
<



|
<







271
272
273
274
275
276
277
278

279
280
281
282

283
284
285
286
287
288
289
do_test shell1-3.2.4 {
  # too many arguments
  catchcmd "test.db" ".bail OFF BAD"
} {1 {Usage: .bail on|off}}

# .databases             List names and files of attached databases
do_test shell1-3.3.1 {
  catchcmd_collapse_space "-csv test.db" ".databases"

} "/0.+main.+[string map {/ .} [string range [get_pwd] 0 10]].*/"
do_test shell1-3.3.2 {
  # extra arguments ignored
  catchcmd_collapse_space "test.db" ".databases BAD"

} "/0.+main.+[string map {/ .} [string range [get_pwd] 0 10]].*/"

# .dump ?TABLE? ...      Dump the database in an SQL text format
#                          If TABLE specified, only dump tables matching
#                          LIKE pattern TABLE.
do_test shell1-3.4.1 {
  set res [catchcmd "test.db" ".dump"]

Changes to test/tester.tcl.

818
819
820
821
822
823
824











825
826
827
828
829
830
831
  set out [open cmds.txt w]
  puts $out $cmd
  close $out
  set line "exec $CLI $db < cmds.txt"
  set rc [catch { eval $line } msg]
  list $rc $msg
}












proc catchcmdex {db {cmd ""}} {
  global CLI
  set out [open cmds.txt w]
  fconfigure $out -encoding binary -translation binary
  puts -nonewline $out $cmd
  close $out







>
>
>
>
>
>
>
>
>
>
>







818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
  set out [open cmds.txt w]
  puts $out $cmd
  close $out
  set line "exec $CLI $db < cmds.txt"
  set rc [catch { eval $line } msg]
  list $rc $msg
}

proc catchcmd_collapse_space {db {cmd ""}} {
  global CLI
  set out [open cmds.txt w]
  puts $out $cmd
  close $out
  set line "exec $CLI $db < cmds.txt"
  set rc [catch { eval $line } msg]
  regsub -all {\s+} $msg { } msg
  list $rc $msg
}

proc catchcmdex {db {cmd ""}} {
  global CLI
  set out [open cmds.txt w]
  fconfigure $out -encoding binary -translation binary
  puts -nonewline $out $cmd
  close $out