| OLD | NEW |
| 1 # 2015 Nov 24 | 1 # 2015 Nov 24 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 set x1 aback | 61 set x1 aback |
| 62 set x2 abaft | 62 set x2 abaft |
| 63 set x3 abandon | 63 set x3 abandon |
| 64 set x4 abandonint | 64 set x4 abandonint |
| 65 set x5 babble | 65 set x5 babble |
| 66 set x6 baboon | 66 set x6 baboon |
| 67 set x7 backbone | 67 set x7 backbone |
| 68 set x8 backarrow | 68 set x8 backarrow |
| 69 set x9 castle | 69 set x9 castle |
| 70 | 70 |
| 71 db func glob gfunc | 71 db func glob -argcount 2 gfunc |
| 72 proc gfunc {a b} { | 72 proc gfunc {a b} { |
| 73 incr ::gfunc | 73 incr ::gfunc |
| 74 return 1 | 74 return 1 |
| 75 } | 75 } |
| 76 | 76 |
| 77 db func like lfunc | 77 db func like -argcount 2 lfunc |
| 78 proc lfunc {a b} { | 78 proc lfunc {a b} { |
| 79 incr ::gfunc 100 | 79 incr ::gfunc 100 |
| 80 return 1 | 80 return 1 |
| 81 } | 81 } |
| 82 | 82 |
| 83 db func regexp rfunc | 83 db func regexp -argcount 2 rfunc |
| 84 proc rfunc {a b} { | 84 proc rfunc {a b} { |
| 85 incr ::gfunc 10000 | 85 incr ::gfunc 10000 |
| 86 return 1 | 86 return 1 |
| 87 } | 87 } |
| 88 | 88 |
| 89 foreach ::tclvar_set_omit {0 1} { | 89 foreach ::tclvar_set_omit {0 1} { |
| 90 foreach {tn expr res cnt} { | 90 foreach {tn expr res cnt} { |
| 91 1 {value GLOB 'aban*'} {x3 abandon x4 abandonint} 2 | 91 1 {value GLOB 'aban*'} {x3 abandon x4 abandonint} 2 |
| 92 2 {value LIKE '%ac%'} {x1 aback x7 backbone x8 backarrow} 300 | 92 2 {value LIKE '%ac%'} {x1 aback x7 backbone x8 backarrow} 300 |
| 93 3 {value REGEXP '^......$'} {x5 babble x6 baboon x9 castle} 30000 | 93 3 {value REGEXP '^......$'} {x5 babble x6 baboon x9 castle} 30000 |
| 94 } { | 94 } { |
| 95 db cache flush | 95 db cache flush |
| 96 set ::gfunc 0 | 96 set ::gfunc 0 |
| 97 if {$::tclvar_set_omit} {set cnt 0} | 97 if {$::tclvar_set_omit} {set cnt 0} |
| 98 | 98 |
| 99 do_test 2.$tclvar_set_omit.$tn.1 { | 99 do_test 2.$tclvar_set_omit.$tn.1 { |
| 100 execsql "SELECT name, value FROM vars WHERE name MATCH 'x*' AND $expr" | 100 execsql "SELECT name, value FROM vars WHERE name MATCH 'x*' AND $expr" |
| 101 } $res | 101 } $res |
| 102 | 102 |
| 103 do_test 2.$tclvar_set_omit.$tn.2 { | 103 do_test 2.$tclvar_set_omit.$tn.2 { |
| 104 set ::gfunc | 104 set ::gfunc |
| 105 } $cnt | 105 } $cnt |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 #------------------------------------------------------------------------- | 109 #------------------------------------------------------------------------- |
| 110 # | 110 # |
| 111 if {1} { | 111 if {$tcl_platform(platform)=="windows"} { |
| 112 set drive [string range [pwd] 0 1] |
| 113 set ::env(fstreeDrive) $drive |
| 114 } |
| 115 if {$tcl_platform(platform)!="windows" || \ |
| 116 [regexp -nocase -- {^[A-Z]:} $drive]} { |
| 112 reset_db | 117 reset_db |
| 113 register_fs_module db | 118 register_fs_module db |
| 114 do_execsql_test 3.0 { | 119 do_execsql_test 3.0 { |
| 115 SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db'; | 120 SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db'; |
| 116 SELECT name FROM fsdir WHERE dir = '.' AND name = '.' | 121 SELECT name FROM fsdir WHERE dir = '.' AND name = '.' |
| 117 } {test.db .} | 122 } {test.db .} |
| 118 | 123 |
| 124 proc sort_files { names {nocase false} } { |
| 125 if {$nocase && $::tcl_platform(platform) eq "windows"} { |
| 126 return [lsort -nocase $names] |
| 127 } else { |
| 128 return [lsort $names] |
| 129 } |
| 130 } |
| 131 |
| 119 proc list_root_files {} { | 132 proc list_root_files {} { |
| 120 if {$::tcl_platform(platform) eq "windows"} { | 133 if {$::tcl_platform(platform) eq "windows"} { |
| 121 set res [list] | 134 set res [list]; set dir $::env(fstreeDrive)/; set names [list] |
| 122 foreach name [glob -directory $::env(SystemDrive)/ -- *] { | 135 eval lappend names [glob -nocomplain -directory $dir -- *] |
| 136 foreach name $names { |
| 123 if {[string index [file tail $name] 0] eq "."} continue | 137 if {[string index [file tail $name] 0] eq "."} continue |
| 138 if {[file attributes $name -hidden]} continue |
| 139 if {[file attributes $name -system]} continue |
| 124 lappend res $name | 140 lappend res $name |
| 125 } | 141 } |
| 126 return $res | 142 return [sort_files $res true] |
| 127 } else { | 143 } else { |
| 128 return [string map {/ {}} [glob /*]] | 144 return [sort_files [string map {/ {}} [glob -nocomplain -- /*]]] |
| 129 } | 145 } |
| 130 } | 146 } |
| 131 | 147 |
| 132 proc list_files { pattern } { | 148 proc list_files { pattern } { |
| 133 if {$::tcl_platform(platform) eq "windows"} { | 149 if {$::tcl_platform(platform) eq "windows"} { |
| 134 set res [list] | 150 set res [list]; set names [list] |
| 135 foreach name [glob -nocomplain $pattern] { | 151 eval lappend names [glob -nocomplain -- $pattern] |
| 152 foreach name $names { |
| 136 if {[string index [file tail $name] 0] eq "."} continue | 153 if {[string index [file tail $name] 0] eq "."} continue |
| 154 if {[file attributes $name -hidden]} continue |
| 155 if {[file attributes $name -system]} continue |
| 137 lappend res $name | 156 lappend res $name |
| 138 } | 157 } |
| 139 return $res | 158 return [sort_files $res] |
| 140 } else { | 159 } else { |
| 141 return [glob -nocomplain $pattern] | 160 return [sort_files [glob -nocomplain -- $pattern]] |
| 142 } | 161 } |
| 143 } | 162 } |
| 144 | 163 |
| 164 # Read the first 5 entries from the root directory. Except, ignore |
| 165 # files that contain the "$" character in their names as these are |
| 166 # special files on some Windows platforms. |
| 167 # |
| 168 set res [list] |
| 169 set root_files [list_root_files] |
| 170 foreach p $root_files { |
| 171 if {$::tcl_platform(platform) eq "windows"} { |
| 172 if {![regexp {\$} $p]} {lappend res $p} |
| 173 } else { |
| 174 lappend res "/$p" |
| 175 } |
| 176 } |
| 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] |
| 183 |
| 145 # Read all entries in the current directory. | 184 # Read all entries in the current directory. |
| 146 # | 185 # |
| 147 proc contents {pattern} { | 186 proc contents {pattern} { |
| 148 set res [list] | 187 set res [list] |
| 149 foreach f [list_files $pattern] { | 188 foreach f [list_files $pattern] { |
| 150 lappend res $f | 189 lappend res $f |
| 151 if {[file isdir $f]} { | 190 if {[file isdir $f]} { |
| 152 set res [concat $res [contents "$f/*"]] | 191 set res [concat $res [contents "$f/*"]] |
| 153 } | 192 } |
| 154 } | 193 } |
| 155 set res | 194 set res |
| 156 } | 195 } |
| 157 set pwd "[pwd]/*" | 196 set pwd "[pwd]/*" |
| 158 set res [contents $pwd] | 197 set res [contents $pwd] |
| 159 do_execsql_test 3.2 { | 198 do_execsql_test 3.2 { |
| 160 SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1 | 199 SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1 |
| 161 } [lsort $res] | 200 } [sort_files $res] |
| 162 | 201 |
| 163 # Add some sub-directories and files to the current directory. | 202 # Add some sub-directories and files to the current directory. |
| 164 # | 203 # |
| 165 do_test 3.3 { | 204 do_test 3.3 { |
| 166 catch { file delete -force subdir } | 205 catch { file delete -force subdir } |
| 167 foreach {path sz} { | 206 foreach {path sz} { |
| 168 subdir/x1.txt 143 | 207 subdir/x1.txt 143 |
| 169 subdir/x2.txt 153 | 208 subdir/x2.txt 153 |
| 170 } { | 209 } { |
| 171 set dir [file dirname $path] | 210 set dir [file dirname $path] |
| (...skipping 21 matching lines...) Expand all Loading... |
| 193 SELECT sum(size) FROM fstree WHERE path LIKE $pwd || '/subdir/%' | 232 SELECT sum(size) FROM fstree WHERE path LIKE $pwd || '/subdir/%' |
| 194 } 296 | 233 } 296 |
| 195 do_execsql_test 3.8 { | 234 do_execsql_test 3.8 { |
| 196 SELECT size FROM fstree WHERE path = $pwd || '/subdir/x1.txt' | 235 SELECT size FROM fstree WHERE path = $pwd || '/subdir/x1.txt' |
| 197 } 143 | 236 } 143 |
| 198 | 237 |
| 199 } | 238 } |
| 200 | 239 |
| 201 | 240 |
| 202 finish_test | 241 finish_test |
| OLD | NEW |