/ Check-in [a2a0cd4a]
Login

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

Overview
Comment:Update a few of the uri tests to work on Windows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a2a0cd4aa4a6723a849bbba590c22fd065fab55e
User & Date: shaneh 2011-06-21 19:30:19
Context
2011-06-21
19:38
Update filepath_normalize for unix. check-in: 30dd4f88 user: shaneh tags: trunk
19:30
Update a few of the uri tests to work on Windows. check-in: a2a0cd4a user: shaneh tags: trunk
18:12
Updates to nmake makefile to allow options to be passed to lib.exe. check-in: 9eac4a6b user: shaneh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/e_uri.test.

   116    116       set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy]
   117    117       sqlite3_step $STMT
   118    118       sqlite3_finalize $STMT
   119    119       list [file exists file:test.db2] [file exists test.db2]
   120    120     } {0 1}
   121    121     sqlite3_close $DB
   122    122   }
          123  +
          124  +# ensure uri processing enabled for the rest of the tests
          125  +sqlite3_shutdown
          126  +sqlite3_config_uri 1
   123    127   
   124    128   # EVIDENCE-OF: R-17482-00398 If the authority is not an empty string or
   125    129   # "localhost", an error is returned to the caller.
   126    130   #
   127    131   if {$tcl_platform(platform) == "unix"} {
   128    132     set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]
   129    133     foreach {tn uri error} "
................................................................................
   140    144       } $error
   141    145     }
   142    146   }
   143    147   
   144    148   # EVIDENCE-OF: R-45981-25528 The fragment component of a URI, if
   145    149   # present, is ignored.
   146    150   #
   147         -#   It is difficult to test that something is ignore correctly. So these tests
          151  +#   It is difficult to test that something is ignored correctly. So these tests
   148    152   #   just show that adding a fragment does not interfere with the pathname or
   149    153   #   parameters passed through to the VFS xOpen() methods.
   150    154   #
   151         -if {$tcl_platform(platform) == "unix"} {
   152         -  foreach {tn uri parse} "
   153         -    1    {file:test.db#abc}     {[pwd]/test.db {}}
   154         -    2    {file:test.db?a=b#abc} {[pwd]/test.db {a b}}
   155         -    3    {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}}
   156         -  " {
   157         -    do_test 3.$tn { parse_uri $uri } $parse
   158         -  }
          155  +foreach {tn uri parse} "
          156  +  1    {file:test.db#abc}     {[pwd]/test.db {}}
          157  +  2    {file:test.db?a=b#abc} {[pwd]/test.db {a b}}
          158  +  3    {file:test.db?a=b#?c=d} {[pwd]/test.db {a b}}
          159  +" {
          160  +  do_filepath_test 3.$tn { parse_uri $uri } $parse
   159    161   }
   160    162   
   161    163   # EVIDENCE-OF: R-62557-09390 SQLite uses the path component of the URI
   162    164   # as the name of the disk file which contains the database.
   163    165   #
   164    166   # EVIDENCE-OF: R-28659-11035 If the path begins with a '/' character,
   165    167   # then it is interpreted as an absolute path.
   166    168   #
   167    169   # EVIDENCE-OF: R-46234-61323 If the path does not begin with a '/'
   168    170   # (meaning that the authority section is omitted from the URI) then the
   169    171   # path is interpreted as a relative path.
   170    172   #
   171         -if {$tcl_platform(platform) == "unix"} {
   172         -  foreach {tn uri parse} "
   173         -    1    {file:test.db}             {[pwd]/test.db {}}
   174         -    2    {file:/test.db}            {/test.db {}}
   175         -    3    {file:///test.db}          {/test.db {}}
   176         -    4    {file://localhost/test.db} {/test.db {}}
   177         -    5    {file:/a/b/c/test.db}      {/a/b/c/test.db {}}
   178         -  " {
   179         -    do_test 4.$tn { parse_uri $uri } $parse
   180         -  }
          173  +foreach {tn uri parse} "
          174  +  1    {file:test.db}             {[pwd]/test.db {}}
          175  +  2    {file:/test.db}            {/test.db {}}
          176  +  3    {file:///test.db}          {/test.db {}}
          177  +  4    {file://localhost/test.db} {/test.db {}}
          178  +  5    {file:/a/b/c/test.db}      {/a/b/c/test.db {}}
          179  +" {
          180  +  do_filepath_test 4.$tn { parse_uri $uri } $parse
   181    181   }
   182    182   
   183    183   # EVIDENCE-OF: R-01612-30877 The "vfs" parameter may be used to specify
   184    184   # the name of a VFS object that provides the operating system interface
   185    185   # that should be used to access the database file on disk.
   186    186   #
   187    187   #   The above is tested by cases 1.* below.
................................................................................
   266    266   # EVIDENCE-OF: R-40137-26050 If the mode option is set to "rw", then the
   267    267   # database is opened for read-write (but not create) access, as if
   268    268   # SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had been set.
   269    269   #
   270    270   # EVIDENCE-OF: R-26845-32976 Value "rwc" is equivalent to setting both
   271    271   # SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.
   272    272   #
   273         -sqlite3_shutdown
   274         -sqlite3_config_uri 1
   275    273   foreach {tn uri read write create} {
   276    274     1    {file:test.db?mode=ro}     1 0 0
   277    275     2    {file:test.db?mode=rw}     1 1 0
   278    276     3    {file:test.db?mode=rwc}    1 1 1
   279    277   } {
   280    278     set RES(c,0) {1 {unable to open database file}}
   281    279     set RES(c,1) {0 {}}
................................................................................
   425    423     db close
   426    424   }
   427    425   sqlite3_enable_shared_cache $orig
   428    426   
   429    427   # EVIDENCE-OF: R-63472-46769 Specifying an unknown parameter in the
   430    428   # query component of a URI is not an error.
   431    429   #
   432         -do_test 12.1 {
          430  +do_filepath_test 12.1 {
   433    431     parse_uri file://localhost/test.db?an=unknown&parameter=is&ok=
   434    432   } {/test.db {an unknown parameter is ok {}}}
   435         -do_test 12.2 {
          433  +do_filepath_test 12.2 {
   436    434     parse_uri file://localhost/test.db?an&unknown&parameter&is&ok
   437    435   } {/test.db {an {} unknown {} parameter {} is {} ok {}}}
   438    436   
   439    437   # EVIDENCE-OF: R-27458-04043 URI hexadecimal escape sequences (%HH) are
   440    438   # supported within the path and query components of a URI.
   441    439   #
   442    440   # EVIDENCE-OF: R-52765-50368 Before the path or query components of a
................................................................................
   448    446   #   multi-byte utf-8 character using a sequence of %HH escapes.
   449    447   #
   450    448   foreach {tn uri parse} "
   451    449     1  {file:/test.%64%62}                             {/test.db {}}
   452    450     2  {file:/test.db?%68%65%6c%6c%6f=%77%6f%72%6c%64} {/test.db {hello world}}
   453    451     3  {file:/%C3%BF.db}                               {/\xFF.db {}}
   454    452   " {
   455         -  do_test 13.$tn { parse_uri $uri } $parse
          453  +  do_filepath_test 13.$tn { parse_uri $uri } $parse
   456    454   }
   457    455   
   458    456   finish_test

Changes to test/tester.tcl.

   349    349       puts "\nExpected: \[$expected\]\n     Got: \[$result\]"
   350    350       fail_test $name
   351    351     } else {
   352    352       puts " Ok"
   353    353     }
   354    354     flush stdout
   355    355   }
          356  +
          357  +proc filepath_normalize {p} {
          358  +  # test cases should be written to assume "unix"-like file paths
          359  +  if {$::tcl_platform(platform)!="unix"} {
          360  +    # lreverse*2 as a hack to remove any unneeded {} after the string map
          361  +    lreverse [lreverse [string map {\\ /} [regsub -nocase -all {[a-z]:[/\\]+} $p {/}]]]
          362  +  }
          363  +}
          364  +proc do_filepath_test {name cmd expected} {
          365  +  uplevel [list do_test $name [
          366  +    subst -nocommands { filepath_normalize [ $cmd ] }
          367  +  ] [filepath_normalize $expected]]
          368  +}
   356    369   
   357    370   proc realnum_normalize {r} {
   358    371     # different TCL versions display floating point values differently.
   359    372     string map {1.#INF inf Inf inf .0e e} [regsub -all {(e[+-])0+} $r {\1}]
   360    373   }
   361    374   proc do_realnum_test {name cmd expected} {
   362    375     uplevel [list do_test $name [