/ Check-in [9fb7da69]
Login

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

Overview
Comment:Move the shell test scripts into the test/ subfolder so that they are run automatically by "make test".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9fb7da6904e479f4671eeebf1a4b7e4e4e4f2b7b
User & Date: drh 2012-04-24 12:46:05
Context
2012-04-24
13:14
New test cases for the ".dump" and ".mode insert" commands of the shell. check-in: dfce8569 user: drh tags: trunk
12:46
Move the shell test scripts into the test/ subfolder so that they are run automatically by "make test". check-in: 9fb7da69 user: drh tags: trunk
12:12
Fix a sign-extension problem for BLOB output in ".insert" mode of the command-line shell. check-in: 282f2a74 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Name change from tool/shell1.test to test/shell1.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # The focus of this file is testing the CLI shell tool.
    13     13   #
    14         -# $Id: shell1.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
    15     14   #
    16     15   
    17     16   # Test plan:
    18     17   #
    19     18   #   shell1-1.*: Basic command line option handling.
    20     19   #   shell1-2.*: Basic "dot" command token parsing.
    21     20   #   shell1-3.*: Basic test that "dot" command can be called.
    22     21   #
    23         -
    24         -package require sqlite3
    25         -
    26         -set CLI "./sqlite3"
    27         -
    28         -proc do_test {name cmd expected} {
    29         -  puts -nonewline "$name ..."
    30         -  set res [uplevel $cmd]
    31         -  if {$res eq $expected} {
    32         -    puts Ok
    33         -  } else {
    34         -    puts Error
    35         -    puts "  Got: $res"
    36         -    puts "  Expected: $expected"
    37         -    exit
    38         -  }
           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
    39     32   }
    40         -
    41         -proc execsql {sql} {
    42         -  uplevel [list db eval $sql]
    43         -}
    44         -
    45         -proc catchsql {sql} {
    46         -  set rc [catch {uplevel [list db eval $sql]} msg]
    47         -  list $rc $msg
    48         -}
    49         -
    50         -proc catchcmd {db {cmd ""}} {
    51         -  global CLI
    52         -  set out [open cmds.txt w]
    53         -  puts $out $cmd
    54         -  close $out
    55         -  set line "exec $CLI $db < cmds.txt"
    56         -  set rc [catch { eval $line } msg]
    57         -  list $rc $msg
    58         -}
    59         -
    60         -file delete -force test.db test.db.journal
           33  +db close
           34  +forcedelete test.db test.db-journal test.db-wal
    61     35   sqlite3 db test.db
    62     36   
    63     37   #----------------------------------------------------------------------------
    64     38   # Test cases shell1-1.*: Basic command line option handling.
    65     39   #
    66     40   
    67     41   # invalid option
................................................................................
   713    687   } {1 {Error: unknown command or invalid arguments:  "timer". Enter ".help" for help}}
   714    688   
   715    689   do_test shell1-3-28.1 {
   716    690     catchcmd test.db \
   717    691        ".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
   718    692   } "0 {(123) hello\n456}"
   719    693   
   720         -puts "CLI tests completed successfully"
          694  +finish_test

Name change from tool/shell2.test to test/shell2.test.

    14     14   # $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
    15     15   #
    16     16   
    17     17   # Test plan:
    18     18   #
    19     19   #   shell2-1.*: Misc. test of various tickets and reported errors.
    20     20   #
    21         -
    22         -package require sqlite3
    23         -
    24         -set CLI "./sqlite3"
    25         -
    26         -proc do_test {name cmd expected} {
    27         -  puts -nonewline "$name ..."
    28         -  set res [uplevel $cmd]
    29         -  if {$res eq $expected} {
    30         -    puts Ok
    31         -  } else {
    32         -    puts Error
    33         -    puts "  Got: $res"
    34         -    puts "  Expected: $expected"
    35         -    exit
    36         -  }
           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
    37     31   }
    38         -
    39         -proc execsql {sql} {
    40         -  uplevel [list db eval $sql]
    41         -}
    42         -
    43         -proc catchsql {sql} {
    44         -  set rc [catch {uplevel [list db eval $sql]} msg]
    45         -  list $rc $msg
    46         -}
    47         -
    48         -proc catchcmd {db {cmd ""}} {
    49         -  global CLI
    50         -  set out [open cmds.txt w]
    51         -  puts $out $cmd
    52         -  close $out
    53         -  set line "exec $CLI $db < cmds.txt"
    54         -  set rc [catch { eval $line } msg]
    55         -  list $rc $msg
    56         -}
    57         -
    58         -file delete -force test.db test.db.journal
           32  +db close
           33  +forcedelete test.db test.db-journal test.db-wal
    59     34   sqlite3 db test.db
    60     35   
    61     36   
    62     37   #----------------------------------------------------------------------------
    63     38   #   shell2-1.*: Misc. test of various tickets and reported errors.
    64     39   #
    65     40   
................................................................................
   215    190   1
   216    191   2
   217    192   SELECT * FROM foo2;
   218    193   b
   219    194   1
   220    195   2}}
   221    196   
   222         -puts "CLI tests completed successfully"
          197  +finish_test

Name change from tool/shell3.test to test/shell3.test.

    15     15   #
    16     16   
    17     17   # Test plan:
    18     18   #
    19     19   #   shell3-1.*: Basic tests for running SQL statments from command line.
    20     20   #   shell3-2.*: Basic tests for running SQL file from command line.
    21     21   #
    22         -
    23         -package require sqlite3
    24         -
    25         -set CLI "./sqlite3"
    26         -
    27         -proc do_test {name cmd expected} {
    28         -  puts -nonewline "$name ..."
    29         -  set res [uplevel $cmd]
    30         -  if {$res eq $expected} {
    31         -    puts Ok
    32         -  } else {
    33         -    puts Error
    34         -    puts "  Got: $res"
    35         -    puts "  Expected: $expected"
    36         -    exit
    37         -  }
           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
    38     32   }
    39         -
    40         -proc execsql {sql} {
    41         -  uplevel [list db eval $sql]
    42         -}
    43         -
    44         -proc catchsql {sql} {
    45         -  set rc [catch {uplevel [list db eval $sql]} msg]
    46         -  list $rc $msg
    47         -}
    48         -
    49         -proc catchcmd {db {cmd ""}} {
    50         -  global CLI
    51         -  set out [open cmds.txt w]
    52         -  puts $out $cmd
    53         -  close $out
    54         -  set line "exec $CLI $db < cmds.txt"
    55         -  set rc [catch { eval $line } msg]
    56         -  list $rc $msg
    57         -}
    58         -
    59         -file delete -force test.db test.db.journal
           33  +db close
           34  +forcedelete test.db test.db-journal test.db-wal
    60     35   sqlite3 db test.db
    61         -
    62     36   
    63     37   #----------------------------------------------------------------------------
    64     38   #   shell3-1.*: Basic tests for running SQL statments from command line.
    65     39   #
    66     40   
    67     41   # Run SQL statement from command line
    68     42   do_test shell3-1.1 {
................................................................................
   116     90   do_test shell3-2.6 {
   117     91     catchcmd "foo.db" ".tables"
   118     92   } {0 {}}
   119     93   do_test shell3-2.7 {
   120     94     catchcmd "foo.db" "CREATE TABLE"
   121     95   } {1 {Error: incomplete SQL: CREATE TABLE}}
   122     96   
   123         -
   124         -puts "CLI tests completed successfully"
           97  +finish_test

Name change from tool/shell4.test to test/shell4.test.

    15     15   # $Id: shell4.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
    16     16   #
    17     17   
    18     18   # Test plan:
    19     19   #
    20     20   #   shell4-1.*: Basic tests specific to the "stats" command.
    21     21   #
    22         -
    23         -set CLI "./sqlite3"
    24         -
    25         -proc do_test {name cmd expected} {
    26         -  puts -nonewline "$name ..."
    27         -  set res [uplevel $cmd]
    28         -  if {$res eq $expected} {
    29         -    puts Ok
    30         -  } else {
    31         -    puts Error
    32         -    puts "  Got: $res"
    33         -    puts "  Expected: $expected"
    34         -    exit
    35         -  }
           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
    36     32   }
    37         -
    38         -proc catchcmd {db {cmd ""}} {
    39         -  global CLI
    40         -  set out [open cmds.txt w]
    41         -  puts $out $cmd
    42         -  close $out
    43         -  set line "exec $CLI $db < cmds.txt"
    44         -  set rc [catch { eval $line } msg]
    45         -  list $rc $msg
    46         -}
    47         -
    48         -file delete -force test.db test.db.journal
           33  +db close
           34  +forcedelete test.db test.db-journal test.db-wal
           35  +sqlite3 db test.db
    49     36   
    50     37   #----------------------------------------------------------------------------
    51     38   # Test cases shell4-1.*: Tests specific to the "stats" command.
    52     39   #
    53     40   
    54     41   # should default to off
    55     42   do_test shell4-1.1.1 {
................................................................................
   122    109   SELECT 1;
   123    110   }]
   124    111     list [regexp {Memory Used} $res] \
   125    112          [regexp {Heap Usage} $res] \
   126    113          [regexp {Autoindex Inserts} $res]
   127    114   } {1 1 1}
   128    115   
   129         -puts "CLI tests completed successfully"
          116  +finish_test

Name change from tool/shell5.test to test/shell5.test.

    15     15   # $Id: shell5.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
    16     16   #
    17     17   
    18     18   # Test plan:
    19     19   #
    20     20   #   shell5-1.*: Basic tests specific to the ".import" command.
    21     21   #
    22         -
    23         -set CLI "./sqlite3"
    24         -
    25         -proc do_test {name cmd expected} {
    26         -  puts -nonewline "$name ..."
    27         -  set res [uplevel $cmd]
    28         -  if {$res eq $expected} {
    29         -    puts Ok
    30         -  } else {
    31         -    puts Error
    32         -    puts "  Got: $res"
    33         -    puts "  Expected: $expected"
    34         -    exit
    35         -  }
           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
    36     32   }
    37         -
    38         -proc catchcmd {db {cmd ""}} {
    39         -  global CLI
    40         -  set out [open cmds.txt w]
    41         -  puts $out $cmd
    42         -  close $out
    43         -  set line "exec $CLI $db < cmds.txt"
    44         -  set rc [catch { eval $line } msg]
    45         -  list $rc $msg
    46         -}
    47         -
    48         -file delete -force test.db test.db.journal
           33  +db close
           34  +forcedelete test.db test.db-journal test.db-wal
           35  +sqlite3 db test.db
    49     36   
    50     37   #----------------------------------------------------------------------------
    51     38   # Test cases shell5-1.*: Basic handling of the .import and .separator commands.
    52     39   #
    53     40   
    54     41   # .import FILE TABLE     Import data from FILE into TABLE
    55     42   do_test shell5-1.1.1 {
................................................................................
   235    222     }
   236    223     close $in
   237    224     set res [catchcmd "test.db" {CREATE TABLE t3(a);
   238    225   .import shell5.csv t3
   239    226   SELECT COUNT(*) FROM t3;}]
   240    227   } [list 0 $rows]
   241    228   
   242         -
   243         -puts "CLI tests completed successfully"
          229  +finish_test

Changes to test/tester.tcl.

   513    513       }
   514    514     } else {
   515    515       puts " Omitted"
   516    516       omit_test $name "pattern mismatch" 0
   517    517     }
   518    518     flush stdout
   519    519   }
          520  +
          521  +proc catchcmd {db {cmd ""}} {
          522  +  global CLI
          523  +  set out [open cmds.txt w]
          524  +  puts $out $cmd
          525  +  close $out
          526  +  set line "exec $CLI $db < cmds.txt"
          527  +  set rc [catch { eval $line } msg]
          528  +  list $rc $msg
          529  +}
   520    530   
   521    531   proc filepath_normalize {p} {
   522    532     # test cases should be written to assume "unix"-like file paths
   523    533     if {$::tcl_platform(platform)!="unix"} {
   524    534       # lreverse*2 as a hack to remove any unneeded {} after the string map
   525    535       lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]]
   526    536     } {