os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/fileName.test
First public contribution.
1 # This file tests the filename manipulation routines.
3 # This file contains a collection of tests for one or more of the Tcl
4 # built-in commands. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1995-1996 Sun Microsystems, Inc.
8 # Copyright (c) 1999 by Scriptics Corporation.
9 # Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiaries. All rights reserved.
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 # RCS: @(#) $Id: fileName.test,v 1.30.2.7 2005/06/21 19:07:58 kennykb Exp $
16 if {[lsearch [namespace children] ::tcltest] == -1} {
17 package require tcltest
18 namespace import -force ::tcltest::*
21 tcltest::testConstraint testsetplatform [string equal testsetplatform [info commands testsetplatform]]
22 tcltest::testConstraint testtranslatefilename [string equal testtranslatefilename [info commands testtranslatefilename]]
25 if {[tcltest::testConstraint testsetplatform]} {
26 set platform [testgetplatform]
29 test filename-1.1 {Tcl_GetPathType: unix} {testsetplatform} {
33 test filename-1.2 {Tcl_GetPathType: unix} {testsetplatform} {
37 test filename-1.3 {Tcl_GetPathType: unix} {testsetplatform} {
41 test filename-1.4 {Tcl_GetPathType: unix} {testsetplatform} {
45 test filename-1.5 {Tcl_GetPathType: unix} {testsetplatform} {
49 test filename-1.6 {Tcl_GetPathType: unix} {testsetplatform} {
53 test filename-1.7 {Tcl_GetPathType: unix} {testsetplatform} {
57 test filename-1.8 {Tcl_GetPathType: unix} {testsetplatform} {
62 test filename-2.1 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
66 test filename-2.2 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
70 test filename-2.3 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
74 test filename-2.4 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
78 test filename-2.5 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
80 file pathtype //.//../.
82 test filename-2.6 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
86 test filename-2.7 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
90 test filename-2.8 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
94 test filename-2.9 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
98 test filename-2.10 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
102 test filename-2.11 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
106 test filename-2.12 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
110 test filename-2.13 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
112 file pathtype /..//./foo
114 test filename-2.14 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
116 file pathtype /foo/bar
118 test filename-2.15 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
120 file pathtype foo/bar
122 test filename-2.16 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
126 test filename-2.17 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
130 test filename-2.18 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
134 test filename-2.19 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
136 file pathtype foo:bar
138 test filename-2.20 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
140 file pathtype :foo:bar
142 test filename-2.21 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
144 file pathtype ::foo:bar
146 test filename-2.22 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
150 test filename-2.23 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
154 test filename-2.24 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
158 test filename-2.25 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
160 file pathtype foo/bar:
162 test filename-2.26 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
166 test filename-2.27 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
171 test filename-3.1 {Tcl_GetPathType: windows} {testsetplatform} {
172 testsetplatform windows
175 test filename-3.2 {Tcl_GetPathType: windows} {testsetplatform} {
176 testsetplatform windows
179 test filename-3.3 {Tcl_GetPathType: windows} {testsetplatform} {
180 testsetplatform windows
183 test filename-3.4 {Tcl_GetPathType: windows} {testsetplatform} {
184 testsetplatform windows
187 test filename-3.5 {Tcl_GetPathType: windows} {testsetplatform} {
188 testsetplatform windows
191 test filename-3.6 {Tcl_GetPathType: windows} {testsetplatform} {
192 testsetplatform windows
195 test filename-3.7 {Tcl_GetPathType: windows} {testsetplatform} {
196 testsetplatform windows
199 test filename-3.8 {Tcl_GetPathType: windows} {testsetplatform} {
200 testsetplatform windows
201 file pathtype c:\\foo
203 test filename-3.9 {Tcl_GetPathType: windows} {testsetplatform} {
204 testsetplatform windows
207 test filename-3.10 {Tcl_GetPathType: windows} {testsetplatform} {
208 testsetplatform windows
211 test filename-3.11 {Tcl_GetPathType: windows} {testsetplatform} {
212 testsetplatform windows
215 test filename-3.12 {Tcl_GetPathType: windows} {testsetplatform} {
216 testsetplatform windows
217 file pathtype //foo/bar
219 test filename-3.13 {Tcl_GetPathType: windows} {testsetplatform} {
220 testsetplatform windows
223 test filename-3.14 {Tcl_GetPathType: windows} {testsetplatform} {
224 testsetplatform windows
227 test filename-3.15 {Tcl_GetPathType: windows} {testsetplatform} {
228 testsetplatform windows
231 test filename-3.16 {Tcl_GetPathType: windows} {testsetplatform} {
232 testsetplatform windows
236 test filename-4.1 {Tcl_SplitPath: unix} {testsetplatform} {
240 test filename-4.2 {Tcl_SplitPath: unix} {testsetplatform} {
244 test filename-4.3 {Tcl_SplitPath: unix} {testsetplatform} {
248 test filename-4.4 {Tcl_SplitPath: unix} {testsetplatform} {
250 file split /foo/bar/baz
252 test filename-4.5 {Tcl_SplitPath: unix} {testsetplatform} {
256 test filename-4.6 {Tcl_SplitPath: unix} {testsetplatform} {
260 test filename-4.7 {Tcl_SplitPath: unix} {testsetplatform} {
262 file split /foo/../././foo/bar
263 } {/ foo .. . . foo bar}
264 test filename-4.8 {Tcl_SplitPath: unix} {testsetplatform} {
266 file split ../foo/bar
268 test filename-4.9 {Tcl_SplitPath: unix} {testsetplatform} {
272 test filename-4.10 {Tcl_SplitPath: unix} {testsetplatform} {
276 test filename-4.11 {Tcl_SplitPath: unix} {testsetplatform} {
280 test filename-4.12 {Tcl_SplitPath: unix} {testsetplatform} {
284 test filename-4.13 {Tcl_SplitPath: unix} {testsetplatform} {
288 test filename-4.14 {Tcl_SplitPath: unix} {testsetplatform} {
292 test filename-4.15 {Tcl_SplitPath: unix} {testsetplatform} {
296 test filename-4.16 {Tcl_SplitPath: unix} {testsetplatform} {
300 test filename-4.17 {Tcl_SplitPath: unix} {testsetplatform} {
302 file split ~foo/~bar/~baz
303 } {~foo ./~bar ./~baz}
304 test filename-4.18 {Tcl_SplitPath: unix} {testsetplatform} {
306 file split foo/bar~/baz
309 if {[tcltest::testConstraint testsetplatform]} {
310 testsetplatform $platform
313 test filename-4.19 {Tcl_SplitPath} {
316 cd [temporaryDirectory]
318 set nastydir [file join tildetmp ./~tilde]
320 set norm [file normalize $nastydir]
324 set idx [string first tildetmp $norm]
325 set norm [string range $norm $idx end]
326 # fix path away so all platforms are the same
327 regsub {(.*):$} $norm {\1} norm
328 regsub -all ":" $norm "/" norm
329 # make sure we can delete the directory we created
331 file delete -force $nastydir
335 catch {file delete -force [file join [temporaryDirectory] tildetmp]}
337 } {0 tildetmp/~tilde}
339 test filename-5.1 {Tcl_SplitPath: mac} {testsetplatform} {
343 test filename-5.2 {Tcl_SplitPath: mac} {testsetplatform} {
347 test filename-5.3 {Tcl_SplitPath: mac} {testsetplatform} {
351 test filename-5.4 {Tcl_SplitPath: mac} {testsetplatform} {
355 test filename-5.5 {Tcl_SplitPath: mac} {testsetplatform} {
359 test filename-5.6 {Tcl_SplitPath: mac} {testsetplatform} {
363 test filename-5.7 {Tcl_SplitPath: mac} {testsetplatform} {
367 test filename-5.8 {Tcl_SplitPath: mac} {testsetplatform} {
371 test filename-5.9 {Tcl_SplitPath: mac} {testsetplatform} {
375 test filename-5.10 {Tcl_SplitPath: mac} {testsetplatform} {
379 test filename-5.11 {Tcl_SplitPath: mac} {testsetplatform} {
383 test filename-5.12 {Tcl_SplitPath: mac} {testsetplatform} {
387 test filename-5.13 {Tcl_SplitPath: mac} {testsetplatform} {
391 test filename-5.14 {Tcl_SplitPath: mac} {testsetplatform} {
395 test filename-5.15 {Tcl_SplitPath: mac} {testsetplatform} {
399 test filename-5.16 {Tcl_SplitPath: mac} {testsetplatform} {
403 test filename-5.17 {Tcl_SplitPath: mac} {testsetplatform} {
407 test filename-5.18 {Tcl_SplitPath: mac} {testsetplatform} {
411 test filename-5.19 {Tcl_SplitPath: mac} {testsetplatform} {
415 test filename-5.20 {Tcl_SplitPath: mac} {testsetplatform} {
419 test filename-5.21 {Tcl_SplitPath: mac} {testsetplatform} {
423 test filename-5.22 {Tcl_SplitPath: mac} {testsetplatform} {
427 test filename-5.23 {Tcl_SplitPath: mac} {testsetplatform} {
431 test filename-5.24 {Tcl_SplitPath: mac} {testsetplatform} {
435 test filename-5.25 {Tcl_SplitPath: mac} {testsetplatform} {
439 test filename-5.26 {Tcl_SplitPath: mac} {testsetplatform} {
443 test filename-5.27 {Tcl_SplitPath: mac} {testsetplatform} {
445 file split ../foo/bar
447 test filename-5.28 {Tcl_SplitPath: mac} {testsetplatform} {
451 test filename-5.29 {Tcl_SplitPath: mac} {testsetplatform} {
455 test filename-5.30 {Tcl_SplitPath: mac} {testsetplatform} {
459 test filename-5.31 {Tcl_SplitPath: mac} {testsetplatform} {
463 test filename-5.32 {Tcl_SplitPath: mac} {testsetplatform} {
467 test filename-5.33 {Tcl_SplitPath: mac} {testsetplatform} {
471 test filename-5.34 {Tcl_SplitPath: mac} {testsetplatform} {
475 test filename-5.35 {Tcl_SplitPath: mac} {testsetplatform} {
479 test filename-5.36 {Tcl_SplitPath: mac} {testsetplatform} {
483 test filename-5.37 {Tcl_SplitPath: mac} {testsetplatform} {
487 test filename-5.38 {Tcl_SplitPath: mac} {testsetplatform} {
491 test filename-5.39 {Tcl_SplitPath: mac} {testsetplatform} {
495 test filename-5.40 {Tcl_SplitPath: mac} {testsetplatform} {
499 test filename-5.41 {Tcl_SplitPath: mac} {testsetplatform} {
503 test filename-5.42 {Tcl_SplitPath: mac} {testsetplatform} {
505 file split ~foo/~bar/~baz
506 } {~foo: :~bar :~baz}
507 test filename-5.43 {Tcl_SplitPath: mac} {testsetplatform} {
509 file split foo/bar~/baz
511 test filename-5.44 {Tcl_SplitPath: mac} {testsetplatform} {
515 test filename-5.45 {Tcl_SplitPath: mac} {testsetplatform} {
519 test filename-5.46 {Tcl_SplitPath: mac} {testsetplatform} {
521 file split a/.././../b
523 test filename-5.47 {Tcl_SplitPath: mac} {testsetplatform} {
527 test filename-5.48 {Tcl_SplitPath: mac} {testsetplatform} {
531 test filename-5.49 {Tcl_SplitPath: mac} {testsetplatform} {
533 file split //.//.././bar
535 test filename-5.50 {Tcl_SplitPath: mac} {testsetplatform} {
539 test filename-5.51 {Tcl_SplitPath: mac} {testsetplatform} {
541 file split //.//.././
544 test filename-6.1 {Tcl_SplitPath: win} {testsetplatform} {
548 test filename-6.2 {Tcl_SplitPath: win} {testsetplatform} {
552 test filename-6.3 {Tcl_SplitPath: win} {testsetplatform} {
556 test filename-6.4 {Tcl_SplitPath: win} {testsetplatform} {
558 file split /foo/bar/baz
560 test filename-6.5 {Tcl_SplitPath: win} {testsetplatform} {
564 test filename-6.6 {Tcl_SplitPath: win} {testsetplatform} {
568 test filename-6.7 {Tcl_SplitPath: win} {testsetplatform} {
570 file split /foo/../././foo/bar
571 } {/ foo .. . . foo bar}
572 test filename-6.8 {Tcl_SplitPath: win} {testsetplatform} {
574 file split ../foo/bar
576 test filename-6.9 {Tcl_SplitPath: win} {testsetplatform} {
580 test filename-6.10 {Tcl_SplitPath: win} {testsetplatform} {
584 test filename-6.11 {Tcl_SplitPath: win} {testsetplatform} {
588 test filename-6.12 {Tcl_SplitPath: win} {testsetplatform} {
592 test filename-6.13 {Tcl_SplitPath: win} {testsetplatform} {
596 test filename-6.14 {Tcl_SplitPath: win} {testsetplatform} {
600 test filename-6.15 {Tcl_SplitPath: win} {testsetplatform} {
602 file split /\\/foo//bar
604 test filename-6.16 {Tcl_SplitPath: win} {testsetplatform} {
606 file split /\\/foo//bar
608 test filename-6.17 {Tcl_SplitPath: win} {testsetplatform} {
610 file split /\\/foo//bar
612 test filename-6.18 {Tcl_SplitPath: win} {testsetplatform} {
614 file split \\\\foo\\bar
616 test filename-6.19 {Tcl_SplitPath: win} {testsetplatform} {
618 file split \\\\foo\\bar/baz
620 test filename-6.20 {Tcl_SplitPath: win} {testsetplatform} {
624 test filename-6.21 {Tcl_SplitPath: win} {testsetplatform} {
628 test filename-6.22 {Tcl_SplitPath: win} {testsetplatform} {
632 test filename-6.23 {Tcl_SplitPath: win} {testsetplatform} {
636 test filename-6.24 {Tcl_SplitPath: win} {testsetplatform} {
640 test filename-6.25 {Tcl_SplitPath: win} {testsetplatform} {
644 test filename-6.26 {Tcl_SplitPath: win} {testsetplatform} {
648 test filename-6.27 {Tcl_SplitPath: win} {testsetplatform} {
652 test filename-6.28 {Tcl_SplitPath: win} {testsetplatform} {
654 file split ~foo/~bar/~baz
655 } {~foo ./~bar ./~baz}
656 test filename-6.29 {Tcl_SplitPath: win} {testsetplatform} {
658 file split foo/bar~/baz
660 test filename-6.30 {Tcl_SplitPath: win} {testsetplatform} {
665 test filename-7.1 {Tcl_JoinPath: unix} {testsetplatform} {
669 test filename-7.2 {Tcl_JoinPath: unix} {testsetplatform} {
673 test filename-7.3 {Tcl_JoinPath: unix} {testsetplatform} {
677 test filename-7.4 {Tcl_JoinPath: unix} {testsetplatform} {
681 test filename-7.5 {Tcl_JoinPath: unix} {testsetplatform} {
685 test filename-7.6 {Tcl_JoinPath: unix} {testsetplatform} {
689 test filename-7.7 {Tcl_JoinPath: unix} {testsetplatform} {
693 test filename-7.8 {Tcl_JoinPath: unix} {testsetplatform} {
697 test filename-7.9 {Tcl_JoinPath: unix} {testsetplatform} {
699 file join /a/./../. b
701 test filename-7.10 {Tcl_JoinPath: unix} {testsetplatform} {
705 test filename-7.11 {Tcl_JoinPath: unix} {testsetplatform} {
709 test filename-7.12 {Tcl_JoinPath: unix} {testsetplatform} {
713 test filename-7.13 {Tcl_JoinPath: unix} {testsetplatform} {
717 test filename-7.14 {Tcl_JoinPath: unix} {testsetplatform} {
721 test filename-7.15 {Tcl_JoinPath: unix} {testsetplatform} {
725 test filename-7.16 {Tcl_JoinPath: unix} {testsetplatform} {
729 test filename-7.17 {Tcl_JoinPath: unix} {testsetplatform} {
733 test filename-7.18 {Tcl_JoinPath: unix} {testsetplatform} {
738 test filename-8.1 {Tcl_JoinPath: mac} {testsetplatform} {
742 test filename-8.2 {Tcl_JoinPath: mac} {testsetplatform} {
746 test filename-8.3 {Tcl_JoinPath: mac} {testsetplatform} {
750 test filename-8.4 {Tcl_JoinPath: mac} {testsetplatform} {
754 test filename-8.5 {Tcl_JoinPath: mac} {testsetplatform} {
758 test filename-8.6 {Tcl_JoinPath: mac} {testsetplatform} {
762 test filename-8.7 {Tcl_JoinPath: mac} {testsetplatform} {
766 test filename-8.8 {Tcl_JoinPath: mac} {testsetplatform} {
770 test filename-8.9 {Tcl_JoinPath: mac} {testsetplatform} {
774 test filename-8.10 {Tcl_JoinPath: mac} {testsetplatform} {
778 test filename-8.11 {Tcl_JoinPath: mac} {testsetplatform} {
782 test filename-8.12 {Tcl_JoinPath: mac} {testsetplatform} {
786 test filename-8.13 {Tcl_JoinPath: mac} {testsetplatform} {
790 test filename-8.14 {Tcl_JoinPath: mac} {testsetplatform} {
794 test filename-8.15 {Tcl_JoinPath: mac} {testsetplatform} {
798 test filename-8.16 {Tcl_JoinPath: mac} {testsetplatform} {
802 test filename-8.17 {Tcl_JoinPath: mac} {testsetplatform} {
806 test filename-8.18 {Tcl_JoinPath: mac} {testsetplatform} {
810 test filename-8.19 {Tcl_JoinPath: mac} {testsetplatform} {
814 test filename-8.20 {Tcl_JoinPath: mac} {testsetplatform} {
818 test filename-8.21 {Tcl_JoinPath: mac} {testsetplatform} {
822 test filename-8.22 {Tcl_JoinPath: mac} {testsetplatform} {
827 test filename-9.1 {Tcl_JoinPath: win} {testsetplatform} {
831 test filename-9.2 {Tcl_JoinPath: win} {testsetplatform} {
835 test filename-9.3 {Tcl_JoinPath: win} {testsetplatform} {
839 test filename-9.4 {Tcl_JoinPath: win} {testsetplatform} {
843 test filename-9.5 {Tcl_JoinPath: win} {testsetplatform} {
847 test filename-9.6 {Tcl_JoinPath: win} {testsetplatform} {
849 file join c:\\bar foo
851 test filename-9.7 {Tcl_JoinPath: win} {testsetplatform} {
855 test filename-9.8 {Tcl_JoinPath: win} {testsetplatform} {
857 file join ///host//share dir
859 test filename-9.9 {Tcl_JoinPath: win} {testsetplatform} {
863 test filename-9.10 {Tcl_JoinPath: win} {testsetplatform} {
867 test filename-9.11 {Tcl_JoinPath: win} {testsetplatform} {
871 test filename-9.12 {Tcl_JoinPath: win} {testsetplatform} {
875 test filename-9.13 {Tcl_JoinPath: win} {testsetplatform} {
879 test filename-9.14 {Tcl_JoinPath: win} {testsetplatform} {
883 test filename-9.15 {Tcl_JoinPath: win} {testsetplatform} {
885 file join // host share path
887 test filename-9.16 {Tcl_JoinPath: win} {testsetplatform} {
891 test filename-9.17 {Tcl_JoinPath: win} {testsetplatform} {
895 test filename-9.18 {Tcl_JoinPath: win} {testsetplatform} {
899 test filename-9.19 {Tcl_JoinPath: win} {testsetplatform} {
903 [file join {C:\foo\bar}] \
904 [file join C:/blah {C:\foo\bar}] \
905 [file join C:/blah C:/blah {C:\foo\bar}]
906 } {C:/foo/bar C:/foo/bar C:/foo/bar}
907 test filename-9.19.1 {Tcl_JoinPath: win} {testsetplatform} {
911 [file join {foo\bar}] \
912 [file join C:/blah {foo\bar}] \
913 [file join C:/blah C:/blah {foo\bar}]
914 } {foo/bar C:/blah/foo/bar C:/blah/foo/bar}
915 test filename-9.19.2 {Tcl_JoinPath: win} {testsetplatform winOnly} {
919 [file join {foo\bar}] \
920 [file join [pwd] {foo\bar}] \
921 [file join [pwd] [pwd] {foo\bar}]
922 string map [list [pwd] pwd] $res
923 } {foo/bar pwd/foo/bar pwd/foo/bar}
924 test filename-9.20 {Tcl_JoinPath: unix} {testsetplatform} {
928 [file join {/foo/bar}] \
929 [file join /x {/foo/bar}] \
930 [file join /x /x {/foo/bar}]
931 } {/foo/bar /foo/bar /foo/bar}
932 test filename-9.21 {Tcl_JoinPath: mac} {testsetplatform} {
936 [file join {/foo/bar}] \
937 [file join drive: {/foo/bar}] \
938 [file join drive: drive: {/foo/bar}]
939 } {foo:bar foo:bar foo:bar}
940 test filename-9.22 {Tcl_JoinPath: mac} {testsetplatform} {
944 [file join {foo:bar}] \
945 [file join drive: {foo:bar}] \
946 [file join drive: drive: {foo:bar}]
947 } {foo:bar foo:bar foo:bar}
948 test filename-9.23 {Tcl_JoinPath: win} {testsetplatform} {
952 [file join {foo\bar}] \
953 [file join C:/blah {foo\bar}] \
954 [file join C:/blah C:/blah {foo\bar}]
955 string map [list C:/blah ""] $res
956 } {foo/bar /foo/bar /foo/bar}
957 test filename-9.24 {Tcl_JoinPath: unix} {testsetplatform} {
961 [file join {foo/bar}] \
962 [file join /x {foo/bar}] \
963 [file join /x /x {foo/bar}]
964 string map [list /x ""] $res
965 } {foo/bar /foo/bar /foo/bar}
966 test filename-9.25 {Tcl_JoinPath: mac} {testsetplatform} {
970 [file join {foo/bar}] \
971 [file join drive: {foo/bar}] \
972 [file join drive: drive: {foo/bar}]
973 string map [list drive: ""] $res
974 } {:foo:bar foo:bar foo:bar}
975 test filename-9.26 {Tcl_JoinPath: mac} {testsetplatform} {
979 [file join {:foo:bar}] \
980 [file join drive: {:foo:bar}] \
981 [file join drive: drive: {:foo:bar}]
982 string map [list drive: ""] $res
983 } {:foo:bar foo:bar foo:bar}
985 test filename-10.1 {Tcl_TranslateFileName} {testsetplatform} {
987 list [catch {testtranslatefilename foo} msg] $msg
989 test filename-10.2 {Tcl_TranslateFileName} {testsetplatform} {
990 testsetplatform windows
991 list [catch {testtranslatefilename {c:/foo}} msg] $msg
993 test filename-10.3 {Tcl_TranslateFileName} {testsetplatform} {
994 testsetplatform windows
995 list [catch {testtranslatefilename {c:/\\foo/}} msg] $msg
997 test filename-10.4 {Tcl_TranslateFileName} {testsetplatform} {
999 list [catch {testtranslatefilename foo} msg] $msg
1001 test filename-10.5 {Tcl_TranslateFileName} {testsetplatform} {
1003 list [catch {testtranslatefilename :~foo} msg] $msg
1005 test filename-10.6 {Tcl_TranslateFileName} {testsetplatform} {
1008 set env(HOME) "/home/test"
1009 testsetplatform unix
1010 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1013 } {0 /home/test/foo}
1014 test filename-10.7 {Tcl_TranslateFileName} {testsetplatform} {
1018 testsetplatform unix
1019 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1022 } {1 {couldn't find HOME environment variable to expand path}}
1023 test filename-10.8 {Tcl_TranslateFileName} {testsetplatform} {
1026 set env(HOME) "/home/test"
1027 testsetplatform unix
1028 set result [list [catch {testtranslatefilename ~} msg] $msg]
1032 test filename-10.9 {Tcl_TranslateFileName} {testsetplatform} {
1035 set env(HOME) "/home/test/"
1036 testsetplatform unix
1037 set result [list [catch {testtranslatefilename ~} msg] $msg]
1041 test filename-10.10 {Tcl_TranslateFileName} {testsetplatform} {
1044 set env(HOME) "/home/test/"
1045 testsetplatform unix
1046 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1049 } {0 /home/test/foo}
1050 test filename-10.11 {Tcl_TranslateFileName} {testsetplatform} {
1053 set env(HOME) "Root:"
1055 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1059 test filename-10.12 {Tcl_TranslateFileName} {testsetplatform} {
1062 set env(HOME) "Root:home"
1064 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1068 test filename-10.13 {Tcl_TranslateFileName} {testsetplatform} {
1071 set env(HOME) "Root:home"
1073 set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
1076 } {0 Root:home::foo}
1077 test filename-10.14 {Tcl_TranslateFileName} {testsetplatform} {
1080 set env(HOME) "Root:home"
1082 set result [list [catch {testtranslatefilename ~} msg] $msg]
1086 test filename-10.15 {Tcl_TranslateFileName} {testsetplatform} {
1089 set env(HOME) "Root:home:"
1091 set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
1094 } {0 Root:home::foo}
1095 test filename-10.16 {Tcl_TranslateFileName} {testsetplatform} {
1098 set env(HOME) "Root:home::"
1100 set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
1103 } {0 Root:home:::foo}
1104 test filename-10.17 {Tcl_TranslateFileName} {testsetplatform} {
1107 set env(HOME) "\\home\\"
1108 testsetplatform windows
1109 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1113 test filename-10.18 {Tcl_TranslateFileName} {testsetplatform} {
1116 set env(HOME) "\\home\\"
1117 testsetplatform windows
1118 set result [list [catch {testtranslatefilename ~/foo\\bar} msg] $msg]
1121 } {0 {\home\foo\bar}}
1122 test filename-10.19 {Tcl_TranslateFileName} {testsetplatform} {
1126 testsetplatform windows
1127 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1131 test filename-10.20 {Tcl_TranslateFileName} {testtranslatefilename} {
1132 list [catch {testtranslatefilename ~blorp/foo} msg] $msg
1133 } {1 {user "blorp" doesn't exist}}
1134 test filename-10.21 {Tcl_TranslateFileName} {testsetplatform} {
1137 set env(HOME) "c:\\"
1138 testsetplatform windows
1139 set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
1143 test filename-10.22 {Tcl_TranslateFileName} {testsetplatform} {
1144 testsetplatform windows
1145 list [catch {testtranslatefilename foo//bar} msg] $msg
1148 if {[tcltest::testConstraint testsetplatform]} {
1149 testsetplatform $platform
1152 test filename-10.23 {Tcl_TranslateFileName} {unixOnly nonPortable} {
1153 # this test fails if ~ouster is not /home/ouster
1154 list [catch {testtranslatefilename ~ouster} msg] $msg
1156 test filename-10.24 {Tcl_TranslateFileName} {unixOnly nonPortable} {
1157 # this test fails if ~ouster is not /home/ouster
1158 list [catch {testtranslatefilename ~ouster/foo} msg] $msg
1159 } {0 /home/ouster/foo}
1162 test filename-11.1 {Tcl_GlobCmd} {
1163 list [catch {glob} msg] $msg
1164 } {1 {wrong # args: should be "glob ?switches? name ?name ...?"}}
1165 test filename-11.2 {Tcl_GlobCmd} {
1166 list [catch {glob -gorp} msg] $msg
1167 } {1 {bad option "-gorp": must be -directory, -join, -nocomplain, -path, -tails, -types, or --}}
1168 test filename-11.3 {Tcl_GlobCmd} {
1169 list [catch {glob -nocomplai} msg] $msg
1170 } {1 {wrong # args: should be "glob ?switches? name ?name ...?"}}
1171 test filename-11.4 {Tcl_GlobCmd} {
1172 list [catch {glob -nocomplain} msg] $msg
1173 } {1 {wrong # args: should be "glob ?switches? name ?name ...?"}}
1174 test filename-11.5 {Tcl_GlobCmd} {
1175 list [catch {glob -nocomplain ~xyqrszzz} msg] $msg
1177 test filename-11.6 {Tcl_GlobCmd} {
1178 list [catch {glob ~xyqrszzz} msg] $msg
1179 } {1 {user "xyqrszzz" doesn't exist}}
1180 test filename-11.7 {Tcl_GlobCmd} {
1181 list [catch {glob -- -nocomplain} msg] $msg
1182 } {1 {no files matched glob pattern "-nocomplain"}}
1183 test filename-11.8 {Tcl_GlobCmd} {
1184 list [catch {glob -nocomplain -- -nocomplain} msg] $msg
1186 test filename-11.9 {Tcl_GlobCmd} {testsetplatform} {
1187 testsetplatform unix
1188 list [catch {glob ~\\xyqrszzz/bar} msg] $msg
1189 } {1 {user "\xyqrszzz" doesn't exist}}
1190 test filename-11.10 {Tcl_GlobCmd} {testsetplatform} {
1191 testsetplatform unix
1192 list [catch {glob -nocomplain ~\\xyqrszzz/bar} msg] $msg
1194 test filename-11.11 {Tcl_GlobCmd} {testsetplatform} {
1195 testsetplatform unix
1196 list [catch {glob ~xyqrszzz\\/\\bar} msg] $msg
1197 } {1 {user "xyqrszzz" doesn't exist}}
1198 test filename-11.12 {Tcl_GlobCmd} {testsetplatform} {
1199 testsetplatform unix
1202 set x [list [catch {glob ~/*} msg] $msg]
1205 } {1 {couldn't find HOME environment variable to expand path}}
1207 if {[tcltest::testConstraint testsetplatform]} {
1208 testsetplatform $platform
1211 test filename-11.13 {Tcl_GlobCmd} {
1212 list [catch {file join [lindex [glob ~] 0]} msg] $msg
1213 } [list 0 [file join $env(HOME)]]
1216 set oldhome $env(HOME)
1217 cd [temporaryDirectory]
1219 file delete -force globTest
1220 file mkdir globTest/a1/b1
1221 file mkdir globTest/a1/b2
1222 file mkdir globTest/a2/b3
1223 file mkdir globTest/a3
1224 close [open globTest/x1.c w]
1225 close [open globTest/y1.c w]
1226 close [open globTest/z1.c w]
1227 close [open "globTest/weird name.c" w]
1228 close [open globTest/a1/b1/x2.c w]
1229 close [open globTest/a1/b2/y2.c w]
1231 catch {close [open globTest/.1 w]}
1232 catch {close [open globTest/x,z1.c w]}
1234 test filename-11.14 {Tcl_GlobCmd} {
1235 list [catch {glob ~/globTest} msg] $msg
1236 } [list 0 [list [file join $env(HOME) globTest]]]
1237 test filename-11.15 {Tcl_GlobCmd} {
1238 list [catch {glob ~\\/globTest} msg] $msg
1239 } [list 0 [list [file join $env(HOME) globTest]]]
1240 test filename-11.16 {Tcl_GlobCmd} {
1241 list [catch {glob globTest} msg] $msg
1244 set globname "globTest"
1245 set horribleglobname "glob\[\{Test"
1247 test filename-11.17 {Tcl_GlobCmd} {unixOnly} {
1248 list [catch {lsort [glob -directory $globname *]} msg] $msg
1249 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1250 [file join $globname a3]\
1251 [file join $globname "weird name.c"]\
1252 [file join $globname x,z1.c]\
1253 [file join $globname x1.c]\
1254 [file join $globname y1.c] [file join $globname z1.c]]]]
1255 test filename-11.17.1 {Tcl_GlobCmd} {pcOnly macOnly} {
1256 list [catch {lsort [glob -directory $globname *]} msg] $msg
1257 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1258 [file join $globname .1]\
1259 [file join $globname a3]\
1260 [file join $globname "weird name.c"]\
1261 [file join $globname x,z1.c]\
1262 [file join $globname x1.c]\
1263 [file join $globname y1.c] [file join $globname z1.c]]]]
1264 if {[string equal $tcl_platform(platform) "windows"]} {
1265 if {[string index $tcl_platform(osVersion) 0] >= 5 \
1266 && ([lindex [file system [temporaryDirectory]] 1] == "NTFS")} {
1267 tcltest::testConstraint linkDirectory 1
1269 tcltest::testConstraint linkDirectory 0
1271 } elseif {[string equal $tcl_platform(osSystemName) "Symbian"]} {
1272 tcltest::testConstraint linkDirectory 0
1274 tcltest::testConstraint linkDirectory 1
1276 if {[string equal $tcl_platform(platform) "windows"] || [string equal $tcl_platform(osSystemName) "Symbian"]} {
1277 tcltest::testConstraint symbolicLinkFile 0
1279 tcltest::testConstraint symbolicLinkFile 1
1281 test filename-11.17.2 {Tcl_GlobCmd} {notRoot linkDirectory} {
1283 set ret "error in test"
1286 file link -symbolic link a1
1288 set ret [list [catch {
1289 lsort [glob -directory $globname -join * b1]
1294 file delete [file join $globname link]
1296 } [list 0 [lsort [list [file join $globname a1 b1] \
1297 [file join $globname link b1]]]]
1298 # Simpler version of the above test to illustrate a given bug.
1299 test filename-11.17.3 {Tcl_GlobCmd} {notRoot linkDirectory} {
1301 set ret "error in test"
1304 file link -symbolic link a1
1306 set ret [list [catch {
1307 lsort [glob -directory $globname -type d *]
1312 file delete [file join $globname link]
1314 } [list 0 [lsort [list [file join $globname a1] \
1315 [file join $globname a2] \
1316 [file join $globname a3] \
1317 [file join $globname link]]]]
1318 # Make sure the bugfix isn't too simple. We don't want
1319 # to break 'glob -type l'.
1320 test filename-11.17.4 {Tcl_GlobCmd} {notRoot linkDirectory} {
1322 set ret "error in test"
1325 file link -symbolic link a1
1327 set ret [list [catch {
1328 lsort [glob -directory $globname -type l *]
1333 file delete [file join $globname link]
1335 } [list 0 [list [file join $globname link]]]
1336 test filename-11.17.5 {Tcl_GlobCmd} {
1337 list [catch {lsort [glob -directory $globname -tails *.c]} msg] $msg
1338 } [list 0 [lsort [list "weird name.c" x,z1.c x1.c y1.c z1.c]]]
1339 test filename-11.17.6 {Tcl_GlobCmd} {
1340 list [catch {lsort [glob -directory $globname -tails *.c *.c]} msg] $msg
1341 } [list 0 [lsort [concat [list "weird name.c" x,z1.c x1.c y1.c z1.c] \
1342 [list "weird name.c" x,z1.c x1.c y1.c z1.c]]]]
1343 test filename-11.17.7 {Tcl_GlobCmd: broken link and glob -l} {linkDirectory} {
1345 set ret "error in test"
1348 file mkdir nonexistent
1349 file link -symbolic link nonexistent
1350 file delete nonexistent
1352 set ret [list [catch {
1353 lsort [glob -nocomplain -directory $globname -type l *]
1358 file delete [file join $globname link]
1360 } [list 0 [list [file join $globname link]]]
1361 test filename-11.17.8 {Tcl_GlobCmd: broken link and glob -l} {symbolicLinkFile} {
1363 set ret "error in test"
1366 close [open "nonexistent" w]
1367 file link -symbolic link nonexistent
1368 file delete nonexistent
1370 set ret [list [catch {
1371 lsort [glob -nocomplain -directory $globname -type l *]
1376 file delete [file join $globname link]
1378 } [list 0 [list [file join $globname link]]]
1379 test filename-11.18 {Tcl_GlobCmd} {unixOnly} {
1380 list [catch {lsort [glob -path $globname/ *]} msg] $msg
1381 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1382 [file join $globname a3]\
1383 [file join $globname "weird name.c"]\
1384 [file join $globname x,z1.c]\
1385 [file join $globname x1.c]\
1386 [file join $globname y1.c] [file join $globname z1.c]]]]
1387 test filename-11.18.1 {Tcl_GlobCmd} {pcOnly macOnly} {
1388 list [catch {lsort [glob -path $globname/ *]} msg] $msg
1389 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1390 [file join $globname .1]\
1391 [file join $globname a3]\
1392 [file join $globname "weird name.c"]\
1393 [file join $globname x,z1.c]\
1394 [file join $globname x1.c]\
1395 [file join $globname y1.c] [file join $globname z1.c]]]]
1396 test filename-11.19 {Tcl_GlobCmd} {unixOnly} {
1397 list [catch {lsort [glob -join -path \
1398 [string range $globname 0 5] * *]} msg] $msg
1399 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1400 [file join $globname a3]\
1401 [file join $globname "weird name.c"]\
1402 [file join $globname x,z1.c]\
1403 [file join $globname x1.c]\
1404 [file join $globname y1.c] [file join $globname z1.c]]]]
1405 test filename-11.19.1 {Tcl_GlobCmd} {pcOnly macOnly} {
1406 list [catch {lsort [glob -join -path \
1407 [string range $globname 0 5] * *]} msg] $msg
1408 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1409 [file join $globname .1]\
1410 [file join $globname a3]\
1411 [file join $globname "weird name.c"]\
1412 [file join $globname x,z1.c]\
1413 [file join $globname x1.c]\
1414 [file join $globname y1.c] [file join $globname z1.c]]]]
1415 test filename-11.20 {Tcl_GlobCmd} {
1416 list [catch {lsort [glob -type d -dir $globname *]} msg] $msg
1417 } [list 0 [lsort [list [file join $globname a1]\
1418 [file join $globname a2]\
1419 [file join $globname a3]]]]
1420 test filename-11.21 {Tcl_GlobCmd} {
1421 list [catch {lsort [glob -type d -path $globname *]} msg] $msg
1422 } [list 0 [lsort [list $globname]]]
1424 test filename-11.21.1 {Tcl_GlobCmd} {
1425 close [open {[tcl].testremains} w]
1426 set res [list [catch {lsort [glob -path {[tcl]} *]} msg] $msg]
1427 file delete -force {[tcl].testremains}
1429 } [list 0 {{[tcl].testremains}}]
1431 # Get rid of file/dir if it exists, since it will have
1432 # been left behind by a previous failed run.
1433 if {[file exists $horribleglobname]} {
1434 file delete -force $horribleglobname
1436 file rename globTest $horribleglobname
1437 set globname $horribleglobname
1439 test filename-11.22 {Tcl_GlobCmd} {unixOnly} {
1440 list [catch {lsort [glob -dir $globname *]} msg] $msg
1441 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1442 [file join $globname a3]\
1443 [file join $globname "weird name.c"]\
1444 [file join $globname x,z1.c]\
1445 [file join $globname x1.c]\
1446 [file join $globname y1.c] [file join $globname z1.c]]]]
1447 test filename-11.22.1 {Tcl_GlobCmd} {pcOnly macOnly} {
1448 list [catch {lsort [glob -dir $globname *]} msg] $msg
1449 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1450 [file join $globname .1]\
1451 [file join $globname a3]\
1452 [file join $globname "weird name.c"]\
1453 [file join $globname x,z1.c]\
1454 [file join $globname x1.c]\
1455 [file join $globname y1.c] [file join $globname z1.c]]]]
1456 test filename-11.23 {Tcl_GlobCmd} {unixOnly} {
1457 list [catch {lsort [glob -path $globname/ *]} msg] $msg
1458 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1459 [file join $globname a3]\
1460 [file join $globname "weird name.c"]\
1461 [file join $globname x,z1.c]\
1462 [file join $globname x1.c]\
1463 [file join $globname y1.c] [file join $globname z1.c]]]]
1464 test filename-11.23.1 {Tcl_GlobCmd} {pcOnly macOnly} {
1465 list [catch {lsort [glob -path $globname/ *]} msg] $msg
1466 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1467 [file join $globname .1]\
1468 [file join $globname a3]\
1469 [file join $globname "weird name.c"]\
1470 [file join $globname x,z1.c]\
1471 [file join $globname x1.c]\
1472 [file join $globname y1.c] [file join $globname z1.c]]]]
1473 test filename-11.24 {Tcl_GlobCmd} {unixOnly} {
1474 list [catch {lsort [glob -join -path \
1475 [string range $globname 0 5] * *]} msg] $msg
1476 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1477 [file join $globname a3]\
1478 [file join $globname "weird name.c"]\
1479 [file join $globname x,z1.c]\
1480 [file join $globname x1.c]\
1481 [file join $globname y1.c] [file join $globname z1.c]]]]
1482 test filename-11.24.1 {Tcl_GlobCmd} {pcOnly macOnly} {
1483 list [catch {lsort [glob -join -path \
1484 [string range $globname 0 5] * *]} msg] $msg
1485 } [list 0 [lsort [list [file join $globname a1] [file join $globname a2]\
1486 [file join $globname .1]\
1487 [file join $globname a3]\
1488 [file join $globname "weird name.c"]\
1489 [file join $globname x,z1.c]\
1490 [file join $globname x1.c]\
1491 [file join $globname y1.c] [file join $globname z1.c]]]]
1492 test filename-11.25 {Tcl_GlobCmd} {
1493 list [catch {lsort [glob -type d -dir $globname *]} msg] $msg
1494 } [list 0 [lsort [list [file join $globname a1]\
1495 [file join $globname a2]\
1496 [file join $globname a3]]]]
1497 test filename-11.25.1 {Tcl_GlobCmd} {
1498 list [catch {lsort [glob -type {d r} -dir $globname *]} msg] $msg
1499 } [list 0 [lsort [list [file join $globname a1]\
1500 [file join $globname a2]\
1501 [file join $globname a3]]]]
1502 test filename-11.25.2 {Tcl_GlobCmd} {
1503 list [catch {lsort [glob -type {d r w} -dir $globname *]} msg] $msg
1504 } [list 0 [lsort [list [file join $globname a1]\
1505 [file join $globname a2]\
1506 [file join $globname a3]]]]
1507 test filename-11.26 {Tcl_GlobCmd} {
1508 list [catch {glob -type d -path $globname *} msg] $msg
1509 } [list 0 [list $globname]]
1510 test filename-11.27 {Tcl_GlobCmd} {
1511 list [catch {glob -types abcde *} msg] $msg
1512 } {1 {bad argument to "-types": abcde}}
1513 test filename-11.28 {Tcl_GlobCmd} {
1514 list [catch {glob -types z *} msg] $msg
1515 } {1 {bad argument to "-types": z}}
1516 test filename-11.29 {Tcl_GlobCmd} {
1517 list [catch {glob -types {abcd efgh} *} msg] $msg
1518 } {1 {only one MacOS type or creator argument to "-types" allowed}}
1519 test filename-11.30 {Tcl_GlobCmd} {
1520 list [catch {glob -types {{macintosh type TEXT} \
1521 {macintosh creator ALFA} efgh} *} msg] $msg
1522 } {1 {only one MacOS type or creator argument to "-types" allowed}}
1523 test filename-11.31 {Tcl_GlobCmd} {
1524 list [catch {glob -types} msg] $msg
1525 } {1 {missing argument to "-types"}}
1526 test filename-11.32 {Tcl_GlobCmd} {
1527 list [catch {glob -path hello -dir hello *} msg] $msg
1528 } {1 {"-directory" cannot be used with "-path"}}
1529 test filename-11.33 {Tcl_GlobCmd} {
1530 list [catch {glob -path} msg] $msg
1531 } {1 {missing argument to "-path"}}
1532 test filename-11.34 {Tcl_GlobCmd} {
1533 list [catch {glob -direct} msg] $msg
1534 } {1 {missing argument to "-directory"}}
1535 test filename-11.35 {Tcl_GlobCmd} {
1536 list [catch {glob -paths *} msg] $msg
1537 } {1 {bad option "-paths": must be -directory, -join, -nocomplain, -path, -tails, -types, or --}}
1538 # Test '-tails' flag to glob.
1539 test filename-11.36 {Tcl_GlobCmd} {
1540 list [catch {glob -tails *} msg] $msg
1541 } {1 {"-tails" must be used with either "-directory" or "-path"}}
1542 test filename-11.37 {Tcl_GlobCmd} {
1543 list [catch {glob -type d -tails -path $globname *} msg] $msg
1544 } [list 0 [list $globname]]
1545 test filename-11.38 {Tcl_GlobCmd} {
1546 list [catch {glob -tails -path $globname *} msg] $msg
1547 } [list 0 [list $globname]]
1548 test filename-11.39 {Tcl_GlobCmd} {
1549 list [catch {glob -tails -join -path $globname *} msg] $msg
1550 } [list 0 [list $globname]]
1551 test filename-11.40 {Tcl_GlobCmd} {
1552 expr {[glob -dir [pwd] -tails *] == [glob *]}
1554 test filename-11.41 {Tcl_GlobCmd} {
1555 expr {[glob -dir [pwd] -tails *] != [glob -dir [pwd] *]}
1557 test filename-11.42 {Tcl_GlobCmd} {
1559 foreach f [glob -dir [pwd] *] {
1560 lappend res [file tail $f]
1562 expr {$res == [glob *]}
1564 test filename-11.43 {Tcl_GlobCmd} {
1565 list [catch {glob -t *} msg] $msg
1566 } {1 {ambiguous option "-t": must be -directory, -join, -nocomplain, -path, -tails, -types, or --}}
1567 test filename-11.44 {Tcl_GlobCmd} {
1568 list [catch {glob -tails -path hello -directory hello *} msg] $msg
1569 } {1 {"-directory" cannot be used with "-path"}}
1570 test filename-11.45 {Tcl_GlobCmd on root volume} {
1574 set res1 [glob -dir [lindex [file volumes] 0] -tails *]
1578 cd [lindex [file volumes] 0]
1582 expr {$res1 == $res2}
1584 test filename-11.46 {Tcl_GlobCmd} {
1585 list [catch {glob -types abcde -dir foo *} msg] $msg
1586 } {1 {bad argument to "-types": abcde}}
1587 test filename-11.47 {Tcl_GlobCmd} {
1588 list [catch {glob -types abcde -path foo *} msg] $msg
1589 } {1 {bad argument to "-types": abcde}}
1590 test filename-11.48 {Tcl_GlobCmd} {
1591 list [catch {glob -types abcde -dir foo -join * *} msg] $msg
1592 } {1 {bad argument to "-types": abcde}}
1593 test filename-11.49 {Tcl_GlobCmd} {
1594 list [catch {glob -types abcde -path foo -join * *} msg] $msg
1595 } {1 {bad argument to "-types": abcde}}
1597 file rename $horribleglobname globTest
1598 set globname globTest
1599 unset horribleglobname
1601 test filename-12.1 {simple globbing} {unixOrPc} {
1602 list [catch {glob {}} msg] $msg
1604 test filename-12.1.1 {simple globbing} {unixOrPc} {
1605 list [catch {glob -types f {}} msg] $msg
1606 } {1 {no files matched glob pattern ""}}
1607 test filename-12.1.2 {simple globbing} {unixOrPc} {
1608 list [catch {glob -types d {}} msg] $msg
1610 test filename-12.1.3 {simple globbing} {unixOnly} {
1611 list [catch {glob -types hidden {}} msg] $msg
1613 test filename-12.1.4 {simple globbing} {pcOnly} {
1614 list [catch {glob -types hidden {}} msg] $msg
1615 } {1 {no files matched glob pattern ""}}
1616 test filename-12.1.5 {simple globbing} {pcOnly} {
1617 list [catch {glob -types hidden c:/} msg] $msg
1618 } {1 {no files matched glob pattern "c:/"}}
1619 test filename-12.1.6 {simple globbing} {pcOnly} {
1620 list [catch {glob c:/} msg] $msg
1622 test filename-12.2 {simple globbing} {macOnly} {
1623 list [catch {glob {}} msg] $msg
1625 test filename-12.2.1 {simple globbing} {macOnly} {
1626 list [catch {glob -types f {}} msg] $msg
1627 } {1 {no files matched glob pattern ""}}
1628 test filename-12.2.2 {simple globbing} {macOnly} {
1629 list [catch {glob -types d {}} msg] $msg
1631 test filename-12.2.3 {simple globbing} {macOnly} {
1632 list [catch {glob -types hidden {}} msg] $msg
1633 } {1 {no files matched glob pattern ""}}
1634 test filename-12.3 {simple globbing} {
1635 list [catch {glob -nocomplain \{a1,a2\}} msg] $msg
1638 if {$tcl_platform(platform) == "macintosh"} {
1639 set globPreResult :globTest:
1641 set globPreResult globTest/
1645 test filename-12.4 {simple globbing} {unixOrPc} {
1646 lsort [glob globTest/x1.c globTest/y1.c globTest/foo]
1647 } "$globPreResult$x1 $globPreResult$y1"
1648 test filename-12.5 {simple globbing} {
1649 list [catch {glob globTest\\/x1.c} msg] $msg
1650 } "0 $globPreResult$x1"
1651 test filename-12.6 {simple globbing} {
1652 list [catch {glob globTest\\/\\x1.c} msg] $msg
1653 } "0 $globPreResult$x1"
1654 test filename-12.7 {globbing at filesystem root} {unixOnly} {
1655 set res1 [glob -nocomplain /*]
1656 set res2 [glob -path / *]
1657 set equal [string equal $res1 $res2]
1659 lappend equal "not equal" $res1 $res2
1663 test filename-12.8 {globbing at filesystem root} {unixOnly} {
1664 set dir [lindex [glob -type d /*] 0]
1665 set first [string range $dir 0 1]
1666 set res1 [glob -nocomplain ${first}*]
1667 set res2 [glob -path $first *]
1668 set equal [string equal $res1 $res2]
1670 lappend equal "not equal" $res1 $res2
1674 test filename-12.9 {globbing at filesystem root} {winOnly} {
1675 # Can't grab just anything from 'file volumes' because we need a dir
1676 # that has subdirs - assume that C:/ exists across Windows machines.
1677 set dir [lindex [glob -type d C:/*] 0]
1678 set first [string range $dir 0 3]
1679 set res1 [glob -nocomplain ${first}*]
1680 set res2 [glob -path $first *]
1681 set equal [string equal $res1 $res2]
1683 lappend equal "not equal" $res1 $res2
1688 test filename-13.1 {globbing with brace substitution} {
1689 list [catch {glob globTest/\{\}} msg] $msg
1690 } "0 $globPreResult"
1691 test filename-13.2 {globbing with brace substitution} {
1692 list [catch {glob globTest/\{} msg] $msg
1693 } {1 {unmatched open-brace in file name}}
1694 test filename-13.3 {globbing with brace substitution} {
1695 list [catch {glob globTest/\{\\\}} msg] $msg
1696 } {1 {unmatched open-brace in file name}}
1697 test filename-13.4 {globbing with brace substitution} {
1698 list [catch {glob globTest/\{\\} msg] $msg
1699 } {1 {unmatched open-brace in file name}}
1700 test filename-13.5 {globbing with brace substitution} {
1701 list [catch {glob globTest/\}} msg] $msg
1702 } {1 {unmatched close-brace in file name}}
1703 test filename-13.6 {globbing with brace substitution} {
1704 list [catch {glob globTest/\{\}x1.c} msg] $msg
1705 } "0 $globPreResult$x1"
1706 test filename-13.7 {globbing with brace substitution} {
1707 list [catch {glob globTest/\{x\}1.c} msg] $msg
1708 } "0 $globPreResult$x1"
1709 test filename-13.8 {globbing with brace substitution} {
1710 list [catch {glob globTest/\{x\{\}\}1.c} msg] $msg
1711 } "0 $globPreResult$x1"
1712 test filename-13.9 {globbing with brace substitution} {
1713 list [lsort [catch {glob globTest/\{x,y\}1.c} msg]] $msg
1714 } [list 0 [list $globPreResult$x1 $globPreResult$y1]]
1715 test filename-13.10 {globbing with brace substitution} {
1716 list [lsort [catch {glob globTest/\{x,,y\}1.c} msg]] $msg
1717 } [list 0 [list $globPreResult$x1 $globPreResult$y1]]
1718 test filename-13.11 {globbing with brace substitution} {unixOrPc} {
1719 list [lsort [catch {glob globTest/\{x,x\\,z,z\}1.c} msg]] $msg
1720 } {0 {globTest/x1.c globTest/x,z1.c globTest/z1.c}}
1721 test filename-13.12 {globbing with brace substitution} {macOnly} {
1722 list [lsort [catch {glob globTest/\{x,x\\,z,z\}1.c} msg]] $msg
1723 } {0 {:globTest:x1.c :globTest:x,z1.c :globTest:z1.c}}
1724 test filename-13.13 {globbing with brace substitution} {
1725 lsort [glob globTest/{a,b,x,y}1.c]
1726 } [list $globPreResult$x1 $globPreResult$y1]
1727 test filename-13.14 {globbing with brace substitution} {unixOrPc} {
1728 lsort [glob {globTest/{x1,y2,weird name}.c}]
1729 } {{globTest/weird name.c} globTest/x1.c}
1730 test filename-13.15 {globbing with brace substitution} {macOnly} {
1731 lsort [glob {globTest/{x1,y2,weird name}.c}]
1732 } {{:globTest:weird name.c} :globTest:x1.c}
1733 test filename-13.16 {globbing with brace substitution} {unixOrPc} {
1734 lsort [glob globTest/{x1.c,a1/*}]
1735 } {globTest/a1/b1 globTest/a1/b2 globTest/x1.c}
1736 test filename-13.17 {globbing with brace substitution} {macOnly} {
1737 lsort [glob globTest/{x1.c,a1/*}]
1738 } {:globTest:a1:b1 :globTest:a1:b2 :globTest:x1.c}
1739 test filename-13.18 {globbing with brace substitution} {unixOrPc} {
1740 lsort [glob globTest/{x1.c,{a},a1/*}]
1741 } {globTest/a1/b1 globTest/a1/b2 globTest/x1.c}
1742 test filename-13.19 {globbing with brace substitution} {macOnly} {
1743 lsort [glob globTest/{x1.c,{a},a1/*}]
1744 } {:globTest:a1:b1 :globTest:a1:b2 :globTest:x1.c}
1745 test filename-13.20 {globbing with brace substitution} {unixOrPc} {
1746 lsort [glob globTest/{a,x}1/*/{x,y}*]
1747 } {globTest/a1/b1/x2.c globTest/a1/b2/y2.c}
1748 test filename-13.21 {globbing with brace substitution} {macOnly} {
1749 lsort [glob globTest/{a,x}1/*/{x,y}*]
1750 } {:globTest:a1:b1:x2.c :globTest:a1:b2:y2.c}
1751 test filename-13.22 {globbing with brace substitution} {
1752 list [catch {glob globTest/\{a,x\}1/*/\{} msg] $msg
1753 } {1 {unmatched open-brace in file name}}
1755 test filename-14.1 {asterisks, question marks, and brackets} {unixOrPc} {
1756 lsort [glob glo*/*.c]
1757 } {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}
1758 test filename-14.2 {asterisks, question marks, and brackets} {macOnly} {
1759 lsort [glob glo*/*.c]
1760 } {{:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}
1761 test filename-14.3 {asterisks, question marks, and brackets} {unixOrPc} {
1762 lsort [glob globTest/?1.c]
1763 } {globTest/x1.c globTest/y1.c globTest/z1.c}
1764 test filename-14.4 {asterisks, question marks, and brackets} {macOnly} {
1765 lsort [glob globTest/?1.c]
1766 } {:globTest:x1.c :globTest:y1.c :globTest:z1.c}
1768 # The current directory could be anywhere; do this to stop spurious matches
1769 file mkdir globTestContext
1770 file rename globTest [file join globTestContext globTest]
1774 test filename-14.5 {asterisks, question marks, and brackets} {unixOrPc} {
1775 lsort [glob */*/*/*.c]
1776 } {globTest/a1/b1/x2.c globTest/a1/b2/y2.c}
1777 test filename-14.6 {asterisks, question marks, and brackets} {macOnly} {
1778 lsort [glob */*/*/*.c]
1779 } {:globTest:a1:b1:x2.c :globTest:a1:b2:y2.c}
1781 # Reset to where we were
1783 file rename [file join globTestContext globTest] globTest
1784 file delete globTestContext
1786 test filename-14.7 {asterisks, question marks, and brackets} {unixOnly} {
1787 lsort [glob globTest/*]
1788 } {globTest/a1 globTest/a2 globTest/a3 {globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}
1789 test filename-14.7.1 {asterisks, question marks, and brackets} {pcOnly} {
1790 lsort [glob globTest/*]
1791 } {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}
1792 test filename-14.8 {asterisks, question marks, and brackets} {macOnly} {
1793 lsort [glob globTest/*]
1794 } {: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}
1795 test filename-14.9.1 {asterisks, question marks, and brackets} {unixOrPc tempNotSymbian} {
1796 lsort [glob globTest/.*]
1797 } {globTest/. globTest/.. globTest/.1}
1798 test filename-14.9.2 {asterisks, question marks, and brackets} {symbianOnly} {
1799 lsort [glob globTest/.*]
1801 test filename-14.10 {asterisks, question marks, and brackets} {macOnly} {
1802 lsort [glob globTest/.*]
1804 test filename-14.11 {asterisks, question marks, and brackets} {unixOrPc} {
1805 lsort [glob globTest/*/*]
1806 } {globTest/a1/b1 globTest/a1/b2 globTest/a2/b3}
1807 test filename-14.12 {asterisks, question marks, and brackets} {macOnly} {
1808 lsort [glob globTest/*/*]
1809 } {:globTest:a1:b1 :globTest:a1:b2 :globTest:a2:b3}
1810 test filename-14.13 {asterisks, question marks, and brackets} {unixOrPc} {
1811 lsort [glob {globTest/[xyab]1.*}]
1812 } {globTest/x1.c globTest/y1.c}
1813 test filename-14.14 {asterisks, question marks, and brackets} {macOnly} {
1814 lsort [glob {globTest/[xyab]1.*}]
1815 } {:globTest:x1.c :globTest:y1.c}
1816 test filename-14.15 {asterisks, question marks, and brackets} {unixOrPc} {
1817 lsort [glob globTest/*/]
1818 } {globTest/a1/ globTest/a2/ globTest/a3/}
1819 test filename-14.16 {asterisks, question marks, and brackets} {macOnly} {
1820 lsort [glob globTest/*/]
1821 } {:globTest:a1: :globTest:a2: :globTest:a3:}
1822 test filename-14.17 {asterisks, question marks, and brackets} {
1825 set env(HOME) [file join $env(HOME) globTest]
1826 set result [list [catch {glob ~/z*} msg] $msg]
1829 } [list 0 [list [file join $env(HOME) globTest z1.c]]]
1830 test filename-14.18 {asterisks, question marks, and brackets} {unixOrPc} {
1831 list [catch {lsort [glob globTest/*.c goo/*]} msg] $msg
1832 } {0 {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}}
1833 test filename-14.19 {asterisks, question marks, and brackets} {macOnly} {
1834 list [catch {lsort [glob globTest/*.c goo/*]} msg] $msg
1835 } {0 {{:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}}
1836 test filename-14.20 {asterisks, question marks, and brackets} {
1837 list [catch {glob -nocomplain goo/*} msg] $msg
1839 test filename-14.21 {asterisks, question marks, and brackets} {
1840 list [catch {glob globTest/*/gorp} msg] $msg
1841 } {1 {no files matched glob pattern "globTest/*/gorp"}}
1842 test filename-14.22 {asterisks, question marks, and brackets} {
1843 list [catch {glob goo/* x*z foo?q} msg] $msg
1844 } {1 {no files matched glob patterns "goo/* x*z foo?q"}}
1845 test filename-14.23 {slash globbing} {unixOrPc} {
1848 test filename-14.24 {slash globbing} {pcOnly} {
1851 test filename-14.25 {type specific globbing} {unixOnly} {
1852 list [catch {lsort [glob -dir globTest -types f *]} msg] $msg
1853 } [list 0 [lsort [list \
1854 [file join $globname "weird name.c"]\
1855 [file join $globname x,z1.c]\
1856 [file join $globname x1.c]\
1857 [file join $globname y1.c] [file join $globname z1.c]]]]
1858 test filename-14.25.1 {type specific globbing} {pcOnly macOnly} {
1859 list [catch {lsort [glob -dir globTest -types f *]} msg] $msg
1860 } [list 0 [lsort [list \
1861 [file join $globname .1]\
1862 [file join $globname "weird name.c"]\
1863 [file join $globname x,z1.c]\
1864 [file join $globname x1.c]\
1865 [file join $globname y1.c] [file join $globname z1.c]]]]
1866 test filename-14.26 {type specific globbing} {
1867 list [catch {glob -nocomplain -dir globTest -types {readonly} *} msg] $msg
1872 # The following tests are only valid for Unix systems.
1873 # On some systems, like AFS, "000" protection doesn't prevent
1874 # access by owner, so the following test is not portable.
1876 catch {file attributes globTest/a1 -permissions 0000}
1877 test filename-15.1 {unix specific globbing} {unixOnly nonPortable} {
1878 string tolower [list [catch {glob globTest/a1/*} msg] $msg $errorCode]
1879 } {1 {couldn't read directory "globtest/a1": permission denied} {posix eacces {permission denied}}}
1880 test filename-15.2 {unix specific no complain: no errors} {unixOnly nonPortable} {
1881 glob -nocomplain globTest/a1/*
1883 test filename-15.3 {unix specific no complain: no errors, good result} \
1884 {unixOnly nonPortable} {
1885 # test fails because if an error occur , the interp's result
1887 glob -nocomplain globTest/a2 globTest/a1/* globTest/a3
1888 } {globTest/a2 globTest/a3}
1890 catch {file attributes globTest/a1 -permissions 0755}
1891 test filename-15.4 {unix specific no complain: no errors, good result} \
1892 {unixOnly nonPortable} {
1893 # test fails because if an error occurs, the interp's result
1894 # is reset... or you don't run at scriptics where the
1895 # outser and welch users exists
1896 glob -nocomplain ~ouster ~foo ~welch
1897 } {/home/ouster /home/welch}
1898 test filename-15.4.1 {no complain: no errors, good result} {
1899 # test used to fail because if an error occurs, the interp's result
1901 string equal [glob -nocomplain ~wontexist ~blah ~] \
1902 [glob -nocomplain ~ ~blah ~wontexist]
1904 test filename-15.5 {unix specific globbing} {unixOnly nonPortable} {
1906 } "/home/ouster/.cshrc"
1907 catch {close [open globTest/odd\\\[\]*?\{\}name w]}
1908 test filename-15.6 {unix specific globbing} {unixOnly tempNotSymbian} {
1911 set env(HOME) $env(HOME)/globTest/odd\\\[\]*?\{\}name
1912 set result [list [catch {glob ~} msg] $msg]
1915 } [list 0 [list [lindex [glob ~] 0]/globTest/odd\\\[\]*?\{\}name]]
1916 catch {file delete -force globTest/odd\\\[\]*?\{\}name}
1918 # The following tests are only valid for Windows systems.
1920 if {$::tcltest::testConstraints(pcOnly)} {
1922 file delete -force globTest
1924 close [open globTest/x1.BAT w]
1925 close [open globTest/y1.Bat w]
1926 close [open globTest/z1.bat w]
1929 test filename-16.1 {windows specific globbing} {pcOnly} {
1930 lsort [glob globTest/*.bat]
1931 } {globTest/x1.BAT globTest/y1.Bat globTest/z1.bat}
1932 test filename-16.2 {windows specific globbing} {pcOnly} {
1935 test filename-16.3 {windows specific globbing} {pcOnly} {
1938 test filename-16.4 {windows specific globbing} {pcOnly} {
1941 test filename-16.5 {windows specific globbing} {pcOnly} {
1944 test filename-16.6 {windows specific globbing} {pcOnly} {
1947 test filename-16.7 {windows specific globbing} {pcOnly} {
1950 test filename-16.8 {windows specific globbing} {pcOnly} {
1951 lsort [glob c:globTest/*.bat]
1952 } {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat}
1953 test filename-16.9 {windows specific globbing} {pcOnly} {
1954 lsort [glob c:/globTest/*.bat]
1955 } {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat}
1956 test filename-16.10 {windows specific globbing} {pcOnly} {
1957 lsort [glob c:globTest\\\\*.bat]
1958 } {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat}
1959 test filename-16.11 {windows specific globbing} {pcOnly} {
1960 lsort [glob c:\\\\globTest\\\\*.bat]
1961 } {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat}
1963 # some tests require a shared C drive
1965 if {[catch {cd //[info hostname]/c}]} {
1966 set ::tcltest::testConstraints(sharedCdrive) 0
1968 set ::tcltest::testConstraints(sharedCdrive) 1
1971 test filename-16.12 {windows specific globbing} {pcOnly sharedCdrive} {
1972 cd //[info hostname]/c
1973 glob //[info hostname]/c/*Test
1974 } //[info hostname]/c/globTest
1975 test filename-16.13 {windows specific globbing} {pcOnly sharedCdrive} {
1976 cd //[info hostname]/c
1977 glob "\\\\\\\\[info hostname]\\\\c\\\\*Test"
1978 } //[info hostname]/c/globTest
1979 test filename-16.14 {windows specific globbing} {pcOnly} {
1980 cd [lindex [glob -types d -dir C:/ *] 0]
1981 expr {[lsearch -exact [glob {{.,*}*}] ".."] != -1}
1983 test filename-16.15 {windows specific globbing} {pcOnly} {
1984 cd [lindex [glob -types d -dir C:/ *] 0]
1987 test filename-16.16 {windows specific globbing} {pcOnly} {
1988 file tail [lindex [glob "[lindex [glob -types d -dir C:/ *] 0]/.."] 0]
1991 test filename-17.1 {windows specific special files} {testsetplatform} {
1993 list [file pathtype com1] [file pathtype con] [file pathtype lpt3] \
1994 [file pathtype prn] [file pathtype nul] [file pathtype aux] \
1996 } {absolute absolute absolute absolute absolute absolute relative}
1998 test filename-17.2 {windows specific glob with executable} {winOnly} {
1999 makeDirectory execglob
2000 makeFile contents execglob/abc.exe
2001 makeFile contents execglob/abc.notexecutable
2002 set res [glob -nocomplain -dir [temporaryDirectory]/execglob \
2004 removeFile execglob/abc.exe
2005 removeFile execglob/abc.notexecutable
2006 removeDirectory execglob
2010 test fileName-18.1 {windows - split ADS name correctly} {winOnly} {
2012 set x [file split c:/c:d]
2013 set y [eval [linsert $x 0 file join]]
2015 } {{c:/ ./c:d} c:/c:d}
2018 catch {file delete -force C:/globTest}
2019 cd [temporaryDirectory]
2020 file delete -force globTest
2022 set env(HOME) $oldhome
2023 if {[tcltest::testConstraint testsetplatform]} {
2024 testsetplatform $platform
2025 catch {unset platform}
2027 catch {unset oldhome temp result globPreResult}
2028 ::tcltest::cleanupTests