1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
+
+
|
# This file tests the filename manipulation routines.
#
# This file contains a collection of tests for one or more of the Tcl built-in
# commands. Sourcing this file into Tcl runs the tests and generates output
# for errors. No output means no errors were found.
#
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
# Copyright (c) 1999 by Scriptics Corporation.
# Copyright (c) 1999 Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
if {"::tcltest" ni [namespace children]} {
package require tcltest 2.5
namespace import -force ::tcltest::*
}
::tcltest::loadTestedCommands
catch [list package require -exact Tcltest [info patchlevel]]
testConstraint testsetplatform [llength [info commands testsetplatform]]
testConstraint testtranslatefilename [llength [info commands testtranslatefilename]]
testConstraint linkDirectory 1
|
| ︙ | | |
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
|
-
+
-
+
-
+
-
-
+
+
-
+
|
glob ~/*
} -returnCodes error -cleanup {
set env(HOME) $home
} -result {couldn't find HOME environment variable to expand path}
if {[testConstraint testsetplatform]} {
testsetplatform $platform
}
test filename-11.13 {Tcl_GlobCmd} {
test filename-11.13 {Tcl_GlobCmd} -body {
file join [lindex [glob ~] 0]
} [file join $env(HOME)]
} -result [file join $env(HOME)]
set oldpwd [pwd]
set oldhome $env(HOME)
catch {cd [makeDirectory tcl[pid]]}
set env(HOME) [pwd]
file delete -force globTest
file mkdir globTest/a1/b1
file mkdir globTest/a1/b2
file mkdir globTest/a2/b3
file mkdir globTest/a3
touch globTest/x1.c
touch globTest/y1.c
touch globTest/z1.c
touch "globTest/weird name.c"
touch globTest/a1/b1/x2.c
touch globTest/a1/b2/y2.c
touch globTest/.1
touch globTest/x,z1.c
test filename-11.14 {Tcl_GlobCmd} {
test filename-11.14 {Tcl_GlobCmd} -body {
glob ~/globTest
} [list [file join $env(HOME) globTest]]
test filename-11.15 {Tcl_GlobCmd} {
} -result [list [file join $env(HOME) globTest]]
test filename-11.15 {Tcl_GlobCmd} -body {
glob ~\\/globTest
} [list [file join $env(HOME) globTest]]
} -result [list [file join $env(HOME) globTest]]
test filename-11.16 {Tcl_GlobCmd} {
glob globTest
} {globTest}
set globname "globTest"
set horribleglobname "glob\[\{Test"
set tildeglobname "./~test.txt"
|
| ︙ | | |
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
|
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
|
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
|
} -result {"-directory" may only be used once}
file rename $horribleglobname globTest
file delete -force $tildeglobname
set globname globTest
unset horribleglobname tildeglobname
test filename-12.1 {simple globbing} {unixOrWin} {
test filename-12.1 {simple globbing} -constraints {unixOrWin} -body {
glob {}
} {.}
} -result {.}
test filename-12.1.1 {simple globbing} -constraints {unixOrWin} -body {
glob -types f {}
} -returnCodes error -result {no files matched glob pattern ""}
test filename-12.1.2 {simple globbing} {unixOrWin} {
test filename-12.1.2 {simple globbing} -constraints {unixOrWin} -body {
glob -types d {}
} {.}
test filename-12.1.3 {simple globbing} {unix} {
} -result {.}
test filename-12.1.3 {simple globbing} -constraints {unix} -body {
glob -types hidden {}
} {.}
} -result {.}
test filename-12.1.4 {simple globbing} -constraints {win} -body {
glob -types hidden {}
} -returnCodes error -result {no files matched glob pattern ""}
test filename-12.1.5 {simple globbing} -constraints {win} -body {
glob -types hidden c:/
} -returnCodes error -result {no files matched glob pattern "c:/"}
test filename-12.1.6 {simple globbing} {win} {
test filename-12.1.6 {simple globbing} -constraints {win} -body {
glob c:/
} {c:/}
test filename-12.3 {simple globbing} {
} -result {c:/}
test filename-12.3 {simple globbing} -body {
glob -nocomplain \{a1,a2\}
} {}
} -result {}
set globPreResult globTest/
set x1 x1.c
set y1 y1.c
test filename-12.4 {simple globbing} {unixOrWin} {
test filename-12.4 {simple globbing} -constraints {unixOrWin} -body {
lsort [glob globTest/x1.c globTest/y1.c globTest/foo]
} "$globPreResult$x1 $globPreResult$y1"
test filename-12.5 {simple globbing} {
} -result "$globPreResult$x1 $globPreResult$y1"
test filename-12.5 {simple globbing} -body {
glob globTest\\/x1.c
} "$globPreResult$x1"
test filename-12.6 {simple globbing} {
} -result "$globPreResult$x1"
test filename-12.6 {simple globbing} -body {
glob globTest\\/\\x1.c
} "$globPreResult$x1"
} -result "$globPreResult$x1"
test filename-12.7 {globbing at filesystem root} -constraints {unix} -body {
list [glob -nocomplain /*] [glob -path / *]
} -match compareWords -result equal
test filename-12.8 {globbing at filesystem root} -constraints {unix} -body {
set first [string range [lindex [glob -type d /*] 0] 0 1]
list [glob -nocomplain ${first}*] [glob -path $first *]
} -match compareWords -result equal
|
| ︙ | | |
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
|
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
|
-
-
+
+
|
} globTest/a1/
test filename-14.31 {Bug 2918610} -setup {
set d [makeDirectory foo]
makeFile {} bar.soom $d
} -body {
foreach fn [glob $d/bar.soom] {
set root [file rootname $fn]
close [open $root {WRONLY CREAT}]
set root [file rootname $fn]
close [open $root {WRONLY CREAT}]
}
llength [glob -directory $d *]
} -cleanup {
file delete -force $d/bar
removeFile bar.soom $d
removeDirectory foo
} -result 2
|
| ︙ | | |
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
|
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
|
-
+
|
cd //[info hostname]/c
glob //[info hostname]/c/*Test
} //[info hostname]/c/globTest
test filename-16.13 {windows specific globbing} {win sharedCdrive} {
cd //[info hostname]/c
glob "\\\\\\\\[info hostname]\\\\c\\\\*Test"
} //[info hostname]/c/globTest
test filename-16.14 {windows specific globbing} {win} {
test filename-16.14 {windows specific globbing} {win sharedCdrive} {
cd [lindex [glob -types d -dir C:/ *] 0]
expr {".." in [glob {{.,*}*}]}
} {1}
test filename-16.15 {windows specific globbing} {win} {
cd [lindex [glob -types d -dir C:/ *] 0]
glob ..
} {..}
|
| ︙ | | |
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
|
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
|
-
+
-
+
|
} {absolute absolute absolute absolute absolute absolute relative}
if {[testConstraint testsetplatform]} {
testsetplatform $platform
}
test filename-17.2 {windows specific glob with executable} -body {
makeDirectory execglob
foreach ext {exe com cmd bat notexecutable} {
makeFile contents execglob/abc.$ext
makeFile contents execglob/abc.$ext
}
lsort [glob -nocomplain -dir [temporaryDirectory]/execglob -tails -types x *]
} -constraints {win} -cleanup {
foreach ext {exe com cmd bat ps1 notexecutable} {
removeFile execglob/abc.$ext
removeFile execglob/abc.$ext
}
removeDirectory execglob
} -result {abc.bat abc.cmd abc.com abc.exe}
test filename-17.3 {Bug 2571597} win {
set p /a
file pathtype $p
file normalize $p
|
| ︙ | | |