/ Check-in [d3c91c1f]
Login

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

Overview
Comment:Make the vtabH-3.1 test more portable and robust.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d3c91c1fb345fbcbfc60a897bebf771c795430c9
User & Date: mistachkin 2017-01-18 22:16:34
Context
2017-01-18
22:19
Remove superfluous option to Tcl 'lsort' in the vtabH test file. check-in: b92cc6e5 user: mistachkin tags: trunk
22:16
Make the vtabH-3.1 test more portable and robust. check-in: d3c91c1f user: mistachkin tags: trunk
22:16
Fix handling of initial hidden and/or system files in the opendir() implementation for Windows. No changes to non-test code. check-in: 26dd42b4 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/vtabH.test.

   116    116       [regexp -nocase -- {^[A-Z]:} $drive]} {
   117    117     reset_db
   118    118     register_fs_module db
   119    119     do_execsql_test 3.0 {
   120    120       SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db';
   121    121       SELECT name FROM fsdir WHERE dir = '.' AND name = '.'
   122    122     } {test.db .}
          123  +
          124  +  proc sort_files { names {nocase false} } {
          125  +    if {$nocase && $::tcl_platform(platform) eq "windows"} {
          126  +      return [lsort -dictionary -nocase $names]
          127  +    } else {
          128  +      return [lsort $names]
          129  +    }
          130  +  }
   123    131   
   124    132     proc list_root_files {} {
   125    133       if {$::tcl_platform(platform) eq "windows"} {
   126         -      set res [list]
   127         -      foreach name [glob -directory $::env(fstreeDrive)/ -- *] {
          134  +      set res [list]; set dir $::env(fstreeDrive)/; set names [list]
          135  +      eval lappend names [glob -nocomplain -directory $dir -- *]
          136  +      foreach name $names {
   128    137           if {[string index [file tail $name] 0] eq "."} continue
          138  +        if {[file attributes $name -hidden]} continue
          139  +        if {[file attributes $name -system]} continue
   129    140           lappend res $name
   130    141         }
   131         -      return $res
          142  +      return [sort_files $res true]
   132    143       } else {
   133         -      return [string map {/ {}} [glob /*]]
          144  +      return [sort_files [string map {/ {}} [glob -nocomplain -- /*]]]
   134    145       }
   135    146     }
   136    147   
   137    148     proc list_files { pattern } {
   138    149       if {$::tcl_platform(platform) eq "windows"} {
   139         -      set res [list]
   140         -      foreach name [glob -nocomplain $pattern] {
          150  +      set res [list]; set names [list]
          151  +      eval lappend names [glob -nocomplain -- $pattern]
          152  +      foreach name $names {
   141    153           if {[string index [file tail $name] 0] eq "."} continue
          154  +        if {[file attributes $name -hidden]} continue
          155  +        if {[file attributes $name -system]} continue
   142    156           lappend res $name
   143    157         }
   144         -      return $res
          158  +      return [sort_files $res]
   145    159       } else {
   146         -      return [glob -nocomplain $pattern]
          160  +      return [sort_files [glob -nocomplain -- $pattern]]
   147    161       }
   148    162     }
   149    163   
   150    164     # Read the first 5 entries from the root directory.  Except, ignore
   151    165     # files that contain the "$" character in their names as these are
   152    166     # special files on some Windows platforms.
   153    167     #
   154    168     set res [list]
   155    169     set root_files [list_root_files]
   156         -  set num_root_files [llength $root_files]
   157         -  set lim_root_files [expr {$num_root_files > 5 ? 5 : $num_root_files}]
   158         -  foreach p [lrange $root_files 0 [expr {$lim_root_files - 1}]] {
          170  +  foreach p $root_files {
   159    171       if {$::tcl_platform(platform) eq "windows"} {
   160         -      if {[regexp {\$} $p]} {incr lim_root_files -1} else {lappend res $p}
          172  +      if {![regexp {\$} $p]} {lappend res $p}
   161    173       } else {
   162    174         lappend res "/$p"
   163    175       }
   164    176     }
   165         -  do_execsql_test 3.1 [subst {
   166         -    SELECT path FROM fstree WHERE path NOT GLOB '*\$*' LIMIT $lim_root_files;
   167         -  }] $res
          177  +  set num_root_files [llength $root_files]
          178  +  do_test 3.1 {
          179  +    sort_files [execsql {
          180  +      SELECT path FROM fstree WHERE path NOT GLOB '*\$*' LIMIT $num_root_files;
          181  +    }] true
          182  +  } [sort_files $res true]
   168    183   
   169    184     # Read all entries in the current directory.
   170    185     #
   171    186     proc contents {pattern} {
   172    187       set res [list]
   173    188       foreach f [list_files $pattern] {
   174    189         lappend res $f
................................................................................
   178    193       }
   179    194       set res
   180    195     }
   181    196     set pwd "[pwd]/*"
   182    197     set res [contents $pwd]
   183    198     do_execsql_test 3.2 {
   184    199       SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1
   185         -  } [lsort $res]
          200  +  } [sort_files $res]
   186    201   
   187    202     # Add some sub-directories and files to the current directory.
   188    203     #
   189    204     do_test 3.3 {
   190    205       catch { file delete -force subdir }
   191    206       foreach {path sz} {
   192    207         subdir/x1.txt     143