| 1 |
# This file tests the filename manipulation routines. |
| 2 |
# |
| 3 |
# This file contains a collection of tests for one or more of the Tcl built-in |
| 4 |
# commands. Sourcing this file into Tcl runs the tests and generates output |
| 5 |
# for errors. No output means no errors were found. |
| 6 |
# |
| 7 |
# Copyright (c) 1995-1996 Sun Microsystems, Inc. |
| 8 |
# Copyright (c) 1999 Scriptics Corporation. |
| 9 |
# |
| 10 |
# See the file "license.terms" for information on usage and redistribution of |
| 11 |
# this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 12 |
|
| 13 |
if {"::tcltest" ni [namespace children]} { |
| 14 |
package require tcltest 2.5 |
| 15 |
namespace import -force ::tcltest::* |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
::tcltest::loadTestedCommands |
| 20 |
catch [list package require -exact Tcltest [info patchlevel]] |
| 21 |
|
| 22 |
testConstraint testsetplatform [llength [info commands testsetplatform]] |
| 23 |
testConstraint testtranslatefilename [llength [info commands testtranslatefilename]] |
| 24 |
testConstraint linkDirectory 1 |
| 25 |
testConstraint symbolicLinkFile 1 |
| 26 |
if {[testConstraint win]} { |
| 27 |
if {$::tcl_platform(osVersion) < 5.0 \ |
| 28 |
|| [lindex [file system [temporaryDirectory]] 1] ne "NTFS"} { |
| 29 |
testConstraint linkDirectory 0 |
| 30 |
} |
| 31 |
testConstraint symbolicLinkFile 0 |
| 32 |
testConstraint sharedCdrive [expr {![catch {cd //[info hostname]/c}]}] |
| 33 |
} |
| 34 |
# This match compares the first two words of the result. If the wanted result |
| 35 |
# is "equal", then this is successful if the words are equal. If the wanted |
| 36 |
# result is "not equal", then this is successful if the words are different. |
| 37 |
customMatch compareWords {apply {{a b} { |
| 38 |
lassign $b w1 w2 |
| 39 |
expr {$a eq "equal" ? $w1 eq $w2 : $w1 ne $w2} |
| 40 |
}}} |
| 41 |
|
| 42 |
proc touch filename {catch {close [open $filename w]}} |
| 43 |
global env |
| 44 |
if {[testConstraint testsetplatform]} { |
| 45 |
set platform [testgetplatform] |
| 46 |
} |
| 47 |
|
| 48 |
# Caution: when using 'testsetplatform' to test different file name platform |
| 49 |
# descriptions in this file, one must be very careful not to combine such |
| 50 |
# platform manipulation with commands like 'cd', 'pwd'. That is because the |
| 51 |
# latter commands operate on the real filesystem but will potentially have |
| 52 |
# their logic routed through the wrong generic code paths if we've used |
| 53 |
# 'testsetplatform'. This can lead to serious problems, even crashes. |
| 54 |
test filename-1.1 {Tcl_GetPathType: unix} {testsetplatform} { |
| 55 |
testsetplatform unix |
| 56 |
file pathtype / |
| 57 |
} absolute |
| 58 |
test filename-1.2 {Tcl_GetPathType: unix} {testsetplatform} { |
| 59 |
testsetplatform unix |
| 60 |
file pathtype /foo |
| 61 |
} absolute |
| 62 |
test filename-1.3 {Tcl_GetPathType: unix} {testsetplatform} { |
| 63 |
testsetplatform unix |
| 64 |
file pathtype foo |
| 65 |
} relative |
| 66 |
test filename-1.4 {Tcl_GetPathType: unix} {testsetplatform} { |
| 67 |
testsetplatform unix |
| 68 |
file pathtype c:/foo |
| 69 |
} relative |
| 70 |
test filename-1.5 {Tcl_GetPathType: unix} {testsetplatform} { |
| 71 |
testsetplatform unix |
| 72 |
file pathtype ~ |
| 73 |
} absolute |
| 74 |
test filename-1.6 {Tcl_GetPathType: unix} {testsetplatform} { |
| 75 |
testsetplatform unix |
| 76 |
file pathtype ~/foo |
| 77 |
} absolute |
| 78 |
test filename-1.7 {Tcl_GetPathType: unix} {testsetplatform} { |
| 79 |
testsetplatform unix |
| 80 |
file pathtype ~foo |
| 81 |
} absolute |
| 82 |
test filename-1.8 {Tcl_GetPathType: unix} {testsetplatform} { |
| 83 |
testsetplatform unix |
| 84 |
file pathtype ./~foo |
| 85 |
} relative |
| 86 |
|
| 87 |
test filename-3.1 {Tcl_GetPathType: windows} {testsetplatform} { |
| 88 |
testsetplatform windows |
| 89 |
file pathtype / |
| 90 |
} volumerelative |
| 91 |
test filename-3.2 {Tcl_GetPathType: windows} {testsetplatform} { |
| 92 |
testsetplatform windows |
| 93 |
file pathtype \\ |
| 94 |
} volumerelative |
| 95 |
test filename-3.3 {Tcl_GetPathType: windows} {testsetplatform} { |
| 96 |
testsetplatform windows |
| 97 |
file pathtype /foo |
| 98 |
} volumerelative |
| 99 |
test filename-3.4 {Tcl_GetPathType: windows} {testsetplatform} { |
| 100 |
testsetplatform windows |
| 101 |
file pathtype \\foo |
| 102 |
} volumerelative |
| 103 |
test filename-3.5 {Tcl_GetPathType: windows} {testsetplatform} { |
| 104 |
testsetplatform windows |
| 105 |
file pathtype c:/ |
| 106 |
} absolute |
| 107 |
test filename-3.6 {Tcl_GetPathType: windows} {testsetplatform} { |
| 108 |
testsetplatform windows |
| 109 |
file pathtype c:\\ |
| 110 |
} absolute |
| 111 |
test filename-3.7 {Tcl_GetPathType: windows} {testsetplatform} { |
| 112 |
testsetplatform windows |
| 113 |
file pathtype c:/foo |
| 114 |
} absolute |
| 115 |
test filename-3.8 {Tcl_GetPathType: windows} {testsetplatform} { |
| 116 |
testsetplatform windows |
| 117 |
file pathtype c:\\foo |
| 118 |
} absolute |
| 119 |
test filename-3.9 {Tcl_GetPathType: windows} {testsetplatform} { |
| 120 |
testsetplatform windows |
| 121 |
file pathtype c: |
| 122 |
} volumerelative |
| 123 |
test filename-3.10 {Tcl_GetPathType: windows} {testsetplatform} { |
| 124 |
testsetplatform windows |
| 125 |
file pathtype c:foo |
| 126 |
} volumerelative |
| 127 |
test filename-3.11 {Tcl_GetPathType: windows} {testsetplatform} { |
| 128 |
testsetplatform windows |
| 129 |
file pathtype foo |
| 130 |
} relative |
| 131 |
test filename-3.12 {Tcl_GetPathType: windows} {testsetplatform} { |
| 132 |
testsetplatform windows |
| 133 |
file pathtype //foo/bar |
| 134 |
} absolute |
| 135 |
test filename-3.13 {Tcl_GetPathType: windows} {testsetplatform} { |
| 136 |
testsetplatform windows |
| 137 |
file pathtype ~foo |
| 138 |
} absolute |
| 139 |
test filename-3.14 {Tcl_GetPathType: windows} {testsetplatform} { |
| 140 |
testsetplatform windows |
| 141 |
file pathtype ~ |
| 142 |
} absolute |
| 143 |
test filename-3.15 {Tcl_GetPathType: windows} {testsetplatform} { |
| 144 |
testsetplatform windows |
| 145 |
file pathtype ~/foo |
| 146 |
} absolute |
| 147 |
test filename-3.16 {Tcl_GetPathType: windows} {testsetplatform} { |
| 148 |
testsetplatform windows |
| 149 |
file pathtype ./~foo |
| 150 |
} relative |
| 151 |
|
| 152 |
test filename-4.1 {Tcl_SplitPath: unix} {testsetplatform} { |
| 153 |
testsetplatform unix |
| 154 |
file split / |
| 155 |
} {/} |
| 156 |
test filename-4.2 {Tcl_SplitPath: unix} {testsetplatform} { |
| 157 |
testsetplatform unix |
| 158 |
file split /foo |
| 159 |
} {/ foo} |
| 160 |
test filename-4.3 {Tcl_SplitPath: unix} {testsetplatform} { |
| 161 |
testsetplatform unix |
| 162 |
file split /foo/bar |
| 163 |
} {/ foo bar} |
| 164 |
test filename-4.4 {Tcl_SplitPath: unix} {testsetplatform} { |
| 165 |
testsetplatform unix |
| 166 |
file split /foo/bar/baz |
| 167 |
} {/ foo bar baz} |
| 168 |
test filename-4.5 {Tcl_SplitPath: unix} {testsetplatform} { |
| 169 |
testsetplatform unix |
| 170 |
file split foo/bar |
| 171 |
} {foo bar} |
| 172 |
test filename-4.6 {Tcl_SplitPath: unix} {testsetplatform} { |
| 173 |
testsetplatform unix |
| 174 |
file split ./foo/bar |
| 175 |
} {. foo bar} |
| 176 |
test filename-4.7 {Tcl_SplitPath: unix} {testsetplatform} { |
| 177 |
testsetplatform unix |
| 178 |
file split /foo/../././foo/bar |
| 179 |
} {/ foo .. . . foo bar} |
| 180 |
test filename-4.8 {Tcl_SplitPath: unix} {testsetplatform} { |
| 181 |
testsetplatform unix |
| 182 |
file split ../foo/bar |
| 183 |
} {.. foo bar} |
| 184 |
test filename-4.9 {Tcl_SplitPath: unix} {testsetplatform} { |
| 185 |
testsetplatform unix |
| 186 |
file split {} |
| 187 |
} {} |
| 188 |
test filename-4.10 {Tcl_SplitPath: unix} {testsetplatform} { |
| 189 |
testsetplatform unix |
| 190 |
file split . |
| 191 |
} {.} |
| 192 |
test filename-4.11 {Tcl_SplitPath: unix} {testsetplatform} { |
| 193 |
testsetplatform unix |
| 194 |
file split ../ |
| 195 |
} {..} |
| 196 |
test filename-4.12 {Tcl_SplitPath: unix} {testsetplatform} { |
| 197 |
testsetplatform unix |
| 198 |
file split ../.. |
| 199 |
} {.. ..} |
| 200 |
test filename-4.13 {Tcl_SplitPath: unix} {testsetplatform} { |
| 201 |
testsetplatform unix |
| 202 |
file split //foo |
| 203 |
} "/ foo" |
| 204 |
test filename-4.14 {Tcl_SplitPath: unix} {testsetplatform} { |
| 205 |
testsetplatform unix |
| 206 |
file split foo//bar |
| 207 |
} {foo bar} |
| 208 |
test filename-4.15 {Tcl_SplitPath: unix} {testsetplatform} { |
| 209 |
testsetplatform unix |
| 210 |
file split ~foo |
| 211 |
} {~foo} |
| 212 |
test filename-4.16 {Tcl_SplitPath: unix} {testsetplatform} { |
| 213 |
testsetplatform unix |
| 214 |
file split ~foo/~bar |
| 215 |
} {~foo ./~bar} |
| 216 |
test filename-4.17 {Tcl_SplitPath: unix} {testsetplatform} { |
| 217 |
testsetplatform unix |
| 218 |
file split ~foo/~bar/~baz |
| 219 |
} {~foo ./~bar ./~baz} |
| 220 |
test filename-4.18 {Tcl_SplitPath: unix} {testsetplatform} { |
| 221 |
testsetplatform unix |
| 222 |
file split foo/bar~/baz |
| 223 |
} {foo bar~ baz} |
| 224 |
if {[testConstraint testsetplatform]} { |
| 225 |
testsetplatform $platform |
| 226 |
} |
| 227 |
test filename-4.19 {Tcl_SplitPath} -setup { |
| 228 |
set oldDir [pwd] |
| 229 |
cd [temporaryDirectory] |
| 230 |
} -body { |
| 231 |
file mkdir tildetmp |
| 232 |
set nastydir [file join tildetmp ./~tilde] |
| 233 |
file mkdir $nastydir |
| 234 |
set norm [file normalize $nastydir] |
| 235 |
cd tildetmp |
| 236 |
cd ./~tilde |
| 237 |
glob -nocomplain * |
| 238 |
set idx [string first tildetmp $norm] |
| 239 |
set norm [string range $norm $idx end] |
| 240 |
# fix path away so all platforms are the same |
| 241 |
regsub {(.*):$} $norm {\1} norm |
| 242 |
regsub -all ":" $norm "/" norm |
| 243 |
# make sure we can delete the directory we created |
| 244 |
cd $oldDir |
| 245 |
file delete -force $nastydir |
| 246 |
return $norm |
| 247 |
} -cleanup { |
| 248 |
cd $oldDir |
| 249 |
catch {file delete -force [file join [temporaryDirectory] tildetmp]} |
| 250 |
} -result {tildetmp/~tilde} |
| 251 |
|
| 252 |
test filename-6.1 {Tcl_SplitPath: win} {testsetplatform} { |
| 253 |
testsetplatform win |
| 254 |
file split / |
| 255 |
} {/} |
| 256 |
test filename-6.2 {Tcl_SplitPath: win} {testsetplatform} { |
| 257 |
testsetplatform win |
| 258 |
file split /foo |
| 259 |
} {/ foo} |
| 260 |
test filename-6.3 {Tcl_SplitPath: win} {testsetplatform} { |
| 261 |
testsetplatform win |
| 262 |
file split /foo/bar |
| 263 |
} {/ foo bar} |
| 264 |
test filename-6.4 {Tcl_SplitPath: win} {testsetplatform} { |
| 265 |
testsetplatform win |
| 266 |
file split /foo/bar/baz |
| 267 |
} {/ foo bar baz} |
| 268 |
test filename-6.5 {Tcl_SplitPath: win} {testsetplatform} { |
| 269 |
testsetplatform win |
| 270 |
file split foo/bar |
| 271 |
} {foo bar} |
| 272 |
test filename-6.6 {Tcl_SplitPath: win} {testsetplatform} { |
| 273 |
testsetplatform win |
| 274 |
file split ./foo/bar |
| 275 |
} {. foo bar} |
| 276 |
test filename-6.7 {Tcl_SplitPath: win} {testsetplatform} { |
| 277 |
testsetplatform win |
| 278 |
file split /foo/../././foo/bar |
| 279 |
} {/ foo .. . . foo bar} |
| 280 |
test filename-6.8 {Tcl_SplitPath: win} {testsetplatform} { |
| 281 |
testsetplatform win |
| 282 |
file split ../foo/bar |
| 283 |
} {.. foo bar} |
| 284 |
test filename-6.9 {Tcl_SplitPath: win} {testsetplatform} { |
| 285 |
testsetplatform win |
| 286 |
file split {} |
| 287 |
} {} |
| 288 |
test filename-6.10 {Tcl_SplitPath: win} {testsetplatform} { |
| 289 |
testsetplatform win |
| 290 |
file split . |
| 291 |
} {.} |
| 292 |
test filename-6.11 {Tcl_SplitPath: win} {testsetplatform} { |
| 293 |
testsetplatform win |
| 294 |
file split ../ |
| 295 |
} {..} |
| 296 |
test filename-6.12 {Tcl_SplitPath: win} {testsetplatform} { |
| 297 |
testsetplatform win |
| 298 |
file split ../.. |
| 299 |
} {.. ..} |
| 300 |
test filename-6.13 {Tcl_SplitPath: win} {testsetplatform} { |
| 301 |
testsetplatform win |
| 302 |
file split //foo |
| 303 |
} {/ foo} |
| 304 |
test filename-6.14 {Tcl_SplitPath: win} {testsetplatform} { |
| 305 |
testsetplatform win |
| 306 |
file split foo//bar |
| 307 |
} {foo bar} |
| 308 |
test filename-6.15 {Tcl_SplitPath: win} {testsetplatform} { |
| 309 |
testsetplatform win |
| 310 |
file split /\\/foo//bar |
| 311 |
} {//foo/bar} |
| 312 |
test filename-6.16 {Tcl_SplitPath: win} {testsetplatform} { |
| 313 |
testsetplatform win |
| 314 |
file split /\\/foo//bar |
| 315 |
} {//foo/bar} |
| 316 |
test filename-6.17 {Tcl_SplitPath: win} {testsetplatform} { |
| 317 |
testsetplatform win |
| 318 |
file split /\\/foo//bar |
| 319 |
} {//foo/bar} |
| 320 |
test filename-6.18 {Tcl_SplitPath: win} {testsetplatform} { |
| 321 |
testsetplatform win |
| 322 |
file split \\\\foo\\bar |
| 323 |
} {//foo/bar} |
| 324 |
test filename-6.19 {Tcl_SplitPath: win} {testsetplatform} { |
| 325 |
testsetplatform win |
| 326 |
file split \\\\foo\\bar/baz |
| 327 |
} {//foo/bar baz} |
| 328 |
test filename-6.20 {Tcl_SplitPath: win} {testsetplatform} { |
| 329 |
testsetplatform win |
| 330 |
file split c:/foo |
| 331 |
} {c:/ foo} |
| 332 |
test filename-6.21 {Tcl_SplitPath: win} {testsetplatform} { |
| 333 |
testsetplatform win |
| 334 |
file split c:foo |
| 335 |
} {c: foo} |
| 336 |
test filename-6.22 {Tcl_SplitPath: win} {testsetplatform} { |
| 337 |
testsetplatform win |
| 338 |
file split c: |
| 339 |
} {c:} |
| 340 |
test filename-6.23 {Tcl_SplitPath: win} {testsetplatform} { |
| 341 |
testsetplatform win |
| 342 |
file split c:\\ |
| 343 |
} {c:/} |
| 344 |
test filename-6.24 {Tcl_SplitPath: win} {testsetplatform} { |
| 345 |
testsetplatform win |
| 346 |
file split c:/ |
| 347 |
} {c:/} |
| 348 |
test filename-6.25 {Tcl_SplitPath: win} {testsetplatform} { |
| 349 |
testsetplatform win |
| 350 |
file split c:/./.. |
| 351 |
} {c:/ . ..} |
| 352 |
test filename-6.26 {Tcl_SplitPath: win} {testsetplatform} { |
| 353 |
testsetplatform win |
| 354 |
file split ~foo |
| 355 |
} {~foo} |
| 356 |
test filename-6.27 {Tcl_SplitPath: win} {testsetplatform} { |
| 357 |
testsetplatform win |
| 358 |
file split ~foo/~bar |
| 359 |
} {~foo ./~bar} |
| 360 |
test filename-6.28 {Tcl_SplitPath: win} {testsetplatform} { |
| 361 |
testsetplatform win |
| 362 |
file split ~foo/~bar/~baz |
| 363 |
} {~foo ./~bar ./~baz} |
| 364 |
test filename-6.29 {Tcl_SplitPath: win} {testsetplatform} { |
| 365 |
testsetplatform win |
| 366 |
file split foo/bar~/baz |
| 367 |
} {foo bar~ baz} |
| 368 |
test filename-6.30 {Tcl_SplitPath: win} {testsetplatform} { |
| 369 |
testsetplatform win |
| 370 |
file split c:~foo |
| 371 |
} {c: ./~foo} |
| 372 |
|
| 373 |
test filename-7.1 {Tcl_JoinPath: unix} {testsetplatform} { |
| 374 |
testsetplatform unix |
| 375 |
file join / a |
| 376 |
} {/a} |
| 377 |
test filename-7.2 {Tcl_JoinPath: unix} {testsetplatform} { |
| 378 |
testsetplatform unix |
| 379 |
file join a b |
| 380 |
} {a/b} |
| 381 |
test filename-7.3 {Tcl_JoinPath: unix} {testsetplatform} { |
| 382 |
testsetplatform unix |
| 383 |
file join /a c /b d |
| 384 |
} {/b/d} |
| 385 |
test filename-7.4 {Tcl_JoinPath: unix} {testsetplatform} { |
| 386 |
testsetplatform unix |
| 387 |
file join / |
| 388 |
} {/} |
| 389 |
test filename-7.5 {Tcl_JoinPath: unix} {testsetplatform} { |
| 390 |
testsetplatform unix |
| 391 |
file join a |
| 392 |
} {a} |
| 393 |
test filename-7.6 {Tcl_JoinPath: unix} {testsetplatform} { |
| 394 |
testsetplatform unix |
| 395 |
file join {} |
| 396 |
} {} |
| 397 |
test filename-7.7 {Tcl_JoinPath: unix} {testsetplatform} { |
| 398 |
testsetplatform unix |
| 399 |
file join /a/ b |
| 400 |
} {/a/b} |
| 401 |
test filename-7.8 {Tcl_JoinPath: unix} {testsetplatform} { |
| 402 |
testsetplatform unix |
| 403 |
file join /a// b |
| 404 |
} {/a/b} |
| 405 |
test filename-7.9 {Tcl_JoinPath: unix} {testsetplatform} { |
| 406 |
testsetplatform unix |
| 407 |
file join /a/./../. b |
| 408 |
} {/a/./.././b} |
| 409 |
test filename-7.10 {Tcl_JoinPath: unix} {testsetplatform} { |
| 410 |
testsetplatform unix |
| 411 |
file join ~ a |
| 412 |
} {~/a} |
| 413 |
test filename-7.11 {Tcl_JoinPath: unix} {testsetplatform} { |
| 414 |
testsetplatform unix |
| 415 |
file join ~a ~b |
| 416 |
} {~b} |
| 417 |
test filename-7.12 {Tcl_JoinPath: unix} {testsetplatform} { |
| 418 |
testsetplatform unix |
| 419 |
file join ./~a b |
| 420 |
} {./~a/b} |
| 421 |
test filename-7.13 {Tcl_JoinPath: unix} {testsetplatform} { |
| 422 |
testsetplatform unix |
| 423 |
file join ./~a ~b |
| 424 |
} {~b} |
| 425 |
test filename-7.14 {Tcl_JoinPath: unix} {testsetplatform} { |
| 426 |
testsetplatform unix |
| 427 |
file join ./~a ./~b |
| 428 |
} {./~a/~b} |
| 429 |
test filename-7.15 {Tcl_JoinPath: unix} {testsetplatform} { |
| 430 |
testsetplatform unix |
| 431 |
file join a . b |
| 432 |
} {a/./b} |
| 433 |
test filename-7.16 {Tcl_JoinPath: unix} {testsetplatform} { |
| 434 |
testsetplatform unix |
| 435 |
file join a . ./~b |
| 436 |
} {a/./~b} |
| 437 |
test filename-7.17 {Tcl_JoinPath: unix} {testsetplatform} { |
| 438 |
testsetplatform unix |
| 439 |
file join //a b |
| 440 |
} "/a/b" |
| 441 |
test filename-7.18 {Tcl_JoinPath: unix} {testsetplatform} { |
| 442 |
testsetplatform unix |
| 443 |
file join /// a b |
| 444 |
} "/a/b" |
| 445 |
test filename-7.19 {[Bug f34cf83dd0]} { |
| 446 |
file join foo //bar |
| 447 |
} /bar |
| 448 |
|
| 449 |
test filename-9.1 {Tcl_JoinPath: win} {testsetplatform} { |
| 450 |
testsetplatform win |
| 451 |
file join a b |
| 452 |
} {a/b} |
| 453 |
test filename-9.2 {Tcl_JoinPath: win} {testsetplatform} { |
| 454 |
testsetplatform win |
| 455 |
file join /a b |
| 456 |
} {/a/b} |
| 457 |
test filename-9.3 {Tcl_JoinPath: win} {testsetplatform} { |
| 458 |
testsetplatform win |
| 459 |
file join /a /b |
| 460 |
} {/b} |
| 461 |
test filename-9.4 {Tcl_JoinPath: win} {testsetplatform} { |
| 462 |
testsetplatform win |
| 463 |
file join c: foo |
| 464 |
} {c:foo} |
| 465 |
test filename-9.5 {Tcl_JoinPath: win} {testsetplatform} { |
| 466 |
testsetplatform win |
| 467 |
file join c:/ foo |
| 468 |
} {c:/foo} |
| 469 |
test filename-9.6 {Tcl_JoinPath: win} {testsetplatform} { |
| 470 |
testsetplatform win |
| 471 |
file join c:\\bar foo |
| 472 |
} {c:/bar/foo} |
| 473 |
test filename-9.7 {Tcl_JoinPath: win} {testsetplatform} { |
| 474 |
testsetplatform win |
| 475 |
file join /foo c:bar |
| 476 |
} {c:bar} |
| 477 |
test filename-9.8 {Tcl_JoinPath: win} {testsetplatform} { |
| 478 |
testsetplatform win |
| 479 |
file join ///host//share dir |
| 480 |
} {//host/share/dir} |
| 481 |
test filename-9.9 {Tcl_JoinPath: win} {testsetplatform} { |
| 482 |
testsetplatform win |
| 483 |
file join ~ foo |
| 484 |
} {~/foo} |
| 485 |
test filename-9.10 {Tcl_JoinPath: win} {testsetplatform} { |
| 486 |
testsetplatform win |
| 487 |
file join ~/~foo |
| 488 |
} {~/~foo} |
| 489 |
test filename-9.11 {Tcl_JoinPath: win} {testsetplatform} { |
| 490 |
testsetplatform win |
| 491 |
file join ~ ./~foo |
| 492 |
} {~/~foo} |
| 493 |
test filename-9.12 {Tcl_JoinPath: win} {testsetplatform} { |
| 494 |
testsetplatform win |
| 495 |
file join / ~foo |
| 496 |
} {~foo} |
| 497 |
test filename-9.13 {Tcl_JoinPath: win} {testsetplatform} { |
| 498 |
testsetplatform win |
| 499 |
file join ./a/ b c |
| 500 |
} {./a/b/c} |
| 501 |
test filename-9.14 {Tcl_JoinPath: win} {testsetplatform} { |
| 502 |
testsetplatform win |
| 503 |
file join ./~a/ b c |
| 504 |
} {./~a/b/c} |
| 505 |
test filename-9.15 {Tcl_JoinPath: win} {testsetplatform} { |
| 506 |
testsetplatform win |
| 507 |
file join // host share path |
| 508 |
} {/host/share/path} |
| 509 |
test filename-9.16 {Tcl_JoinPath: win} {testsetplatform} { |
| 510 |
testsetplatform win |
| 511 |
file join foo . bar |
| 512 |
} {foo/./bar} |
| 513 |
test filename-9.17 {Tcl_JoinPath: win} {testsetplatform} { |
| 514 |
testsetplatform win |
| 515 |
file join foo .. bar |
| 516 |
} {foo/../bar} |
| 517 |
test filename-9.18 {Tcl_JoinPath: win} {testsetplatform} { |
| 518 |
testsetplatform win |
| 519 |
file join foo/./bar |
| 520 |
} {foo/./bar} |
| 521 |
test filename-9.19 {Tcl_JoinPath: win} {testsetplatform} { |
| 522 |
testsetplatform win |
| 523 |
set res {} |
| 524 |
lappend res \ |
| 525 |
[file join {C:\foo\bar}] \ |
| 526 |
[file join C:/blah {C:\foo\bar}] \ |
| 527 |
[file join C:/blah C:/blah {C:\foo\bar}] |
| 528 |
} {C:/foo/bar C:/foo/bar C:/foo/bar} |
| 529 |
test filename-9.19.1 {Tcl_JoinPath: win} {testsetplatform} { |
| 530 |
testsetplatform win |
| 531 |
set res {} |
| 532 |
lappend res \ |
| 533 |
[file join {foo\bar}] \ |
| 534 |
[file join C:/blah {foo\bar}] \ |
| 535 |
[file join C:/blah C:/blah {foo\bar}] |
| 536 |
} {foo/bar C:/blah/foo/bar C:/blah/foo/bar} |
| 537 |
test filename-9.19.2 {Tcl_JoinPath: win} {testsetplatform win} { |
| 538 |
testsetplatform win |
| 539 |
set res {} |
| 540 |
lappend res \ |
| 541 |
[file join {foo\bar}] \ |
| 542 |
[file join [pwd] {foo\bar}] \ |
| 543 |
[file join [pwd] [pwd] {foo\bar}] |
| 544 |
set nres {} |
| 545 |
foreach elt $res { |
| 546 |
lappend nres [string map [list [pwd] pwd] $elt] |
| 547 |
} |
| 548 |
set nres |
| 549 |
} {foo/bar pwd/foo/bar pwd/foo/bar} |
| 550 |
test filename-9.20 {Tcl_JoinPath: unix} {testsetplatform} { |
| 551 |
testsetplatform unix |
| 552 |
set res {} |
| 553 |
lappend res \ |
| 554 |
[file join {/foo/bar}] \ |
| 555 |
[file join /x {/foo/bar}] \ |
| 556 |
[file join /x /x {/foo/bar}] |
| 557 |
} {/foo/bar /foo/bar /foo/bar} |
| 558 |
test filename-9.23 {Tcl_JoinPath: win} {testsetplatform} { |
| 559 |
testsetplatform win |
| 560 |
set res {} |
| 561 |
lappend res \ |
| 562 |
[file join {foo\bar}] \ |
| 563 |
[file join C:/blah {foo\bar}] \ |
| 564 |
[file join C:/blah C:/blah {foo\bar}] |
| 565 |
string map [list C:/blah ""] $res |
| 566 |
} {foo/bar /foo/bar /foo/bar} |
| 567 |
test filename-9.24 {Tcl_JoinPath: unix} {testsetplatform} { |
| 568 |
testsetplatform unix |
| 569 |
set res {} |
| 570 |
lappend res \ |
| 571 |
[file join {foo/bar}] \ |
| 572 |
[file join /x {foo/bar}] \ |
| 573 |
[file join /x /x {foo/bar}] |
| 574 |
string map [list /x ""] $res |
| 575 |
} {foo/bar /foo/bar /foo/bar} |
| 576 |
|
| 577 |
test filename-10.1 {Tcl_TranslateFileName} -body { |
| 578 |
testsetplatform unix |
| 579 |
testtranslatefilename foo |
| 580 |
} -result {foo} -constraints {testsetplatform testtranslatefilename} |
| 581 |
test filename-10.2 {Tcl_TranslateFileName} -body { |
| 582 |
testsetplatform windows |
| 583 |
testtranslatefilename {c:/foo} |
| 584 |
} -result {c:\foo} -constraints {testsetplatform testtranslatefilename} |
| 585 |
test filename-10.3 {Tcl_TranslateFileName} -body { |
| 586 |
testsetplatform windows |
| 587 |
testtranslatefilename {c:/\\foo/} |
| 588 |
} -result {c:\foo} -constraints {testsetplatform testtranslatefilename} |
| 589 |
test filename-10.3.1 {Tcl_TranslateFileName} -body { |
| 590 |
testsetplatform windows |
| 591 |
testtranslatefilename {c://///} |
| 592 |
} -result c:\\ -constraints {testsetplatform testtranslatefilename} |
| 593 |
test filename-10.6 {Tcl_TranslateFileName} -setup { |
| 594 |
global env |
| 595 |
set temp $env(HOME) |
| 596 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 597 |
set env(HOME) "/home/test" |
| 598 |
testsetplatform unix |
| 599 |
testtranslatefilename ~/foo |
| 600 |
} -cleanup { |
| 601 |
set env(HOME) $temp |
| 602 |
} -result {/home/test/foo} |
| 603 |
test filename-10.7 {Tcl_TranslateFileName} -setup { |
| 604 |
global env |
| 605 |
set temp $env(HOME) |
| 606 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 607 |
unset env(HOME) |
| 608 |
testsetplatform unix |
| 609 |
testtranslatefilename ~/foo |
| 610 |
} -returnCodes error -cleanup { |
| 611 |
set env(HOME) $temp |
| 612 |
} -result {couldn't find HOME environment variable to expand path} |
| 613 |
test filename-10.8 {Tcl_TranslateFileName} -setup { |
| 614 |
global env |
| 615 |
set temp $env(HOME) |
| 616 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 617 |
set env(HOME) "/home/test" |
| 618 |
testsetplatform unix |
| 619 |
testtranslatefilename ~ |
| 620 |
} -cleanup { |
| 621 |
set env(HOME) $temp |
| 622 |
} -result {/home/test} |
| 623 |
test filename-10.9 {Tcl_TranslateFileName} -setup { |
| 624 |
global env |
| 625 |
set temp $env(HOME) |
| 626 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 627 |
set env(HOME) "/home/test/" |
| 628 |
testsetplatform unix |
| 629 |
testtranslatefilename ~ |
| 630 |
} -cleanup { |
| 631 |
set env(HOME) $temp |
| 632 |
} -result {/home/test} |
| 633 |
test filename-10.10 {Tcl_TranslateFileName} -setup { |
| 634 |
global env |
| 635 |
set temp $env(HOME) |
| 636 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 637 |
set env(HOME) "/home/test/" |
| 638 |
testsetplatform unix |
| 639 |
testtranslatefilename ~/foo |
| 640 |
} -cleanup { |
| 641 |
set env(HOME) $temp |
| 642 |
} -result {/home/test/foo} |
| 643 |
test filename-10.17 {Tcl_TranslateFileName} -setup { |
| 644 |
global env |
| 645 |
set temp $env(HOME) |
| 646 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 647 |
set env(HOME) "\\home\\" |
| 648 |
testsetplatform windows |
| 649 |
testtranslatefilename ~/foo |
| 650 |
} -cleanup { |
| 651 |
set env(HOME) $temp |
| 652 |
} -result {\home\foo} |
| 653 |
test filename-10.18 {Tcl_TranslateFileName} -setup { |
| 654 |
global env |
| 655 |
set temp $env(HOME) |
| 656 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 657 |
set env(HOME) "\\home\\" |
| 658 |
testsetplatform windows |
| 659 |
testtranslatefilename ~/foo\\bar |
| 660 |
} -cleanup { |
| 661 |
set env(HOME) $temp |
| 662 |
} -result {\home\foo\bar} |
| 663 |
test filename-10.19 {Tcl_TranslateFileName} -setup { |
| 664 |
global env |
| 665 |
set temp $env(HOME) |
| 666 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 667 |
set env(HOME) "c:" |
| 668 |
testsetplatform windows |
| 669 |
testtranslatefilename ~/foo |
| 670 |
} -cleanup { |
| 671 |
set env(HOME) $temp |
| 672 |
} -result {c:foo} |
| 673 |
test filename-10.20 {Tcl_TranslateFileName} -returnCodes error -body { |
| 674 |
testtranslatefilename ~blorp/foo |
| 675 |
} -constraints {testtranslatefilename testtranslatefilename} \ |
| 676 |
-result {user "blorp" doesn't exist} |
| 677 |
test filename-10.21 {Tcl_TranslateFileName} -setup { |
| 678 |
global env |
| 679 |
set temp $env(HOME) |
| 680 |
} -constraints {testsetplatform testtranslatefilename} -body { |
| 681 |
set env(HOME) "c:\\" |
| 682 |
testsetplatform windows |
| 683 |
testtranslatefilename ~/foo |
| 684 |
} -cleanup { |
| 685 |
set env(HOME) $temp |
| 686 |
} -result {c:\foo} |
| 687 |
test filename-10.22 {Tcl_TranslateFileName} -body { |
| 688 |
testsetplatform windows |
| 689 |
testtranslatefilename foo//bar |
| 690 |
} -constraints {testsetplatform testtranslatefilename} -result {foo\bar} |
| 691 |
if {[testConstraint testsetplatform]} { |
| 692 |
testsetplatform $platform |
| 693 |
} |
| 694 |
test filename-10.23 {Tcl_TranslateFileName} -body { |
| 695 |
# this test fails if ~ouster is not /home/ouster |
| 696 |
testtranslatefilename ~ouster |
| 697 |
} -constraints {nonPortable testtranslatefilename} -result {/home/ouster} |
| 698 |
test filename-10.24 {Tcl_TranslateFileName} -body { |
| 699 |
# this test fails if ~ouster is not /home/ouster |
| 700 |
testtranslatefilename ~ouster/foo |
| 701 |
} -result {/home/ouster/foo} -constraints {nonPortable testtranslatefilename} |
| 702 |
|
| 703 |
test filename-11.1 {Tcl_GlobCmd} -returnCodes error -body { |
| 704 |
glob |
| 705 |
} -result {no files matched glob patterns ""} |
| 706 |
test filename-11.2 {Tcl_GlobCmd} -returnCodes error -body { |
| 707 |
glob -gorp |
| 708 |
} -result {bad option "-gorp": must be -directory, -join, -nocomplain, -path, -tails, -types, or --} |
| 709 |
test filename-11.3 {Tcl_GlobCmd} -body { |
| 710 |
glob -nocomplai |
| 711 |
} -result {} |
| 712 |
test filename-11.4 {Tcl_GlobCmd} -body { |
| 713 |
glob -nocomplain |
| 714 |
} -result {} |
| 715 |
test filename-11.5 {Tcl_GlobCmd} -returnCodes error -body { |
| 716 |
glob -nocomplain * ~xyqrszzz |
| 717 |
} -result {user "xyqrszzz" doesn't exist} |
| 718 |
test filename-11.6 {Tcl_GlobCmd} -returnCodes error -body { |
| 719 |
glob ~xyqrszzz |
| 720 |
} -result {user "xyqrszzz" doesn't exist} |
| 721 |
test filename-11.7 {Tcl_GlobCmd} -returnCodes error -body { |
| 722 |
glob -- -nocomplain |
| 723 |
} -result {no files matched glob pattern "-nocomplain"} |
| 724 |
test filename-11.8 {Tcl_GlobCmd} -body { |
| 725 |
glob -nocomplain -- -nocomplain |
| 726 |
} -result {} |
| 727 |
test filename-11.9 {Tcl_GlobCmd} -constraints {testsetplatform} -body { |
| 728 |
testsetplatform unix |
| 729 |
glob ~\\xyqrszzz/bar |
| 730 |
} -returnCodes error -result {user "\xyqrszzz" doesn't exist} |
| 731 |
test filename-11.10 {Tcl_GlobCmd} -constraints {testsetplatform} -body { |
| 732 |
testsetplatform unix |
| 733 |
glob -nocomplain ~\\xyqrszzz/bar |
| 734 |
} -returnCodes error -result {user "\xyqrszzz" doesn't exist} |
| 735 |
test filename-11.11 {Tcl_GlobCmd} -constraints {testsetplatform} -body { |
| 736 |
testsetplatform unix |
| 737 |
glob ~xyqrszzz\\/\\bar |
| 738 |
} -returnCodes error -result {user "xyqrszzz" doesn't exist} |
| 739 |
test filename-11.12 {Tcl_GlobCmd} -constraints {testsetplatform} -setup { |
| 740 |
testsetplatform unix |
| 741 |
set home $env(HOME) |
| 742 |
} -body { |
| 743 |
unset env(HOME) |
| 744 |
glob ~/* |
| 745 |
} -returnCodes error -cleanup { |
| 746 |
set env(HOME) $home |
| 747 |
} -result {couldn't find HOME environment variable to expand path} |
| 748 |
if {[testConstraint testsetplatform]} { |
| 749 |
testsetplatform $platform |
| 750 |
} |
| 751 |
test filename-11.13 {Tcl_GlobCmd} -body { |
| 752 |
file join [lindex [glob ~] 0] |
| 753 |
} -result [file join $env(HOME)] |
| 754 |
set oldpwd [pwd] |
| 755 |
set oldhome $env(HOME) |
| 756 |
catch {cd [makeDirectory tcl[pid]]} |
| 757 |
set env(HOME) [pwd] |
| 758 |
file delete -force globTest |
| 759 |
file mkdir globTest/a1/b1 |
| 760 |
file mkdir globTest/a1/b2 |
| 761 |
file mkdir globTest/a2/b3 |
| 762 |
file mkdir globTest/a3 |
| 763 |
touch globTest/x1.c |
| 764 |
touch globTest/y1.c |
| 765 |
touch globTest/z1.c |
| 766 |
touch "globTest/weird name.c" |
| 767 |
touch globTest/a1/b1/x2.c |
| 768 |
touch globTest/a1/b2/y2.c |
| 769 |
touch globTest/.1 |
| 770 |
touch globTest/x,z1.c |
| 771 |
test filename-11.14 {Tcl_GlobCmd} -body { |
| 772 |
glob ~/globTest |
| 773 |
} -result [list [file join $env(HOME) globTest]] |
| 774 |
test filename-11.15 {Tcl_GlobCmd} -body { |
| 775 |
glob ~\\/globTest |
| 776 |
} -result [list [file join $env(HOME) globTest]] |
| 777 |
test filename-11.16 {Tcl_GlobCmd} { |
| 778 |
glob globTest |
| 779 |
} {globTest} |
| 780 |
set globname "globTest" |
| 781 |
set horribleglobname "glob\[\{Test" |
| 782 |
set tildeglobname "./~test.txt" |
| 783 |
|
| 784 |
test filename-11.17 {Tcl_GlobCmd} {unix} { |
| 785 |
lsort [glob -directory $globname *] |
| 786 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 787 |
[file join $globname a3]\ |
| 788 |
[file join $globname "weird name.c"]\ |
| 789 |
[file join $globname x,z1.c]\ |
| 790 |
[file join $globname x1.c]\ |
| 791 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 792 |
test filename-11.17.1 {Tcl_GlobCmd} {win} { |
| 793 |
lsort [glob -directory $globname *] |
| 794 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 795 |
[file join $globname .1]\ |
| 796 |
[file join $globname a3]\ |
| 797 |
[file join $globname "weird name.c"]\ |
| 798 |
[file join $globname x,z1.c]\ |
| 799 |
[file join $globname x1.c]\ |
| 800 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 801 |
test filename-11.17.2 {Tcl_GlobCmd} -setup { |
| 802 |
set dir [pwd] |
| 803 |
} -constraints {notRoot linkDirectory} -body { |
| 804 |
cd $globname |
| 805 |
file link -symbolic link a1 |
| 806 |
cd $dir |
| 807 |
lsort [glob -directory $globname -join * b1] |
| 808 |
} -cleanup { |
| 809 |
cd $dir |
| 810 |
file delete [file join $globname link] |
| 811 |
} -result [list [file join $globname a1 b1] \ |
| 812 |
[file join $globname link b1]] |
| 813 |
# Simpler version of the above test to illustrate a given bug. |
| 814 |
test filename-11.17.3 {Tcl_GlobCmd} -setup { |
| 815 |
set dir [pwd] |
| 816 |
} -constraints {notRoot linkDirectory} -body { |
| 817 |
cd $globname |
| 818 |
file link -symbolic link a1 |
| 819 |
cd $dir |
| 820 |
lsort [glob -directory $globname -type d *] |
| 821 |
} -cleanup { |
| 822 |
cd $dir |
| 823 |
file delete [file join $globname link] |
| 824 |
} -result [list [file join $globname a1] \ |
| 825 |
[file join $globname a2] \ |
| 826 |
[file join $globname a3] \ |
| 827 |
[file join $globname link]] |
| 828 |
# Make sure the bugfix isn't too simple. We don't want to break 'glob -type l' |
| 829 |
test filename-11.17.4 {Tcl_GlobCmd} -setup { |
| 830 |
set dir [pwd] |
| 831 |
} -constraints {notRoot linkDirectory} -body { |
| 832 |
cd $globname |
| 833 |
file link -symbolic link a1 |
| 834 |
cd $dir |
| 835 |
lsort [glob -directory $globname -type l *] |
| 836 |
} -cleanup { |
| 837 |
cd $dir |
| 838 |
file delete [file join $globname link] |
| 839 |
} -result [list [file join $globname link]] |
| 840 |
test filename-11.17.5 {Tcl_GlobCmd} { |
| 841 |
lsort [glob -directory $globname -tails *.c] |
| 842 |
} [lsort [list "weird name.c" x,z1.c x1.c y1.c z1.c]] |
| 843 |
test filename-11.17.6 {Tcl_GlobCmd} { |
| 844 |
lsort [glob -directory $globname -tails *.c *.c] |
| 845 |
} [lsort [concat [list "weird name.c" x,z1.c x1.c y1.c z1.c] \ |
| 846 |
[list "weird name.c" x,z1.c x1.c y1.c z1.c]]] |
| 847 |
test filename-11.17.7 {Tcl_GlobCmd: broken link and glob -l} -setup { |
| 848 |
set dir [pwd] |
| 849 |
} -constraints {linkDirectory} -body { |
| 850 |
cd $globname |
| 851 |
file mkdir nonexistent |
| 852 |
file link -symbolic link nonexistent |
| 853 |
file delete nonexistent |
| 854 |
cd $dir |
| 855 |
lsort [glob -nocomplain -directory $globname -type l *] |
| 856 |
} -cleanup { |
| 857 |
cd $dir |
| 858 |
file delete [file join $globname link] |
| 859 |
} -result [list [file join $globname link]] |
| 860 |
test filename-11.17.8 {Tcl_GlobCmd: broken link and glob -l} -setup { |
| 861 |
set dir [pwd] |
| 862 |
} -constraints {symbolicLinkFile} -body { |
| 863 |
cd $globname |
| 864 |
touch "nonexistent" |
| 865 |
file link -symbolic link nonexistent |
| 866 |
file delete nonexistent |
| 867 |
cd $dir |
| 868 |
lsort [glob -nocomplain -directory $globname -type l *] |
| 869 |
} -cleanup { |
| 870 |
cd $dir |
| 871 |
file delete [file join $globname link] |
| 872 |
} -result [list [file join $globname link]] |
| 873 |
test filename-11.18 {Tcl_GlobCmd} {unix} { |
| 874 |
lsort [glob -path $globname/ *] |
| 875 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 876 |
[file join $globname a3]\ |
| 877 |
[file join $globname "weird name.c"]\ |
| 878 |
[file join $globname x,z1.c]\ |
| 879 |
[file join $globname x1.c]\ |
| 880 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 881 |
test filename-11.18.1 {Tcl_GlobCmd} {win} { |
| 882 |
lsort [glob -path $globname/ *] |
| 883 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 884 |
[file join $globname .1]\ |
| 885 |
[file join $globname a3]\ |
| 886 |
[file join $globname "weird name.c"]\ |
| 887 |
[file join $globname x,z1.c]\ |
| 888 |
[file join $globname x1.c]\ |
| 889 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 890 |
test filename-11.19 {Tcl_GlobCmd} {unix} { |
| 891 |
lsort [glob -join -path [string range $globname 0 5] * *] |
| 892 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 893 |
[file join $globname a3]\ |
| 894 |
[file join $globname "weird name.c"]\ |
| 895 |
[file join $globname x,z1.c]\ |
| 896 |
[file join $globname x1.c]\ |
| 897 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 898 |
test filename-11.19.1 {Tcl_GlobCmd} {win} { |
| 899 |
lsort [glob -join -path [string range $globname 0 5] * *] |
| 900 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 901 |
[file join $globname .1]\ |
| 902 |
[file join $globname a3]\ |
| 903 |
[file join $globname "weird name.c"]\ |
| 904 |
[file join $globname x,z1.c]\ |
| 905 |
[file join $globname x1.c]\ |
| 906 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 907 |
test filename-11.20 {Tcl_GlobCmd} { |
| 908 |
lsort [glob -type d -dir $globname *] |
| 909 |
} [lsort [list [file join $globname a1]\ |
| 910 |
[file join $globname a2]\ |
| 911 |
[file join $globname a3]]] |
| 912 |
test filename-11.21 {Tcl_GlobCmd} { |
| 913 |
lsort [glob -type d -path $globname *] |
| 914 |
} [list $globname] |
| 915 |
test filename-11.21.1 {Tcl_GlobCmd} -body { |
| 916 |
touch {[tcl].testremains} |
| 917 |
lsort [glob -path {[tcl]} *] |
| 918 |
} -cleanup { |
| 919 |
file delete -force {[tcl].testremains} |
| 920 |
} -result {{[tcl].testremains}} |
| 921 |
# Get rid of file/dir if it exists, since it will have been left behind by a |
| 922 |
# previous failed run. |
| 923 |
file delete -force $horribleglobname |
| 924 |
file rename globTest $horribleglobname |
| 925 |
set globname $horribleglobname |
| 926 |
file delete -force $tildeglobname |
| 927 |
close [open $tildeglobname w] |
| 928 |
|
| 929 |
test filename-11.22 {Tcl_GlobCmd} {unix} { |
| 930 |
lsort [glob -dir $globname *] |
| 931 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 932 |
[file join $globname a3]\ |
| 933 |
[file join $globname "weird name.c"]\ |
| 934 |
[file join $globname x,z1.c]\ |
| 935 |
[file join $globname x1.c]\ |
| 936 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 937 |
test filename-11.22.1 {Tcl_GlobCmd} {win} { |
| 938 |
lsort [glob -dir $globname *] |
| 939 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 940 |
[file join $globname .1]\ |
| 941 |
[file join $globname a3]\ |
| 942 |
[file join $globname "weird name.c"]\ |
| 943 |
[file join $globname x,z1.c]\ |
| 944 |
[file join $globname x1.c]\ |
| 945 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 946 |
test filename-11.23 {Tcl_GlobCmd} {unix} { |
| 947 |
lsort [glob -path $globname/ *] |
| 948 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 949 |
[file join $globname a3]\ |
| 950 |
[file join $globname "weird name.c"]\ |
| 951 |
[file join $globname x,z1.c]\ |
| 952 |
[file join $globname x1.c]\ |
| 953 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 954 |
test filename-11.23.1 {Tcl_GlobCmd} {win} { |
| 955 |
lsort [glob -path $globname/ *] |
| 956 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 957 |
[file join $globname .1]\ |
| 958 |
[file join $globname a3]\ |
| 959 |
[file join $globname "weird name.c"]\ |
| 960 |
[file join $globname x,z1.c]\ |
| 961 |
[file join $globname x1.c]\ |
| 962 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 963 |
test filename-11.24 {Tcl_GlobCmd} {unix} { |
| 964 |
lsort [glob -join -path [string range $globname 0 5] * *] |
| 965 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 966 |
[file join $globname a3]\ |
| 967 |
[file join $globname "weird name.c"]\ |
| 968 |
[file join $globname x,z1.c]\ |
| 969 |
[file join $globname x1.c]\ |
| 970 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 971 |
test filename-11.24.1 {Tcl_GlobCmd} {win} { |
| 972 |
lsort [glob -join -path [string range $globname 0 5] * *] |
| 973 |
} [lsort [list [file join $globname a1] [file join $globname a2]\ |
| 974 |
[file join $globname .1]\ |
| 975 |
[file join $globname a3]\ |
| 976 |
[file join $globname "weird name.c"]\ |
| 977 |
[file join $globname x,z1.c]\ |
| 978 |
[file join $globname x1.c]\ |
| 979 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 980 |
test filename-11.25 {Tcl_GlobCmd} { |
| 981 |
lsort [glob -type d -dir $globname *] |
| 982 |
} [lsort [list [file join $globname a1]\ |
| 983 |
[file join $globname a2]\ |
| 984 |
[file join $globname a3]]] |
| 985 |
test filename-11.25.1 {Tcl_GlobCmd} { |
| 986 |
lsort [glob -type {d r} -dir $globname *] |
| 987 |
} [lsort [list [file join $globname a1]\ |
| 988 |
[file join $globname a2]\ |
| 989 |
[file join $globname a3]]] |
| 990 |
test filename-11.25.2 {Tcl_GlobCmd} { |
| 991 |
lsort [glob -type {d r w} -dir $globname *] |
| 992 |
} [lsort [list [file join $globname a1]\ |
| 993 |
[file join $globname a2]\ |
| 994 |
[file join $globname a3]]] |
| 995 |
test filename-11.26 {Tcl_GlobCmd} { |
| 996 |
glob -type d -path $globname * |
| 997 |
} [list $globname] |
| 998 |
test filename-11.27 {Tcl_GlobCmd} -returnCodes error -body { |
| 999 |
glob -types abcde * |
| 1000 |
} -result {bad argument to "-types": abcde} |
| 1001 |
test filename-11.28 {Tcl_GlobCmd} -returnCodes error -body { |
| 1002 |
glob -types z * |
| 1003 |
} -result {bad argument to "-types": z} |
| 1004 |
test filename-11.29 {Tcl_GlobCmd} -returnCodes error -body { |
| 1005 |
glob -types {abcd efgh} * |
| 1006 |
} -result {only one MacOS type or creator argument to "-types" allowed} |
| 1007 |
test filename-11.30 {Tcl_GlobCmd} -returnCodes error -body { |
| 1008 |
glob -types {{macintosh type TEXT} {macintosh creator ALFA} efgh} * |
| 1009 |
} -result {only one MacOS type or creator argument to "-types" allowed} |
| 1010 |
test filename-11.31 {Tcl_GlobCmd} -returnCodes error -body { |
| 1011 |
glob -types |
| 1012 |
} -result {missing argument to "-types"} |
| 1013 |
test filename-11.32 {Tcl_GlobCmd} -returnCodes error -body { |
| 1014 |
glob -path hello -dir hello * |
| 1015 |
} -result {"-directory" cannot be used with "-path"} |
| 1016 |
test filename-11.33 {Tcl_GlobCmd} -returnCodes error -body { |
| 1017 |
glob -path |
| 1018 |
} -result {missing argument to "-path"} |
| 1019 |
test filename-11.34 {Tcl_GlobCmd} -returnCodes error -body { |
| 1020 |
glob -direct |
| 1021 |
} -result {missing argument to "-directory"} |
| 1022 |
test filename-11.35 {Tcl_GlobCmd} -returnCodes error -body { |
| 1023 |
glob -paths * |
| 1024 |
} -result {bad option "-paths": must be -directory, -join, -nocomplain, -path, -tails, -types, or --} |
| 1025 |
# Test '-tails' flag to glob. |
| 1026 |
test filename-11.36 {Tcl_GlobCmd} -returnCodes error -body { |
| 1027 |
glob -tails * |
| 1028 |
} -result {"-tails" must be used with either "-directory" or "-path"} |
| 1029 |
test filename-11.37 {Tcl_GlobCmd} { |
| 1030 |
glob -type d -tails -path $globname * |
| 1031 |
} [list $globname] |
| 1032 |
test filename-11.38 {Tcl_GlobCmd} { |
| 1033 |
glob -tails -path $globname * |
| 1034 |
} [list $globname] |
| 1035 |
test filename-11.39 {Tcl_GlobCmd} { |
| 1036 |
glob -tails -join -path $globname * |
| 1037 |
} [list $globname] |
| 1038 |
test filename-11.40 {Tcl_GlobCmd} -body { |
| 1039 |
list [glob -dir [pwd] -tails *] [glob *] |
| 1040 |
} -match compareWords -result equal |
| 1041 |
test filename-11.41 {Tcl_GlobCmd} -body { |
| 1042 |
list [glob -dir [pwd] -tails *] [glob -dir [pwd] *] |
| 1043 |
} -match compareWords -result "not equal" |
| 1044 |
test filename-11.42 {Tcl_GlobCmd} -body { |
| 1045 |
set res [list] |
| 1046 |
foreach f [glob -dir [pwd] *] { |
| 1047 |
set f [file tail $f] |
| 1048 |
regsub {^./} $f {} f; # until glob bug [2511011fff] don't fixed (tilde expansion prevention). |
| 1049 |
lappend res $f |
| 1050 |
} |
| 1051 |
list $res [glob *] |
| 1052 |
} -match compareWords -result equal |
| 1053 |
test filename-11.43 {Tcl_GlobCmd} -returnCodes error -body { |
| 1054 |
glob -t * |
| 1055 |
} -result {ambiguous option "-t": must be -directory, -join, -nocomplain, -path, -tails, -types, or --} |
| 1056 |
test filename-11.44 {Tcl_GlobCmd} -returnCodes error -body { |
| 1057 |
glob -tails -path hello -directory hello * |
| 1058 |
} -result {"-directory" cannot be used with "-path"} |
| 1059 |
test filename-11.45 {Tcl_GlobCmd on root volume} -setup { |
| 1060 |
set res1 "" |
| 1061 |
set res2 "" |
| 1062 |
set tmpd [pwd] |
| 1063 |
} -body { |
| 1064 |
catch { |
| 1065 |
set res1 [glob -dir [lindex [file volumes] end] -tails *] |
| 1066 |
} |
| 1067 |
catch { |
| 1068 |
cd [lindex [file volumes] end] |
| 1069 |
set res2 [glob *] |
| 1070 |
} |
| 1071 |
list $res1 $res2 |
| 1072 |
} -cleanup { |
| 1073 |
cd $tmpd |
| 1074 |
} -match compareWords -result equal |
| 1075 |
test filename-11.46 {Tcl_GlobCmd} -returnCodes error -body { |
| 1076 |
glob -types abcde -dir foo * |
| 1077 |
} -result {bad argument to "-types": abcde} |
| 1078 |
test filename-11.47 {Tcl_GlobCmd} -returnCodes error -body { |
| 1079 |
glob -types abcde -path foo * |
| 1080 |
} -result {bad argument to "-types": abcde} |
| 1081 |
test filename-11.48 {Tcl_GlobCmd} -returnCodes error -body { |
| 1082 |
glob -types abcde -dir foo -join * * |
| 1083 |
} -result {bad argument to "-types": abcde} |
| 1084 |
test filename-11.49 {Tcl_GlobCmd} -returnCodes error -body { |
| 1085 |
glob -types abcde -path foo -join * * |
| 1086 |
} -result {bad argument to "-types": abcde} |
| 1087 |
test filename-11.50 {Tcl_GlobCmd} -returnCodes error -body { |
| 1088 |
glob -path hello -path salut * |
| 1089 |
} -result {"-path" may only be used once} |
| 1090 |
test filename-11.51 {Tcl_GlobCmd} -returnCodes error -body { |
| 1091 |
glob -dir hello -dir salut * |
| 1092 |
} -result {"-directory" may only be used once} |
| 1093 |
|
| 1094 |
file rename $horribleglobname globTest |
| 1095 |
file delete -force $tildeglobname |
| 1096 |
set globname globTest |
| 1097 |
unset horribleglobname tildeglobname |
| 1098 |
|
| 1099 |
test filename-12.1 {simple globbing} -constraints {unixOrWin} -body { |
| 1100 |
glob {} |
| 1101 |
} -result {.} |
| 1102 |
test filename-12.1.1 {simple globbing} -constraints {unixOrWin} -body { |
| 1103 |
glob -types f {} |
| 1104 |
} -returnCodes error -result {no files matched glob pattern ""} |
| 1105 |
test filename-12.1.2 {simple globbing} -constraints {unixOrWin} -body { |
| 1106 |
glob -types d {} |
| 1107 |
} -result {.} |
| 1108 |
test filename-12.1.3 {simple globbing} -constraints {unix} -body { |
| 1109 |
glob -types hidden {} |
| 1110 |
} -result {.} |
| 1111 |
test filename-12.1.4 {simple globbing} -constraints {win} -body { |
| 1112 |
glob -types hidden {} |
| 1113 |
} -returnCodes error -result {no files matched glob pattern ""} |
| 1114 |
test filename-12.1.5 {simple globbing} -constraints {win} -body { |
| 1115 |
glob -types hidden c:/ |
| 1116 |
} -returnCodes error -result {no files matched glob pattern "c:/"} |
| 1117 |
test filename-12.1.6 {simple globbing} -constraints {win} -body { |
| 1118 |
glob c:/ |
| 1119 |
} -result {c:/} |
| 1120 |
test filename-12.3 {simple globbing} -body { |
| 1121 |
glob -nocomplain \{a1,a2\} |
| 1122 |
} -result {} |
| 1123 |
set globPreResult globTest/ |
| 1124 |
set x1 x1.c |
| 1125 |
set y1 y1.c |
| 1126 |
test filename-12.4 {simple globbing} -constraints {unixOrWin} -body { |
| 1127 |
lsort [glob globTest/x1.c globTest/y1.c globTest/foo] |
| 1128 |
} -result "$globPreResult$x1 $globPreResult$y1" |
| 1129 |
test filename-12.5 {simple globbing} -body { |
| 1130 |
glob globTest\\/x1.c |
| 1131 |
} -result "$globPreResult$x1" |
| 1132 |
test filename-12.6 {simple globbing} -body { |
| 1133 |
glob globTest\\/\\x1.c |
| 1134 |
} -result "$globPreResult$x1" |
| 1135 |
test filename-12.7 {globbing at filesystem root} -constraints {unix} -body { |
| 1136 |
list [glob -nocomplain /*] [glob -path / *] |
| 1137 |
} -match compareWords -result equal |
| 1138 |
test filename-12.8 {globbing at filesystem root} -constraints {unix} -body { |
| 1139 |
set first [string range [lindex [glob -type d /*] 0] 0 1] |
| 1140 |
list [glob -nocomplain ${first}*] [glob -path $first *] |
| 1141 |
} -match compareWords -result equal |
| 1142 |
test filename-12.9 {globbing at filesystem root} -constraints {win} -body { |
| 1143 |
# Can't grab just anything from 'file volumes' because we need a dir that |
| 1144 |
# has subdirs - assume that C:/ exists across Windows machines. |
| 1145 |
set first [string range [lindex [glob -type d C:/*] 0] 0 3] |
| 1146 |
list [glob -nocomplain ${first}*] [glob -path $first *] |
| 1147 |
} -match compareWords -result equal |
| 1148 |
test filename-12.10 {globbing with volume relative paths} -setup { |
| 1149 |
set pwd [pwd] |
| 1150 |
} -body { |
| 1151 |
set dir [lindex [glob -type d C:/*] 0] |
| 1152 |
cd C:/ |
| 1153 |
list [glob -nocomplain [string range $dir 2 end]] [list $dir] |
| 1154 |
} -cleanup { |
| 1155 |
cd $pwd |
| 1156 |
} -constraints {win} -match compareWords -result equal |
| 1157 |
|
| 1158 |
test filename-13.1 {globbing with brace substitution} { |
| 1159 |
glob globTest/\{\} |
| 1160 |
} "$globPreResult" |
| 1161 |
test filename-13.2 {globbing with brace substitution} -body { |
| 1162 |
glob globTest/\{ |
| 1163 |
} -returnCodes error -result {unmatched open-brace in file name} |
| 1164 |
test filename-13.3 {globbing with brace substitution} -body { |
| 1165 |
glob globTest/\{\\\} |
| 1166 |
} -returnCodes error -result {unmatched open-brace in file name} |
| 1167 |
test filename-13.4 {globbing with brace substitution} -body { |
| 1168 |
glob globTest/\{\\ |
| 1169 |
} -returnCodes error -result {unmatched open-brace in file name} |
| 1170 |
test filename-13.5 {globbing with brace substitution} -body { |
| 1171 |
glob globTest/\} |
| 1172 |
} -returnCodes error -result {unmatched close-brace in file name} |
| 1173 |
test filename-13.6 {globbing with brace substitution} { |
| 1174 |
glob globTest/\{\}x1.c |
| 1175 |
} "$globPreResult$x1" |
| 1176 |
test filename-13.7 {globbing with brace substitution} { |
| 1177 |
glob globTest/\{x\}1.c |
| 1178 |
} "$globPreResult$x1" |
| 1179 |
test filename-13.8 {globbing with brace substitution} { |
| 1180 |
glob globTest/\{x\{\}\}1.c |
| 1181 |
} "$globPreResult$x1" |
| 1182 |
test filename-13.9 {globbing with brace substitution} { |
| 1183 |
lsort [glob globTest/\{x,y\}1.c] |
| 1184 |
} [list $globPreResult$x1 $globPreResult$y1] |
| 1185 |
test filename-13.10 {globbing with brace substitution} { |
| 1186 |
lsort [glob globTest/\{x,,y\}1.c] |
| 1187 |
} [list $globPreResult$x1 $globPreResult$y1] |
| 1188 |
test filename-13.11 {globbing with brace substitution} {unixOrWin} { |
| 1189 |
lsort [glob globTest/\{x,x\\,z,z\}1.c] |
| 1190 |
} [lsort {globTest/x1.c globTest/x,z1.c globTest/z1.c}] |
| 1191 |
test filename-13.13 {globbing with brace substitution} { |
| 1192 |
lsort [glob globTest/{a,b,x,y}1.c] |
| 1193 |
} [list $globPreResult$x1 $globPreResult$y1] |
| 1194 |
test filename-13.14 {globbing with brace substitution} {unixOrWin} { |
| 1195 |
lsort [glob {globTest/{x1,y2,weird name}.c}] |
| 1196 |
} {{globTest/weird name.c} globTest/x1.c} |
| 1197 |
test filename-13.16 {globbing with brace substitution} {unixOrWin} { |
| 1198 |
lsort [glob globTest/{x1.c,a1/*}] |
| 1199 |
} {globTest/a1/b1 globTest/a1/b2 globTest/x1.c} |
| 1200 |
test filename-13.18 {globbing with brace substitution} {unixOrWin} { |
| 1201 |
lsort [glob globTest/{x1.c,{a},a1/*}] |
| 1202 |
} {globTest/a1/b1 globTest/a1/b2 globTest/x1.c} |
| 1203 |
test filename-13.20 {globbing with brace substitution} {unixOrWin} { |
| 1204 |
lsort [glob globTest/{a,x}1/*/{x,y}*] |
| 1205 |
} {globTest/a1/b1/x2.c globTest/a1/b2/y2.c} |
| 1206 |
test filename-13.22 {globbing with brace substitution} -body { |
| 1207 |
glob globTest/\{a,x\}1/*/\{ |
| 1208 |
} -returnCodes error -result {unmatched open-brace in file name} |
| 1209 |
|
| 1210 |
test filename-14.1 {asterisks, question marks, and brackets} {unixOrWin} { |
| 1211 |
lsort [glob glo*/*.c] |
| 1212 |
} {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c} |
| 1213 |
test filename-14.3 {asterisks, question marks, and brackets} {unixOrWin} { |
| 1214 |
lsort [glob globTest/?1.c] |
| 1215 |
} {globTest/x1.c globTest/y1.c globTest/z1.c} |
| 1216 |
test filename-14.5 {asterisks, question marks, and brackets} -setup { |
| 1217 |
# The current directory could be anywhere; do this to stop spurious |
| 1218 |
# matches |
| 1219 |
file mkdir globTestContext |
| 1220 |
file rename globTest [file join globTestContext globTest] |
| 1221 |
set savepwd [pwd] |
| 1222 |
cd globTestContext |
| 1223 |
} -constraints {unixOrWin} -body { |
| 1224 |
lsort [glob */*/*/*.c] |
| 1225 |
} -cleanup { |
| 1226 |
# Reset to where we were |
| 1227 |
cd $savepwd |
| 1228 |
file rename [file join globTestContext globTest] globTest |
| 1229 |
file delete globTestContext |
| 1230 |
} -result {globTest/a1/b1/x2.c globTest/a1/b2/y2.c} |
| 1231 |
test filename-14.7 {asterisks, question marks, and brackets} {unix} { |
| 1232 |
lsort [glob globTest/*] |
| 1233 |
} {globTest/a1 globTest/a2 globTest/a3 {globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c} |
| 1234 |
test filename-14.7.1 {asterisks, question marks, and brackets} {win} { |
| 1235 |
lsort [glob globTest/*] |
| 1236 |
} {globTest/.1 globTest/a1 globTest/a2 globTest/a3 {globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c} |
| 1237 |
test filename-14.9 {asterisks, question marks, and brackets} {unixOrWin} { |
| 1238 |
lsort [glob globTest/.*] |
| 1239 |
} {globTest/. globTest/.. globTest/.1} |
| 1240 |
test filename-14.11 {asterisks, question marks, and brackets} {unixOrWin} { |
| 1241 |
lsort [glob globTest/*/*] |
| 1242 |
} {globTest/a1/b1 globTest/a1/b2 globTest/a2/b3} |
| 1243 |
test filename-14.13 {asterisks, question marks, and brackets} {unixOrWin} { |
| 1244 |
lsort [glob {globTest/[xyab]1.*}] |
| 1245 |
} {globTest/x1.c globTest/y1.c} |
| 1246 |
test filename-14.15 {asterisks, question marks, and brackets} {unixOrWin} { |
| 1247 |
lsort [glob globTest/*/] |
| 1248 |
} {globTest/a1/ globTest/a2/ globTest/a3/} |
| 1249 |
test filename-14.17 {asterisks, question marks, and brackets} -setup { |
| 1250 |
global env |
| 1251 |
set temp $env(HOME) |
| 1252 |
} -body { |
| 1253 |
set env(HOME) [file join $env(HOME) globTest] |
| 1254 |
glob ~/z* |
| 1255 |
} -cleanup { |
| 1256 |
set env(HOME) $temp |
| 1257 |
} -result [list [file join $env(HOME) globTest z1.c]] |
| 1258 |
test filename-14.18 {asterisks, question marks, and brackets} {unixOrWin} { |
| 1259 |
lsort [glob globTest/*.c goo/*] |
| 1260 |
} {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c} |
| 1261 |
test filename-14.20 {asterisks, question marks, and brackets} { |
| 1262 |
glob -nocomplain goo/* |
| 1263 |
} {} |
| 1264 |
test filename-14.21 {asterisks, question marks, and brackets} -body { |
| 1265 |
glob globTest/*/gorp |
| 1266 |
} -returnCodes error -result {no files matched glob pattern "globTest/*/gorp"} |
| 1267 |
test filename-14.22 {asterisks, question marks, and brackets} -body { |
| 1268 |
glob goo/* x*z foo?q |
| 1269 |
} -returnCodes error -result {no files matched glob patterns "goo/* x*z foo?q"} |
| 1270 |
test filename-14.23 {slash globbing} {unix} { |
| 1271 |
glob / |
| 1272 |
} / |
| 1273 |
test filename-14.23.2 {slash globbing} {win} { |
| 1274 |
glob / |
| 1275 |
} [file norm /] |
| 1276 |
test filename-14.24 {slash globbing} {win} { |
| 1277 |
glob {\\} |
| 1278 |
} [file norm /] |
| 1279 |
test filename-14.25 {type specific globbing} {unix} { |
| 1280 |
lsort [glob -dir globTest -types f *] |
| 1281 |
} [lsort [list \ |
| 1282 |
[file join $globname "weird name.c"]\ |
| 1283 |
[file join $globname x,z1.c]\ |
| 1284 |
[file join $globname x1.c]\ |
| 1285 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 1286 |
test filename-14.25.1 {type specific globbing} {win} { |
| 1287 |
lsort [glob -dir globTest -types f *] |
| 1288 |
} [lsort [list \ |
| 1289 |
[file join $globname .1]\ |
| 1290 |
[file join $globname "weird name.c"]\ |
| 1291 |
[file join $globname x,z1.c]\ |
| 1292 |
[file join $globname x1.c]\ |
| 1293 |
[file join $globname y1.c] [file join $globname z1.c]]] |
| 1294 |
test filename-14.26 {type specific globbing} { |
| 1295 |
glob -nocomplain -dir globTest -types {readonly} * |
| 1296 |
} {} |
| 1297 |
test filename-14.27 {Bug 2710920} {unixOrWin} { |
| 1298 |
file tail [lindex [lsort [glob globTest/*/]] 0] |
| 1299 |
} a1 |
| 1300 |
test filename-14.28 {Bug 2710920} {unixOrWin} { |
| 1301 |
file dirname [lindex [lsort [glob globTest/*/]] 0] |
| 1302 |
} globTest |
| 1303 |
test filename-14.29 {Bug 2710920} {unixOrWin} { |
| 1304 |
file extension [lindex [lsort [glob globTest/*/]] 0] |
| 1305 |
} {} |
| 1306 |
test filename-14.30 {Bug 2710920} {unixOrWin} { |
| 1307 |
file rootname [lindex [lsort [glob globTest/*/]] 0] |
| 1308 |
} globTest/a1/ |
| 1309 |
|
| 1310 |
test filename-14.31 {Bug 2918610} -setup { |
| 1311 |
set d [makeDirectory foo] |
| 1312 |
makeFile {} bar.soom $d |
| 1313 |
} -body { |
| 1314 |
foreach fn [glob $d/bar.soom] { |
| 1315 |
set root [file rootname $fn] |
| 1316 |
close [open $root {WRONLY CREAT}] |
| 1317 |
} |
| 1318 |
llength [glob -directory $d *] |
| 1319 |
} -cleanup { |
| 1320 |
file delete -force $d/bar |
| 1321 |
removeFile bar.soom $d |
| 1322 |
removeDirectory foo |
| 1323 |
} -result 2 |
| 1324 |
|
| 1325 |
unset globname |
| 1326 |
|
| 1327 |
# The following tests are only valid for Unix systems. On some systems, like |
| 1328 |
# AFS, "000" protection doesn't prevent access by owner, so the following test |
| 1329 |
# is not portable. |
| 1330 |
|
| 1331 |
catch {file attributes globTest/a1 -permissions 0o000} |
| 1332 |
test filename-15.1 {unix specific globbing} {unix nonPortable} { |
| 1333 |
string tolower [list [catch {glob globTest/a1/*} msg] $msg $errorCode] |
| 1334 |
} {1 {couldn't read directory "globtest/a1": permission denied} {posix eacces {permission denied}}} |
| 1335 |
test filename-15.2 {unix specific no complain: no errors} {unix nonPortable} { |
| 1336 |
glob -nocomplain globTest/a1/* |
| 1337 |
} {} |
| 1338 |
test filename-15.3 {unix specific no complain: no errors, good result} \ |
| 1339 |
{unix nonPortable} { |
| 1340 |
# test fails because if an error occurs, the interp's result is reset... |
| 1341 |
glob -nocomplain globTest/a2 globTest/a1/* globTest/a3 |
| 1342 |
} {globTest/a2 globTest/a3} |
| 1343 |
catch {file attributes globTest/a1 -permissions 0o755} |
| 1344 |
test filename-15.4 {unix specific no complain: no errors, good result} \ |
| 1345 |
{unix nonPortable} { |
| 1346 |
# test fails because if an error occurs, the interp's result is reset... |
| 1347 |
# or you don't run at scriptics where the ouster and welch users exists |
| 1348 |
glob -nocomplain ~ouster ~foo ~welch |
| 1349 |
} {/home/ouster /home/welch} |
| 1350 |
test filename-15.4.1 {no complain: errors, sequencing} { |
| 1351 |
# test used to fail because if an error occurs, the interp's result is |
| 1352 |
# reset... But, the sequence means we throw a different error first. |
| 1353 |
list [catch {glob -nocomplain ~wontexist ~blahxyz ~} res1] $res1 \ |
| 1354 |
[catch {glob -nocomplain ~ ~blahxyz ~wontexist} res2] $res2 |
| 1355 |
} {1 {user "wontexist" doesn't exist} 1 {user "blahxyz" doesn't exist}} |
| 1356 |
test filename-15.4.2 {no complain: errors, sequencing} -body { |
| 1357 |
# test used to fail because if an error occurs, the interp's result is |
| 1358 |
# reset... |
| 1359 |
list [list [catch {glob -nocomplain ~wontexist *} res1] $res1] \ |
| 1360 |
[list [catch {glob -nocomplain * ~wontexist} res2] $res2] |
| 1361 |
} -match compareWords -result equal |
| 1362 |
test filename-15.5 {unix specific globbing} {unix nonPortable} { |
| 1363 |
glob ~ouster/.csh* |
| 1364 |
} "/home/ouster/.cshrc" |
| 1365 |
touch globTest/odd\\\[\]*?\{\}name |
| 1366 |
test filename-15.6 {unix specific globbing} -constraints {unix} -setup { |
| 1367 |
global env |
| 1368 |
set temp $env(HOME) |
| 1369 |
} -body { |
| 1370 |
set env(HOME) $env(HOME)/globTest/odd\\\[\]*?\{\}name |
| 1371 |
glob ~ |
| 1372 |
} -cleanup { |
| 1373 |
set env(HOME) $temp |
| 1374 |
} -result [list [lindex [glob ~] 0]/globTest/odd\\\[\]*?\{\}name] |
| 1375 |
catch {file delete -force globTest/odd\\\[\]*?\{\}name} |
| 1376 |
test filename-15.7 {win specific globbing} -constraints {win} -body { |
| 1377 |
glob ~ |
| 1378 |
} -match regexp -result {[^/]$} |
| 1379 |
test filename-15.8 {win and unix specific globbing} -constraints {unixOrWin} -setup { |
| 1380 |
global env |
| 1381 |
set temp $env(HOME) |
| 1382 |
} -body { |
| 1383 |
touch $env(HOME)/globTest/anyname |
| 1384 |
set env(HOME) $env(HOME)/globTest/anyname |
| 1385 |
glob ~ |
| 1386 |
} -cleanup { |
| 1387 |
set env(HOME) $temp |
| 1388 |
catch {file delete -force $env(HOME)/globTest/anyname} |
| 1389 |
} -result [list [lindex [glob ~] 0]/globTest/anyname] |
| 1390 |
|
| 1391 |
# The following tests are only valid for Windows systems. |
| 1392 |
set oldDir [pwd] |
| 1393 |
if {[testConstraint win]} { |
| 1394 |
cd c:/ |
| 1395 |
file delete -force globTest |
| 1396 |
file mkdir globTest |
| 1397 |
touch globTest/x1.BAT |
| 1398 |
touch globTest/y1.Bat |
| 1399 |
touch globTest/z1.bat |
| 1400 |
} |
| 1401 |
|
| 1402 |
test filename-16.1 {windows specific globbing} {win} { |
| 1403 |
lsort [glob globTest/*.bat] |
| 1404 |
} {globTest/x1.BAT globTest/y1.Bat globTest/z1.bat} |
| 1405 |
test filename-16.2 {windows specific globbing} {win} { |
| 1406 |
glob c: |
| 1407 |
} c: |
| 1408 |
test filename-16.2.1 {windows specific globbing} -constraints {win} -setup { |
| 1409 |
set dir [pwd] |
| 1410 |
} -body { |
| 1411 |
cd C:/ |
| 1412 |
glob c: |
| 1413 |
} -cleanup { |
| 1414 |
cd $dir |
| 1415 |
} -result c: |
| 1416 |
test filename-16.3 {windows specific globbing} {win} { |
| 1417 |
glob -nocomplain c:\\\\ |
| 1418 |
} c:/ |
| 1419 |
test filename-16.4 {windows specific globbing} {win} { |
| 1420 |
glob -nocomplain c:/ |
| 1421 |
} c:/ |
| 1422 |
test filename-16.5 {windows specific globbing} {win} { |
| 1423 |
glob -nocomplain c:*bTest |
| 1424 |
} c:globTest |
| 1425 |
test filename-16.6 {windows specific globbing} {win} { |
| 1426 |
glob -nocomplain c:\\\\*bTest |
| 1427 |
} c:/globTest |
| 1428 |
test filename-16.7 {windows specific globbing} {win} { |
| 1429 |
glob -nocomplain c:/*bTest |
| 1430 |
} c:/globTest |
| 1431 |
test filename-16.8 {windows specific globbing} {win} { |
| 1432 |
lsort [glob -nocomplain c:globTest/*.bat] |
| 1433 |
} {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat} |
| 1434 |
test filename-16.9 {windows specific globbing} {win} { |
| 1435 |
lsort [glob -nocomplain c:/globTest/*.bat] |
| 1436 |
} {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat} |
| 1437 |
test filename-16.10 {windows specific globbing} {win} { |
| 1438 |
lsort [glob -nocomplain c:globTest\\\\*.bat] |
| 1439 |
} {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat} |
| 1440 |
test filename-16.11 {windows specific globbing} {win} { |
| 1441 |
lsort [glob -nocomplain c:\\\\globTest\\\\*.bat] |
| 1442 |
} {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat} |
| 1443 |
# some tests require a shared C drive |
| 1444 |
test filename-16.12 {windows specific globbing} {win sharedCdrive} { |
| 1445 |
cd //[info hostname]/c |
| 1446 |
glob //[info hostname]/c/*Test |
| 1447 |
} //[info hostname]/c/globTest |
| 1448 |
test filename-16.13 {windows specific globbing} {win sharedCdrive} { |
| 1449 |
cd //[info hostname]/c |
| 1450 |
glob "\\\\\\\\[info hostname]\\\\c\\\\*Test" |
| 1451 |
} //[info hostname]/c/globTest |
| 1452 |
test filename-16.14 {windows specific globbing} {win sharedCdrive} { |
| 1453 |
cd [lindex [glob -types d -dir C:/ *] 0] |
| 1454 |
expr {".." in [glob {{.,*}*}]} |
| 1455 |
} {1} |
| 1456 |
test filename-16.15 {windows specific globbing} {win} { |
| 1457 |
cd [lindex [glob -types d -dir C:/ *] 0] |
| 1458 |
glob .. |
| 1459 |
} {..} |
| 1460 |
test filename-16.16 {windows specific globbing} {win} { |
| 1461 |
file tail [lindex [glob -nocomplain "[lindex [glob -types d -dir C:/ *] 0]/.."] 0] |
| 1462 |
} {..} |
| 1463 |
test filename-16.17 {windows specific globbing} -constraints {win} -body { |
| 1464 |
cd C:/ |
| 1465 |
# Ensure correct trimming of tails with absolute and volume relative |
| 1466 |
# globbing. |
| 1467 |
list [glob -nocomplain -tails -dir C:/ *] \ |
| 1468 |
[glob -nocomplain -tails -dir C: *] |
| 1469 |
} -match compareWords -result equal |
| 1470 |
|
| 1471 |
# Put the working directory back now that we're done with globbing in C:/ |
| 1472 |
if {[testConstraint win]} { |
| 1473 |
cd $oldDir |
| 1474 |
} |
| 1475 |
|
| 1476 |
test filename-17.1 {windows specific special files} {testsetplatform} { |
| 1477 |
testsetplatform win |
| 1478 |
list [file pathtype com1] [file pathtype con] [file pathtype lpt3] \ |
| 1479 |
[file pathtype prn] [file pathtype nul] [file pathtype aux] \ |
| 1480 |
[file pathtype foo] |
| 1481 |
} {absolute absolute absolute absolute absolute absolute relative} |
| 1482 |
if {[testConstraint testsetplatform]} { |
| 1483 |
testsetplatform $platform |
| 1484 |
} |
| 1485 |
test filename-17.2 {windows specific glob with executable} -body { |
| 1486 |
makeDirectory execglob |
| 1487 |
foreach ext {exe com cmd bat notexecutable} { |
| 1488 |
makeFile contents execglob/abc.$ext |
| 1489 |
} |
| 1490 |
lsort [glob -nocomplain -dir [temporaryDirectory]/execglob -tails -types x *] |
| 1491 |
} -constraints {win} -cleanup { |
| 1492 |
foreach ext {exe com cmd bat ps1 notexecutable} { |
| 1493 |
removeFile execglob/abc.$ext |
| 1494 |
} |
| 1495 |
removeDirectory execglob |
| 1496 |
} -result {abc.bat abc.cmd abc.com abc.exe} |
| 1497 |
test filename-17.3 {Bug 2571597} win { |
| 1498 |
set p /a |
| 1499 |
file pathtype $p |
| 1500 |
file normalize $p |
| 1501 |
file pathtype $p |
| 1502 |
} volumerelative |
| 1503 |
|
| 1504 |
test fileName-18.1 {windows - split ADS name correctly} {win} { |
| 1505 |
# bug 1194458 |
| 1506 |
set x [file split c:/c:d] |
| 1507 |
list $x [file join {*}$x] |
| 1508 |
} {{c:/ ./c:d} c:/c:d} |
| 1509 |
|
| 1510 |
test fileName-19.1 {ensure that [Bug 1325099] stays fixed} { |
| 1511 |
# Any non-crashing result is OK |
| 1512 |
list [file exists ~//.nonexistant_file] [file exists ~///.nonexistant_file] |
| 1513 |
} {0 0} |
| 1514 |
|
| 1515 |
test fileName-20.1 {Bug 1750300} -setup { |
| 1516 |
set d [makeDirectory foo] |
| 1517 |
makeFile {} TAGS $d |
| 1518 |
} -body { |
| 1519 |
llength [glob -nocomplain -directory $d -- TAGS one two] |
| 1520 |
} -cleanup { |
| 1521 |
removeFile TAGS $d |
| 1522 |
removeDirectory foo |
| 1523 |
} -result 1 |
| 1524 |
test fileName-20.2 {Bug 1750300} -setup { |
| 1525 |
set d [makeDirectory foo] |
| 1526 |
makeFile {} TAGS $d |
| 1527 |
} -body { |
| 1528 |
llength [glob -nocomplain -directory $d -types {} -- TAGS one two] |
| 1529 |
} -cleanup { |
| 1530 |
removeFile TAGS $d |
| 1531 |
removeDirectory foo |
| 1532 |
} -result 1 |
| 1533 |
test fileName-20.3 {Bug 1750300} -setup { |
| 1534 |
set d [makeDirectory foo] |
| 1535 |
makeFile {} TAGS $d |
| 1536 |
} -body { |
| 1537 |
llength [glob -nocomplain -directory $d -types {} -- *U*] |
| 1538 |
} -cleanup { |
| 1539 |
removeFile TAGS $d |
| 1540 |
removeDirectory foo |
| 1541 |
} -result 0 |
| 1542 |
test fileName-20.4 {Bug 1750300} -setup { |
| 1543 |
set d [makeDirectory foo] |
| 1544 |
makeFile {} TAGS $d |
| 1545 |
} -body { |
| 1546 |
llength [glob -nocomplain -directory $d -types {} -- URGENT Urkle] |
| 1547 |
} -cleanup { |
| 1548 |
removeFile TAGS $d |
| 1549 |
removeDirectory foo |
| 1550 |
} -result 0 |
| 1551 |
test fileName-20.5 {Bug 2837800} -setup { |
| 1552 |
set dd [makeDirectory isolate] |
| 1553 |
set d [makeDirectory ./~foo $dd] |
| 1554 |
makeFile {} test $d |
| 1555 |
set savewd [pwd] |
| 1556 |
cd $dd |
| 1557 |
} -body { |
| 1558 |
glob -nocomplain */test |
| 1559 |
} -cleanup { |
| 1560 |
cd $savewd |
| 1561 |
removeFile test $d |
| 1562 |
removeDirectory ./~foo $dd |
| 1563 |
removeDirectory isolate |
| 1564 |
} -result ~foo/test |
| 1565 |
test fileName-20.6 {Bug 2837800} -setup { |
| 1566 |
# Recall that we have $env(HOME) set so that references |
| 1567 |
# to ~ point to [temporaryDirectory] |
| 1568 |
makeFile {} test ~ |
| 1569 |
set dd [makeDirectory isolate] |
| 1570 |
set d [makeDirectory ./~ $dd] |
| 1571 |
set savewd [pwd] |
| 1572 |
cd $dd |
| 1573 |
} -body { |
| 1574 |
glob -nocomplain */test |
| 1575 |
} -cleanup { |
| 1576 |
cd $savewd |
| 1577 |
removeDirectory ./~ $dd |
| 1578 |
removeDirectory isolate |
| 1579 |
removeFile test ~ |
| 1580 |
} -result {} |
| 1581 |
test fileName-20.7 {Bug 2806250} -setup { |
| 1582 |
set savewd [pwd] |
| 1583 |
cd [temporaryDirectory] |
| 1584 |
set d [makeDirectory isolate] |
| 1585 |
makeFile {} ./~test $d |
| 1586 |
} -body { |
| 1587 |
file exists [lindex [glob -nocomplain isolate/*] 0] |
| 1588 |
} -cleanup { |
| 1589 |
removeFile ./~test $d |
| 1590 |
removeDirectory isolate |
| 1591 |
cd $savewd |
| 1592 |
} -result 1 |
| 1593 |
test fileName-20.8 {Bug 2806250} -setup { |
| 1594 |
set savewd [pwd] |
| 1595 |
cd [temporaryDirectory] |
| 1596 |
set d [makeDirectory isolate] |
| 1597 |
makeFile {} ./~test $d |
| 1598 |
} -body { |
| 1599 |
file tail [lindex [glob -nocomplain isolate/*] 0] |
| 1600 |
} -cleanup { |
| 1601 |
removeFile ./~test $d |
| 1602 |
removeDirectory isolate |
| 1603 |
cd $savewd |
| 1604 |
} -result ./~test |
| 1605 |
test fileName-20.9 {globbing for special chars} -setup { |
| 1606 |
makeFile {} test ~ |
| 1607 |
set d [makeDirectory isolate] |
| 1608 |
set savewd [pwd] |
| 1609 |
cd $d |
| 1610 |
} -body { |
| 1611 |
glob -nocomplain -directory ~ test |
| 1612 |
} -cleanup { |
| 1613 |
cd $savewd |
| 1614 |
removeDirectory isolate |
| 1615 |
removeFile test ~ |
| 1616 |
} -result ~/test |
| 1617 |
test fileName-20.10 {globbing for special chars} -setup { |
| 1618 |
set s [makeDirectory sub ~] |
| 1619 |
makeFile {} fileName-20.10 $s |
| 1620 |
set d [makeDirectory isolate] |
| 1621 |
set savewd [pwd] |
| 1622 |
cd $d |
| 1623 |
} -body { |
| 1624 |
glob -nocomplain -directory ~ -join * fileName-20.10 |
| 1625 |
} -cleanup { |
| 1626 |
cd $savewd |
| 1627 |
removeDirectory isolate |
| 1628 |
removeFile fileName-20.10 $s |
| 1629 |
removeDirectory sub ~ |
| 1630 |
} -result ~/sub/fileName-20.10 |
| 1631 |
|
| 1632 |
# cleanup |
| 1633 |
catch {file delete -force C:/globTest} |
| 1634 |
cd [temporaryDirectory] |
| 1635 |
file delete -force globTest |
| 1636 |
cd $oldpwd |
| 1637 |
catch {removeDirectory tcl[pid]} |
| 1638 |
set env(HOME) $oldhome |
| 1639 |
if {[testConstraint testsetplatform]} { |
| 1640 |
testsetplatform $platform |
| 1641 |
catch {unset platform} |
| 1642 |
} |
| 1643 |
catch {unset oldhome temp result globPreResult} |
| 1644 |
::tcltest::cleanupTests |
| 1645 |
return |
| 1646 |
|
| 1647 |
# Local Variables: |
| 1648 |
# mode: tcl |
| 1649 |
# End: |