SQLite

Check-in [d3c91c1fb3]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d3c91c1fb345fbcbfc60a897bebf771c795430c9
User & Date: mistachkin 2017-01-18 22:16:34.363
Context
2017-01-18
22:19
Remove superfluous option to Tcl 'lsort' in the vtabH test file. (check-in: b92cc6e58a user: mistachkin tags: trunk)
22:16
Make the vtabH-3.1 test more portable and robust. (check-in: d3c91c1fb3 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: 26dd42b462 user: mistachkin tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/vtabH.test.
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
141


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

165

166
167

168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
    [regexp -nocase -- {^[A-Z]:} $drive]} {
  reset_db
  register_fs_module db
  do_execsql_test 3.0 {
    SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db';
    SELECT name FROM fsdir WHERE dir = '.' AND name = '.'
  } {test.db .}









  proc list_root_files {} {
    if {$::tcl_platform(platform) eq "windows"} {
      set res [list]

      foreach name [glob -directory $::env(fstreeDrive)/ -- *] {
        if {[string index [file tail $name] 0] eq "."} continue


        lappend res $name
      }
      return $res
    } else {
      return [string map {/ {}} [glob /*]]
    }
  }

  proc list_files { pattern } {
    if {$::tcl_platform(platform) eq "windows"} {
      set res [list]

      foreach name [glob -nocomplain $pattern] {
        if {[string index [file tail $name] 0] eq "."} continue


        lappend res $name
      }
      return $res
    } else {
      return [glob -nocomplain $pattern]
    }
  }

  # Read the first 5 entries from the root directory.  Except, ignore
  # files that contain the "$" character in their names as these are
  # special files on some Windows platforms.
  #
  set res [list]
  set root_files [list_root_files]
  set num_root_files [llength $root_files]
  set lim_root_files [expr {$num_root_files > 5 ? 5 : $num_root_files}]
  foreach p [lrange $root_files 0 [expr {$lim_root_files - 1}]] {
    if {$::tcl_platform(platform) eq "windows"} {
      if {[regexp {\$} $p]} {incr lim_root_files -1} else {lappend res $p}
    } else {
      lappend res "/$p"
    }
  }

  do_execsql_test 3.1 [subst {

    SELECT path FROM fstree WHERE path NOT GLOB '*\$*' LIMIT $lim_root_files;
  }] $res


  # Read all entries in the current directory.
  #
  proc contents {pattern} {
    set res [list]
    foreach f [list_files $pattern] {
      lappend res $f
      if {[file isdir $f]} {
        set res [concat $res [contents "$f/*"]]
      }
    }
    set res
  }
  set pwd "[pwd]/*"
  set res [contents $pwd]
  do_execsql_test 3.2 {
    SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1
  } [lsort $res]

  # Add some sub-directories and files to the current directory.
  #
  do_test 3.3 {
    catch { file delete -force subdir }
    foreach {path sz} {
      subdir/x1.txt     143







>
>
>
>
>
>
>
>



|
>
|

>
>


|

|





|
>
|

>
>


|

|









|
<
<

|




>
|
>
|
|
>

















|







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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170


171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
    [regexp -nocase -- {^[A-Z]:} $drive]} {
  reset_db
  register_fs_module db
  do_execsql_test 3.0 {
    SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db';
    SELECT name FROM fsdir WHERE dir = '.' AND name = '.'
  } {test.db .}

  proc sort_files { names {nocase false} } {
    if {$nocase && $::tcl_platform(platform) eq "windows"} {
      return [lsort -dictionary -nocase $names]
    } else {
      return [lsort $names]
    }
  }

  proc list_root_files {} {
    if {$::tcl_platform(platform) eq "windows"} {
      set res [list]; set dir $::env(fstreeDrive)/; set names [list]
      eval lappend names [glob -nocomplain -directory $dir -- *]
      foreach name $names {
        if {[string index [file tail $name] 0] eq "."} continue
        if {[file attributes $name -hidden]} continue
        if {[file attributes $name -system]} continue
        lappend res $name
      }
      return [sort_files $res true]
    } else {
      return [sort_files [string map {/ {}} [glob -nocomplain -- /*]]]
    }
  }

  proc list_files { pattern } {
    if {$::tcl_platform(platform) eq "windows"} {
      set res [list]; set names [list]
      eval lappend names [glob -nocomplain -- $pattern]
      foreach name $names {
        if {[string index [file tail $name] 0] eq "."} continue
        if {[file attributes $name -hidden]} continue
        if {[file attributes $name -system]} continue
        lappend res $name
      }
      return [sort_files $res]
    } else {
      return [sort_files [glob -nocomplain -- $pattern]]
    }
  }

  # Read the first 5 entries from the root directory.  Except, ignore
  # files that contain the "$" character in their names as these are
  # special files on some Windows platforms.
  #
  set res [list]
  set root_files [list_root_files]
  foreach p $root_files {


    if {$::tcl_platform(platform) eq "windows"} {
      if {![regexp {\$} $p]} {lappend res $p}
    } else {
      lappend res "/$p"
    }
  }
  set num_root_files [llength $root_files]
  do_test 3.1 {
    sort_files [execsql {
      SELECT path FROM fstree WHERE path NOT GLOB '*\$*' LIMIT $num_root_files;
    }] true
  } [sort_files $res true]

  # Read all entries in the current directory.
  #
  proc contents {pattern} {
    set res [list]
    foreach f [list_files $pattern] {
      lappend res $f
      if {[file isdir $f]} {
        set res [concat $res [contents "$f/*"]]
      }
    }
    set res
  }
  set pwd "[pwd]/*"
  set res [contents $pwd]
  do_execsql_test 3.2 {
    SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1
  } [sort_files $res]

  # Add some sub-directories and files to the current directory.
  #
  do_test 3.3 {
    catch { file delete -force subdir }
    foreach {path sz} {
      subdir/x1.txt     143