os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/fileName.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 # This file tests the filename manipulation routines.
     2 #
     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.
     6 #
     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.  
    10 #
    11 # See the file "license.terms" for information on usage and redistribution
    12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    13 #
    14 # RCS: @(#) $Id: fileName.test,v 1.30.2.7 2005/06/21 19:07:58 kennykb Exp $
    15 
    16 if {[lsearch [namespace children] ::tcltest] == -1} {
    17     package require tcltest
    18     namespace import -force ::tcltest::*
    19 }
    20 
    21 tcltest::testConstraint testsetplatform [string equal testsetplatform [info commands testsetplatform]]
    22 tcltest::testConstraint testtranslatefilename [string equal testtranslatefilename [info commands testtranslatefilename]]
    23 
    24 global env
    25 if {[tcltest::testConstraint testsetplatform]} {
    26     set platform [testgetplatform]
    27 }
    28 
    29 test filename-1.1 {Tcl_GetPathType: unix} {testsetplatform} {
    30     testsetplatform unix
    31     file pathtype /
    32 } absolute
    33 test filename-1.2 {Tcl_GetPathType: unix} {testsetplatform} {
    34     testsetplatform unix
    35     file pathtype /foo
    36 } absolute
    37 test filename-1.3 {Tcl_GetPathType: unix} {testsetplatform} {
    38     testsetplatform unix
    39     file pathtype foo
    40 } relative
    41 test filename-1.4 {Tcl_GetPathType: unix} {testsetplatform} {
    42     testsetplatform unix
    43     file pathtype c:/foo
    44 } relative
    45 test filename-1.5 {Tcl_GetPathType: unix} {testsetplatform} {
    46     testsetplatform unix
    47     file pathtype ~
    48 } absolute
    49 test filename-1.6 {Tcl_GetPathType: unix} {testsetplatform} {
    50     testsetplatform unix
    51     file pathtype ~/foo
    52 } absolute
    53 test filename-1.7 {Tcl_GetPathType: unix} {testsetplatform} {
    54     testsetplatform unix
    55     file pathtype ~foo
    56 } absolute
    57 test filename-1.8 {Tcl_GetPathType: unix} {testsetplatform} {
    58     testsetplatform unix
    59     file pathtype ./~foo
    60 } relative
    61 
    62 test filename-2.1 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
    63     testsetplatform mac
    64     file pathtype /
    65 } relative
    66 test filename-2.2 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
    67     testsetplatform mac
    68     file pathtype /.
    69 } relative
    70 test filename-2.3 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
    71     testsetplatform mac
    72     file pathtype /..
    73 } relative
    74 test filename-2.4 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
    75     testsetplatform mac
    76     file pathtype //.//
    77 } relative
    78 test filename-2.5 {Tcl_GetPathType: mac, denerate names} {testsetplatform} {
    79     testsetplatform mac
    80     file pathtype //.//../.
    81 } relative
    82 test filename-2.6 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
    83     testsetplatform mac
    84     file pathtype ~
    85 } absolute
    86 test filename-2.7 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
    87     testsetplatform mac
    88     file pathtype ~:
    89 } absolute
    90 test filename-2.8 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
    91     testsetplatform mac
    92     file pathtype ~:foo
    93 } absolute
    94 test filename-2.9 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
    95     testsetplatform mac
    96     file pathtype ~/
    97 } absolute
    98 test filename-2.10 {Tcl_GetPathType: mac, tilde names} {testsetplatform} {
    99     testsetplatform mac
   100     file pathtype ~/foo
   101 } absolute
   102 test filename-2.11 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
   103     testsetplatform mac
   104     file pathtype /foo
   105 } absolute
   106 test filename-2.12 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
   107     testsetplatform mac
   108     file pathtype /./foo
   109 } absolute
   110 test filename-2.13 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
   111     testsetplatform mac
   112     file pathtype /..//./foo
   113 } absolute
   114 test filename-2.14 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
   115     testsetplatform mac
   116     file pathtype /foo/bar
   117 } absolute
   118 test filename-2.15 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} {
   119     testsetplatform mac
   120     file pathtype foo/bar
   121 } relative
   122 test filename-2.16 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   123     testsetplatform mac
   124     file pathtype :
   125 } relative
   126 test filename-2.17 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   127     testsetplatform mac
   128     file pathtype :foo
   129 } relative
   130 test filename-2.18 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   131     testsetplatform mac
   132     file pathtype foo:
   133 } absolute
   134 test filename-2.19 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   135     testsetplatform mac
   136     file pathtype foo:bar
   137 } absolute
   138 test filename-2.20 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   139     testsetplatform mac
   140     file pathtype :foo:bar
   141 } relative
   142 test filename-2.21 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   143     testsetplatform mac
   144     file pathtype ::foo:bar
   145 } relative
   146 test filename-2.22 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   147     testsetplatform mac
   148     file pathtype ~foo
   149 } absolute
   150 test filename-2.23 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   151     testsetplatform mac
   152     file pathtype :~foo
   153 } relative
   154 test filename-2.24 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   155     testsetplatform mac
   156     file pathtype ~foo:
   157 } absolute
   158 test filename-2.25 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   159     testsetplatform mac
   160     file pathtype foo/bar:
   161 } absolute
   162 test filename-2.26 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   163     testsetplatform mac
   164     file pathtype /foo:
   165 } absolute
   166 test filename-2.27 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} {
   167     testsetplatform mac
   168     file pathtype foo
   169 } relative
   170 
   171 test filename-3.1 {Tcl_GetPathType: windows} {testsetplatform} {
   172     testsetplatform windows
   173     file pathtype /
   174 } volumerelative
   175 test filename-3.2 {Tcl_GetPathType: windows} {testsetplatform} {
   176     testsetplatform windows
   177     file pathtype \\
   178 } volumerelative
   179 test filename-3.3 {Tcl_GetPathType: windows} {testsetplatform} {
   180     testsetplatform windows
   181     file pathtype /foo
   182 } volumerelative
   183 test filename-3.4 {Tcl_GetPathType: windows} {testsetplatform} {
   184     testsetplatform windows
   185     file pathtype \\foo
   186 } volumerelative
   187 test filename-3.5 {Tcl_GetPathType: windows} {testsetplatform} {
   188     testsetplatform windows
   189     file pathtype c:/
   190 } absolute
   191 test filename-3.6 {Tcl_GetPathType: windows} {testsetplatform} {
   192     testsetplatform windows
   193     file pathtype c:\\
   194 } absolute
   195 test filename-3.7 {Tcl_GetPathType: windows} {testsetplatform} {
   196     testsetplatform windows
   197     file pathtype c:/foo
   198 } absolute
   199 test filename-3.8 {Tcl_GetPathType: windows} {testsetplatform} {
   200     testsetplatform windows
   201     file pathtype c:\\foo
   202 } absolute
   203 test filename-3.9 {Tcl_GetPathType: windows} {testsetplatform} {
   204     testsetplatform windows
   205     file pathtype c:
   206 } volumerelative
   207 test filename-3.10 {Tcl_GetPathType: windows} {testsetplatform} {
   208     testsetplatform windows
   209     file pathtype c:foo
   210 } volumerelative
   211 test filename-3.11 {Tcl_GetPathType: windows} {testsetplatform} {
   212     testsetplatform windows
   213     file pathtype foo
   214 } relative
   215 test filename-3.12 {Tcl_GetPathType: windows} {testsetplatform} {
   216     testsetplatform windows
   217     file pathtype //foo/bar
   218 } absolute
   219 test filename-3.13 {Tcl_GetPathType: windows} {testsetplatform} {
   220     testsetplatform windows
   221     file pathtype ~foo
   222 } absolute
   223 test filename-3.14 {Tcl_GetPathType: windows} {testsetplatform} {
   224     testsetplatform windows
   225     file pathtype ~
   226 } absolute
   227 test filename-3.15 {Tcl_GetPathType: windows} {testsetplatform} {
   228     testsetplatform windows
   229     file pathtype ~/foo
   230 } absolute
   231 test filename-3.16 {Tcl_GetPathType: windows} {testsetplatform} {
   232     testsetplatform windows
   233     file pathtype ./~foo
   234 } relative
   235 
   236 test filename-4.1 {Tcl_SplitPath: unix} {testsetplatform} {
   237     testsetplatform unix
   238     file split /
   239 } {/}
   240 test filename-4.2 {Tcl_SplitPath: unix} {testsetplatform} {
   241     testsetplatform unix
   242     file split /foo
   243 } {/ foo}
   244 test filename-4.3 {Tcl_SplitPath: unix} {testsetplatform} {
   245     testsetplatform unix
   246     file split /foo/bar
   247 } {/ foo bar}
   248 test filename-4.4 {Tcl_SplitPath: unix} {testsetplatform} {
   249     testsetplatform unix
   250     file split /foo/bar/baz
   251 } {/ foo bar baz}
   252 test filename-4.5 {Tcl_SplitPath: unix} {testsetplatform} {
   253     testsetplatform unix
   254     file split foo/bar
   255 } {foo bar}
   256 test filename-4.6 {Tcl_SplitPath: unix} {testsetplatform} {
   257     testsetplatform unix
   258     file split ./foo/bar
   259 } {. foo bar}
   260 test filename-4.7 {Tcl_SplitPath: unix} {testsetplatform} {
   261     testsetplatform unix
   262     file split /foo/../././foo/bar
   263 } {/ foo .. . . foo bar}
   264 test filename-4.8 {Tcl_SplitPath: unix} {testsetplatform} {
   265     testsetplatform unix
   266     file split ../foo/bar
   267 } {.. foo bar}
   268 test filename-4.9 {Tcl_SplitPath: unix} {testsetplatform} {
   269     testsetplatform unix
   270     file split {}
   271 } {}
   272 test filename-4.10 {Tcl_SplitPath: unix} {testsetplatform} {
   273     testsetplatform unix
   274     file split .
   275 } {.}
   276 test filename-4.11 {Tcl_SplitPath: unix} {testsetplatform} {
   277     testsetplatform unix
   278     file split ../
   279 } {..}
   280 test filename-4.12 {Tcl_SplitPath: unix} {testsetplatform} {
   281     testsetplatform unix
   282     file split ../..
   283 } {.. ..}
   284 test filename-4.13 {Tcl_SplitPath: unix} {testsetplatform} {
   285     testsetplatform unix
   286     file split //foo
   287 } {/ foo}
   288 test filename-4.14 {Tcl_SplitPath: unix} {testsetplatform} {
   289     testsetplatform unix
   290     file split foo//bar
   291 } {foo bar}
   292 test filename-4.15 {Tcl_SplitPath: unix} {testsetplatform} {
   293     testsetplatform unix
   294     file split ~foo
   295 } {~foo}
   296 test filename-4.16 {Tcl_SplitPath: unix} {testsetplatform} {
   297     testsetplatform unix
   298     file split ~foo/~bar
   299 } {~foo ./~bar}
   300 test filename-4.17 {Tcl_SplitPath: unix} {testsetplatform} {
   301     testsetplatform unix
   302     file split ~foo/~bar/~baz
   303 } {~foo ./~bar ./~baz}
   304 test filename-4.18 {Tcl_SplitPath: unix} {testsetplatform} {
   305     testsetplatform unix
   306     file split foo/bar~/baz
   307 } {foo bar~ baz}
   308 
   309 if {[tcltest::testConstraint testsetplatform]} {
   310     testsetplatform $platform
   311 }
   312 
   313 test filename-4.19 {Tcl_SplitPath} {
   314     set oldDir [pwd]
   315     set res [catch {
   316 	cd [temporaryDirectory]
   317 	file mkdir tildetmp
   318 	set nastydir [file join tildetmp ./~tilde]
   319 	file mkdir $nastydir
   320 	set norm [file normalize $nastydir]
   321 	cd tildetmp
   322 	cd ./~tilde
   323 	glob -nocomplain *
   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
   330 	cd $oldDir
   331 	file delete -force $nastydir
   332 	set norm
   333     } err]
   334     cd $oldDir
   335     catch {file delete -force [file join [temporaryDirectory] tildetmp]}
   336     list $res $err
   337 } {0 tildetmp/~tilde}
   338 
   339 test filename-5.1 {Tcl_SplitPath: mac} {testsetplatform} {
   340     testsetplatform mac
   341     file split a:b
   342 } {a: b}
   343 test filename-5.2 {Tcl_SplitPath: mac} {testsetplatform} {
   344     testsetplatform mac
   345     file split a:b:c
   346 } {a: b c}
   347 test filename-5.3 {Tcl_SplitPath: mac} {testsetplatform} {
   348     testsetplatform mac
   349     file split a:b:c:
   350 } {a: b c}
   351 test filename-5.4 {Tcl_SplitPath: mac} {testsetplatform} {
   352     testsetplatform mac
   353     file split a:
   354 } {a:}
   355 test filename-5.5 {Tcl_SplitPath: mac} {testsetplatform} {
   356     testsetplatform mac
   357     file split a::
   358 } {a: ::}
   359 test filename-5.6 {Tcl_SplitPath: mac} {testsetplatform} {
   360     testsetplatform mac
   361     file split a:::
   362 } {a: :: ::}
   363 test filename-5.7 {Tcl_SplitPath: mac} {testsetplatform} {
   364     testsetplatform mac
   365     file split :a
   366 } {a}
   367 test filename-5.8 {Tcl_SplitPath: mac} {testsetplatform} {
   368     testsetplatform mac
   369     file split :a::
   370 } {a ::}
   371 test filename-5.9 {Tcl_SplitPath: mac} {testsetplatform} {
   372     testsetplatform mac
   373     file split :
   374 } {:}
   375 test filename-5.10 {Tcl_SplitPath: mac} {testsetplatform} {
   376     testsetplatform mac
   377     file split ::
   378 } {::}
   379 test filename-5.11 {Tcl_SplitPath: mac} {testsetplatform} {
   380     testsetplatform mac
   381     file split :::
   382 } {:: ::}
   383 test filename-5.12 {Tcl_SplitPath: mac} {testsetplatform} {
   384     testsetplatform mac
   385     file split a:::b
   386 } {a: :: :: b}
   387 test filename-5.13 {Tcl_SplitPath: mac} {testsetplatform} {
   388     testsetplatform mac
   389     file split /a:b
   390 } {/a: b}
   391 test filename-5.14 {Tcl_SplitPath: mac} {testsetplatform} {
   392     testsetplatform mac
   393     file split ~:
   394 } {~:}
   395 test filename-5.15 {Tcl_SplitPath: mac} {testsetplatform} {
   396     testsetplatform mac
   397     file split ~/:
   398 } {~/:}
   399 test filename-5.16 {Tcl_SplitPath: mac} {testsetplatform} {
   400     testsetplatform mac
   401     file split ~:foo
   402 } {~: foo}
   403 test filename-5.17 {Tcl_SplitPath: mac} {testsetplatform} {
   404     testsetplatform mac
   405     file split ~/foo
   406 } {~: foo}
   407 test filename-5.18 {Tcl_SplitPath: mac} {testsetplatform} {
   408     testsetplatform mac
   409     file split ~foo:
   410 } {~foo:}
   411 test filename-5.19 {Tcl_SplitPath: mac} {testsetplatform} {
   412     testsetplatform mac
   413     file split a:~foo
   414 } {a: :~foo}
   415 test filename-5.20 {Tcl_SplitPath: mac} {testsetplatform} {
   416     testsetplatform mac
   417     file split /
   418 } {:/}
   419 test filename-5.21 {Tcl_SplitPath: mac} {testsetplatform} {
   420     testsetplatform mac
   421     file split a:b/c
   422 } {a: :b/c}
   423 test filename-5.22 {Tcl_SplitPath: mac} {testsetplatform} {
   424     testsetplatform mac
   425     file split /foo
   426 } {foo:}
   427 test filename-5.23 {Tcl_SplitPath: mac} {testsetplatform} {
   428     testsetplatform mac
   429     file split /a/b
   430 } {a: b}
   431 test filename-5.24 {Tcl_SplitPath: mac} {testsetplatform} {
   432     testsetplatform mac
   433     file split /a/b/foo
   434 } {a: b foo}
   435 test filename-5.25 {Tcl_SplitPath: mac} {testsetplatform} {
   436     testsetplatform mac
   437     file split a/b
   438 } {a b}
   439 test filename-5.26 {Tcl_SplitPath: mac} {testsetplatform} {
   440     testsetplatform mac
   441     file split ./foo/bar
   442 } {: foo bar}
   443 test filename-5.27 {Tcl_SplitPath: mac} {testsetplatform} {
   444     testsetplatform mac
   445     file split ../foo/bar
   446 } {:: foo bar}
   447 test filename-5.28 {Tcl_SplitPath: mac} {testsetplatform} {
   448     testsetplatform mac
   449     file split {}
   450 } {}
   451 test filename-5.29 {Tcl_SplitPath: mac} {testsetplatform} {
   452     testsetplatform mac
   453     file split .
   454 } {:}
   455 test filename-5.30 {Tcl_SplitPath: mac} {testsetplatform} {
   456     testsetplatform mac
   457     file split ././
   458 } {: :}
   459 test filename-5.31 {Tcl_SplitPath: mac} {testsetplatform} {
   460     testsetplatform mac
   461     file split ././.
   462 } {: : :}
   463 test filename-5.32 {Tcl_SplitPath: mac} {testsetplatform} {
   464     testsetplatform mac
   465     file split ../
   466 } {::}
   467 test filename-5.33 {Tcl_SplitPath: mac} {testsetplatform} {
   468     testsetplatform mac
   469     file split ..
   470 } {::}
   471 test filename-5.34 {Tcl_SplitPath: mac} {testsetplatform} {
   472     testsetplatform mac
   473     file split ../..
   474 } {:: ::}
   475 test filename-5.35 {Tcl_SplitPath: mac} {testsetplatform} {
   476     testsetplatform mac
   477     file split //foo
   478 } {foo:}
   479 test filename-5.36 {Tcl_SplitPath: mac} {testsetplatform} {
   480     testsetplatform mac
   481     file split foo//bar
   482 } {foo bar}
   483 test filename-5.37 {Tcl_SplitPath: mac} {testsetplatform} {
   484     testsetplatform mac
   485     file split ~foo
   486 } {~foo:}
   487 test filename-5.38 {Tcl_SplitPath: mac} {testsetplatform} {
   488     testsetplatform mac
   489     file split ~
   490 } {~:}
   491 test filename-5.39 {Tcl_SplitPath: mac} {testsetplatform} {
   492     testsetplatform mac
   493     file split foo
   494 } {foo}
   495 test filename-5.40 {Tcl_SplitPath: mac} {testsetplatform} {
   496     testsetplatform mac
   497     file split ~/
   498 } {~:}
   499 test filename-5.41 {Tcl_SplitPath: mac} {testsetplatform} {
   500     testsetplatform mac
   501     file split ~foo/~bar
   502 } {~foo: :~bar}
   503 test filename-5.42 {Tcl_SplitPath: mac} {testsetplatform} {
   504     testsetplatform mac
   505     file split ~foo/~bar/~baz
   506 } {~foo: :~bar :~baz}
   507 test filename-5.43 {Tcl_SplitPath: mac} {testsetplatform} {
   508     testsetplatform mac
   509     file split foo/bar~/baz
   510 } {foo bar~ baz}
   511 test filename-5.44 {Tcl_SplitPath: mac} {testsetplatform} {
   512     testsetplatform mac
   513     file split a/../b
   514 } {a :: b}
   515 test filename-5.45 {Tcl_SplitPath: mac} {testsetplatform} {
   516     testsetplatform mac
   517     file split a/../../b
   518 } {a :: :: b}
   519 test filename-5.46 {Tcl_SplitPath: mac} {testsetplatform} {
   520     testsetplatform mac
   521     file split a/.././../b
   522 } {a :: : :: b}
   523 test filename-5.47 {Tcl_SplitPath: mac} {testsetplatform} {
   524     testsetplatform mac
   525     file split /../bar
   526 } {bar:}
   527 test filename-5.48 {Tcl_SplitPath: mac} {testsetplatform} {
   528     testsetplatform mac
   529     file split /./bar
   530 } {bar:}
   531 test filename-5.49 {Tcl_SplitPath: mac} {testsetplatform} {
   532     testsetplatform mac
   533     file split //.//.././bar
   534 } {bar:}
   535 test filename-5.50 {Tcl_SplitPath: mac} {testsetplatform} {
   536     testsetplatform mac
   537     file split /..
   538 } {:/..}
   539 test filename-5.51 {Tcl_SplitPath: mac} {testsetplatform} {
   540     testsetplatform mac
   541     file split //.//.././
   542 } {://.//.././}
   543 
   544 test filename-6.1 {Tcl_SplitPath: win} {testsetplatform} {
   545     testsetplatform win
   546     file split /
   547 } {/}
   548 test filename-6.2 {Tcl_SplitPath: win} {testsetplatform} {
   549     testsetplatform win
   550     file split /foo
   551 } {/ foo}
   552 test filename-6.3 {Tcl_SplitPath: win} {testsetplatform} {
   553     testsetplatform win
   554     file split /foo/bar
   555 } {/ foo bar}
   556 test filename-6.4 {Tcl_SplitPath: win} {testsetplatform} {
   557     testsetplatform win
   558     file split /foo/bar/baz
   559 } {/ foo bar baz}
   560 test filename-6.5 {Tcl_SplitPath: win} {testsetplatform} {
   561     testsetplatform win
   562     file split foo/bar
   563 } {foo bar}
   564 test filename-6.6 {Tcl_SplitPath: win} {testsetplatform} {
   565     testsetplatform win
   566     file split ./foo/bar
   567 } {. foo bar}
   568 test filename-6.7 {Tcl_SplitPath: win} {testsetplatform} {
   569     testsetplatform win
   570     file split /foo/../././foo/bar
   571 } {/ foo .. . . foo bar}
   572 test filename-6.8 {Tcl_SplitPath: win} {testsetplatform} {
   573     testsetplatform win
   574     file split ../foo/bar
   575 } {.. foo bar}
   576 test filename-6.9 {Tcl_SplitPath: win} {testsetplatform} {
   577     testsetplatform win
   578     file split {}
   579 } {}
   580 test filename-6.10 {Tcl_SplitPath: win} {testsetplatform} {
   581     testsetplatform win
   582     file split .
   583 } {.}
   584 test filename-6.11 {Tcl_SplitPath: win} {testsetplatform} {
   585     testsetplatform win
   586     file split ../
   587 } {..}
   588 test filename-6.12 {Tcl_SplitPath: win} {testsetplatform} {
   589     testsetplatform win
   590     file split ../..
   591 } {.. ..}
   592 test filename-6.13 {Tcl_SplitPath: win} {testsetplatform} {
   593     testsetplatform win
   594     file split //foo
   595 } {/ foo}
   596 test filename-6.14 {Tcl_SplitPath: win} {testsetplatform} {
   597     testsetplatform win
   598     file split foo//bar
   599 } {foo bar}
   600 test filename-6.15 {Tcl_SplitPath: win} {testsetplatform} {
   601     testsetplatform win
   602     file split /\\/foo//bar
   603 } {//foo/bar}
   604 test filename-6.16 {Tcl_SplitPath: win} {testsetplatform} {
   605     testsetplatform win
   606     file split /\\/foo//bar
   607 } {//foo/bar}
   608 test filename-6.17 {Tcl_SplitPath: win} {testsetplatform} {
   609     testsetplatform win
   610     file split /\\/foo//bar
   611 } {//foo/bar}
   612 test filename-6.18 {Tcl_SplitPath: win} {testsetplatform} {
   613     testsetplatform win
   614     file split \\\\foo\\bar
   615 } {//foo/bar}
   616 test filename-6.19 {Tcl_SplitPath: win} {testsetplatform} {
   617     testsetplatform win
   618     file split \\\\foo\\bar/baz
   619 } {//foo/bar baz}
   620 test filename-6.20 {Tcl_SplitPath: win} {testsetplatform} {
   621     testsetplatform win
   622     file split c:/foo
   623 } {c:/ foo}
   624 test filename-6.21 {Tcl_SplitPath: win} {testsetplatform} {
   625     testsetplatform win
   626     file split c:foo
   627 } {c: foo}
   628 test filename-6.22 {Tcl_SplitPath: win} {testsetplatform} {
   629     testsetplatform win
   630     file split c:
   631 } {c:}
   632 test filename-6.23 {Tcl_SplitPath: win} {testsetplatform} {
   633     testsetplatform win
   634     file split c:\\
   635 } {c:/}
   636 test filename-6.24 {Tcl_SplitPath: win} {testsetplatform} {
   637     testsetplatform win
   638     file split c:/
   639 } {c:/}
   640 test filename-6.25 {Tcl_SplitPath: win} {testsetplatform} {
   641     testsetplatform win
   642     file split c:/./..
   643 } {c:/ . ..}
   644 test filename-6.26 {Tcl_SplitPath: win} {testsetplatform} {
   645     testsetplatform win
   646     file split ~foo
   647 } {~foo}
   648 test filename-6.27 {Tcl_SplitPath: win} {testsetplatform} {
   649     testsetplatform win
   650     file split ~foo/~bar
   651 } {~foo ./~bar}
   652 test filename-6.28 {Tcl_SplitPath: win} {testsetplatform} {
   653     testsetplatform win
   654     file split ~foo/~bar/~baz
   655 } {~foo ./~bar ./~baz}
   656 test filename-6.29 {Tcl_SplitPath: win} {testsetplatform} {
   657     testsetplatform win
   658     file split foo/bar~/baz
   659 } {foo bar~ baz}
   660 test filename-6.30 {Tcl_SplitPath: win} {testsetplatform} {
   661     testsetplatform win
   662     file split c:~foo
   663 } {c: ./~foo}
   664 
   665 test filename-7.1 {Tcl_JoinPath: unix} {testsetplatform} {
   666     testsetplatform unix
   667     file join / a
   668 } {/a}
   669 test filename-7.2 {Tcl_JoinPath: unix} {testsetplatform} {
   670     testsetplatform unix
   671     file join a b
   672 } {a/b}
   673 test filename-7.3 {Tcl_JoinPath: unix} {testsetplatform} {
   674     testsetplatform unix
   675     file join /a c /b d
   676 } {/b/d}
   677 test filename-7.4 {Tcl_JoinPath: unix} {testsetplatform} {
   678     testsetplatform unix
   679     file join /
   680 } {/}
   681 test filename-7.5 {Tcl_JoinPath: unix} {testsetplatform} {
   682     testsetplatform unix
   683     file join a
   684 } {a}
   685 test filename-7.6 {Tcl_JoinPath: unix} {testsetplatform} {
   686     testsetplatform unix
   687     file join {}
   688 } {}
   689 test filename-7.7 {Tcl_JoinPath: unix} {testsetplatform} {
   690     testsetplatform unix
   691     file join /a/ b
   692 } {/a/b}
   693 test filename-7.8 {Tcl_JoinPath: unix} {testsetplatform} {
   694     testsetplatform unix
   695     file join /a// b
   696 } {/a/b}
   697 test filename-7.9 {Tcl_JoinPath: unix} {testsetplatform} {
   698     testsetplatform unix
   699     file join /a/./../. b
   700 } {/a/./.././b}
   701 test filename-7.10 {Tcl_JoinPath: unix} {testsetplatform} {
   702     testsetplatform unix
   703     file join ~ a
   704 } {~/a}
   705 test filename-7.11 {Tcl_JoinPath: unix} {testsetplatform} {
   706     testsetplatform unix
   707     file join ~a ~b
   708 } {~b}
   709 test filename-7.12 {Tcl_JoinPath: unix} {testsetplatform} {
   710     testsetplatform unix
   711     file join ./~a b
   712 } {./~a/b}
   713 test filename-7.13 {Tcl_JoinPath: unix} {testsetplatform} {
   714     testsetplatform unix
   715     file join ./~a ~b
   716 } {~b}
   717 test filename-7.14 {Tcl_JoinPath: unix} {testsetplatform} {
   718     testsetplatform unix
   719     file join ./~a ./~b
   720 } {./~a/~b}
   721 test filename-7.15 {Tcl_JoinPath: unix} {testsetplatform} {
   722     testsetplatform unix
   723     file join a . b
   724 } {a/./b}
   725 test filename-7.16 {Tcl_JoinPath: unix} {testsetplatform} {
   726     testsetplatform unix
   727     file join a . ./~b
   728 } {a/./~b}
   729 test filename-7.17 {Tcl_JoinPath: unix} {testsetplatform} {
   730     testsetplatform unix
   731     file join //a b
   732 } {/a/b}
   733 test filename-7.18 {Tcl_JoinPath: unix} {testsetplatform} {
   734     testsetplatform unix
   735     file join /// a b
   736 } {/a/b}
   737 
   738 test filename-8.1 {Tcl_JoinPath: mac} {testsetplatform} {
   739     testsetplatform mac
   740     file join a b
   741 } {:a:b}
   742 test filename-8.2 {Tcl_JoinPath: mac} {testsetplatform} {
   743     testsetplatform mac
   744     file join :a b
   745 } {:a:b}
   746 test filename-8.3 {Tcl_JoinPath: mac} {testsetplatform} {
   747     testsetplatform mac
   748     file join a b:
   749 } {b:}
   750 test filename-8.4 {Tcl_JoinPath: mac} {testsetplatform} {
   751     testsetplatform mac
   752     file join a: :b
   753 } {a:b}
   754 test filename-8.5 {Tcl_JoinPath: mac} {testsetplatform} {
   755     testsetplatform mac
   756     file join a: :b:
   757 } {a:b}
   758 test filename-8.6 {Tcl_JoinPath: mac} {testsetplatform} {
   759     testsetplatform mac
   760     file join a :: b
   761 } {:a::b}
   762 test filename-8.7 {Tcl_JoinPath: mac} {testsetplatform} {
   763     testsetplatform mac
   764     file join a :: :: b
   765 } {:a:::b}
   766 test filename-8.8 {Tcl_JoinPath: mac} {testsetplatform} {
   767     testsetplatform mac
   768     file join a ::: b
   769 } {:a:::b}
   770 test filename-8.9 {Tcl_JoinPath: mac} {testsetplatform} {
   771     testsetplatform mac
   772     file join a: b:
   773 } {b:}
   774 test filename-8.10 {Tcl_JoinPath: mac} {testsetplatform} {
   775     testsetplatform mac
   776     file join /a/b
   777 } {a:b}
   778 test filename-8.11 {Tcl_JoinPath: mac} {testsetplatform} {
   779     testsetplatform mac
   780     file join /a/b c/d
   781 } {a:b:c:d}
   782 test filename-8.12 {Tcl_JoinPath: mac} {testsetplatform} {
   783     testsetplatform mac
   784     file join /a/b :c:d
   785 } {a:b:c:d}
   786 test filename-8.13 {Tcl_JoinPath: mac} {testsetplatform} {
   787     testsetplatform mac
   788     file join ~ foo
   789 } {~:foo}
   790 test filename-8.14 {Tcl_JoinPath: mac} {testsetplatform} {
   791     testsetplatform mac
   792     file join :: ::
   793 } {:::}
   794 test filename-8.15 {Tcl_JoinPath: mac} {testsetplatform} {
   795     testsetplatform mac
   796     file join a: ::
   797 } {a::}
   798 test filename-8.16 {Tcl_JoinPath: mac} {testsetplatform} {
   799     testsetplatform mac
   800     file join a {} b
   801 } {:a:b}
   802 test filename-8.17 {Tcl_JoinPath: mac} {testsetplatform} {
   803     testsetplatform mac
   804     file join a::: b
   805 } {a:::b}
   806 test filename-8.18 {Tcl_JoinPath: mac} {testsetplatform} {
   807     testsetplatform mac
   808     file join a : : :
   809 } {:a}
   810 test filename-8.19 {Tcl_JoinPath: mac} {testsetplatform} {
   811     testsetplatform mac
   812     file join :
   813 } {:}
   814 test filename-8.20 {Tcl_JoinPath: mac} {testsetplatform} {
   815     testsetplatform mac
   816     file join : a
   817 } {:a}
   818 test filename-8.21 {Tcl_JoinPath: mac} {testsetplatform} {
   819     testsetplatform mac
   820     file join a: :b/c
   821 } {a:b/c}
   822 test filename-8.22 {Tcl_JoinPath: mac} {testsetplatform} {
   823     testsetplatform mac
   824     file join :a :b/c
   825 } {:a:b/c}
   826 
   827 test filename-9.1 {Tcl_JoinPath: win} {testsetplatform} {
   828     testsetplatform win
   829     file join a b
   830 } {a/b}
   831 test filename-9.2 {Tcl_JoinPath: win} {testsetplatform} {
   832     testsetplatform win
   833     file join /a b
   834 } {/a/b}
   835 test filename-9.3 {Tcl_JoinPath: win} {testsetplatform} {
   836     testsetplatform win
   837     file join /a /b
   838 } {/b}
   839 test filename-9.4 {Tcl_JoinPath: win} {testsetplatform} {
   840     testsetplatform win
   841     file join c: foo
   842 } {c:foo}
   843 test filename-9.5 {Tcl_JoinPath: win} {testsetplatform} {
   844     testsetplatform win
   845     file join c:/ foo
   846 } {c:/foo}
   847 test filename-9.6 {Tcl_JoinPath: win} {testsetplatform} {
   848     testsetplatform win
   849     file join c:\\bar foo
   850 } {c:/bar/foo}
   851 test filename-9.7 {Tcl_JoinPath: win} {testsetplatform} {
   852     testsetplatform win
   853     file join /foo c:bar
   854 } {c:bar}
   855 test filename-9.8 {Tcl_JoinPath: win} {testsetplatform} {
   856     testsetplatform win
   857     file join ///host//share dir
   858 } {//host/share/dir}
   859 test filename-9.9 {Tcl_JoinPath: win} {testsetplatform} {
   860     testsetplatform win
   861     file join ~ foo
   862 } {~/foo}
   863 test filename-9.10 {Tcl_JoinPath: win} {testsetplatform} {
   864     testsetplatform win
   865     file join ~/~foo
   866 } {~/~foo}
   867 test filename-9.11 {Tcl_JoinPath: win} {testsetplatform} {
   868     testsetplatform win
   869     file join ~ ./~foo
   870 } {~/~foo}
   871 test filename-9.12 {Tcl_JoinPath: win} {testsetplatform} {
   872     testsetplatform win
   873     file join / ~foo
   874 } {~foo}
   875 test filename-9.13 {Tcl_JoinPath: win} {testsetplatform} {
   876     testsetplatform win
   877     file join ./a/ b c
   878 } {./a/b/c}
   879 test filename-9.14 {Tcl_JoinPath: win} {testsetplatform} {
   880     testsetplatform win
   881     file join ./~a/ b c
   882 } {./~a/b/c}
   883 test filename-9.15 {Tcl_JoinPath: win} {testsetplatform} {
   884     testsetplatform win
   885     file join // host share path
   886 } {/host/share/path}
   887 test filename-9.16 {Tcl_JoinPath: win} {testsetplatform} {
   888     testsetplatform win
   889     file join foo . bar
   890 } {foo/./bar}
   891 test filename-9.17 {Tcl_JoinPath: win} {testsetplatform} {
   892     testsetplatform win
   893     file join foo .. bar
   894 } {foo/../bar}
   895 test filename-9.18 {Tcl_JoinPath: win} {testsetplatform} {
   896     testsetplatform win
   897     file join foo/./bar
   898 } {foo/./bar}
   899 test filename-9.19 {Tcl_JoinPath: win} {testsetplatform} {
   900     testsetplatform win
   901     set res {}
   902     lappend res \
   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} {
   908     testsetplatform win
   909     set res {}
   910     lappend res \
   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} {
   916     testsetplatform win
   917     set res {}
   918     lappend res \
   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} {
   925     testsetplatform unix
   926     set res {}
   927     lappend res \
   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} {
   933     testsetplatform mac
   934     set res {}
   935     lappend res \
   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} {
   941     testsetplatform mac
   942     set res {}
   943     lappend res \
   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} {
   949     testsetplatform win
   950     set res {}
   951     lappend res \
   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} {
   958     testsetplatform unix
   959     set res {}
   960     lappend res \
   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} {
   967     testsetplatform mac
   968     set res {}
   969     lappend res \
   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} {
   976     testsetplatform mac
   977     set res {}
   978     lappend res \
   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}
   984 
   985 test filename-10.1 {Tcl_TranslateFileName} {testsetplatform} {
   986     testsetplatform unix
   987     list [catch {testtranslatefilename foo} msg] $msg
   988 } {0 foo}
   989 test filename-10.2 {Tcl_TranslateFileName} {testsetplatform} {
   990     testsetplatform windows
   991     list [catch {testtranslatefilename {c:/foo}} msg] $msg
   992 } {0 {c:\foo}}
   993 test filename-10.3 {Tcl_TranslateFileName} {testsetplatform} {
   994     testsetplatform windows
   995     list [catch {testtranslatefilename {c:/\\foo/}} msg] $msg
   996 } {0 {c:\foo}}
   997 test filename-10.4 {Tcl_TranslateFileName} {testsetplatform} {
   998     testsetplatform mac
   999     list [catch {testtranslatefilename foo} msg] $msg
  1000 } {0 :foo}
  1001 test filename-10.5 {Tcl_TranslateFileName} {testsetplatform} {
  1002     testsetplatform mac
  1003     list [catch {testtranslatefilename :~foo} msg] $msg
  1004 } {0 :~foo}
  1005 test filename-10.6 {Tcl_TranslateFileName} {testsetplatform} {
  1006     global env
  1007     set temp $env(HOME)
  1008     set env(HOME) "/home/test"
  1009     testsetplatform unix
  1010     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1011     set env(HOME) $temp
  1012     set result
  1013 } {0 /home/test/foo}
  1014 test filename-10.7 {Tcl_TranslateFileName} {testsetplatform} {
  1015     global env
  1016     set temp $env(HOME)
  1017     unset env(HOME)
  1018     testsetplatform unix
  1019     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1020     set env(HOME) $temp
  1021     set result
  1022 } {1 {couldn't find HOME environment variable to expand path}}
  1023 test filename-10.8 {Tcl_TranslateFileName} {testsetplatform} {
  1024     global env
  1025     set temp $env(HOME)
  1026     set env(HOME) "/home/test"
  1027     testsetplatform unix
  1028     set result [list [catch {testtranslatefilename ~} msg] $msg]
  1029     set env(HOME) $temp
  1030     set result
  1031 } {0 /home/test}
  1032 test filename-10.9 {Tcl_TranslateFileName} {testsetplatform} {
  1033     global env
  1034     set temp $env(HOME)
  1035     set env(HOME) "/home/test/"
  1036     testsetplatform unix
  1037     set result [list [catch {testtranslatefilename ~} msg] $msg]
  1038     set env(HOME) $temp
  1039     set result
  1040 } {0 /home/test}
  1041 test filename-10.10 {Tcl_TranslateFileName} {testsetplatform} {
  1042     global env
  1043     set temp $env(HOME)
  1044     set env(HOME) "/home/test/"
  1045     testsetplatform unix
  1046     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1047     set env(HOME) $temp
  1048     set result
  1049 } {0 /home/test/foo}
  1050 test filename-10.11 {Tcl_TranslateFileName} {testsetplatform} {
  1051     global env
  1052     set temp $env(HOME)
  1053     set env(HOME) "Root:"
  1054     testsetplatform mac
  1055     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1056     set env(HOME) $temp
  1057     set result
  1058 } {0 Root:foo}
  1059 test filename-10.12 {Tcl_TranslateFileName} {testsetplatform} {
  1060     global env
  1061     set temp $env(HOME)
  1062     set env(HOME) "Root:home"
  1063     testsetplatform mac
  1064     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1065     set env(HOME) $temp
  1066     set result
  1067 } {0 Root:home:foo}
  1068 test filename-10.13 {Tcl_TranslateFileName} {testsetplatform} {
  1069     global env
  1070     set temp $env(HOME)
  1071     set env(HOME) "Root:home"
  1072     testsetplatform mac
  1073     set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
  1074     set env(HOME) $temp
  1075     set result
  1076 } {0 Root:home::foo}
  1077 test filename-10.14 {Tcl_TranslateFileName} {testsetplatform} {
  1078     global env
  1079     set temp $env(HOME)
  1080     set env(HOME) "Root:home"
  1081     testsetplatform mac
  1082     set result [list [catch {testtranslatefilename ~} msg] $msg]
  1083     set env(HOME) $temp
  1084     set result
  1085 } {0 Root:home}
  1086 test filename-10.15 {Tcl_TranslateFileName} {testsetplatform} {
  1087     global env
  1088     set temp $env(HOME)
  1089     set env(HOME) "Root:home:"
  1090     testsetplatform mac
  1091     set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
  1092     set env(HOME) $temp
  1093     set result
  1094 } {0 Root:home::foo}
  1095 test filename-10.16 {Tcl_TranslateFileName} {testsetplatform} {
  1096     global env
  1097     set temp $env(HOME)
  1098     set env(HOME) "Root:home::"
  1099     testsetplatform mac
  1100     set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
  1101     set env(HOME) $temp
  1102     set result
  1103 } {0 Root:home:::foo}
  1104 test filename-10.17 {Tcl_TranslateFileName} {testsetplatform} {
  1105     global env
  1106     set temp $env(HOME)
  1107     set env(HOME) "\\home\\"
  1108     testsetplatform windows
  1109     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1110     set env(HOME) $temp
  1111     set result
  1112 } {0 {\home\foo}}
  1113 test filename-10.18 {Tcl_TranslateFileName} {testsetplatform} {
  1114     global env
  1115     set temp $env(HOME)
  1116     set env(HOME) "\\home\\"
  1117     testsetplatform windows
  1118     set result [list [catch {testtranslatefilename ~/foo\\bar} msg] $msg]
  1119     set env(HOME) $temp
  1120     set result
  1121 } {0 {\home\foo\bar}}
  1122 test filename-10.19 {Tcl_TranslateFileName} {testsetplatform} {
  1123     global env
  1124     set temp $env(HOME)
  1125     set env(HOME) "c:"
  1126     testsetplatform windows
  1127     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1128     set env(HOME) $temp
  1129     set result
  1130 } {0 c:foo}
  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} {
  1135     global env
  1136     set temp $env(HOME)
  1137     set env(HOME) "c:\\"
  1138     testsetplatform windows
  1139     set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
  1140     set env(HOME) $temp
  1141     set result
  1142 } {0 {c:\foo}}
  1143 test filename-10.22 {Tcl_TranslateFileName} {testsetplatform} {
  1144     testsetplatform windows
  1145     list [catch {testtranslatefilename foo//bar} msg] $msg
  1146 } {0 {foo\bar}}
  1147 
  1148 if {[tcltest::testConstraint testsetplatform]} {
  1149     testsetplatform $platform
  1150 }
  1151 
  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
  1155 } {0 /home/ouster}
  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}
  1160 
  1161 
  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
  1176 } {0 {}}
  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
  1185 } {0 {}}
  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
  1193 } {0 {}}
  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
  1200     set home $env(HOME)
  1201     unset env(HOME)
  1202     set x [list [catch {glob ~/*} msg] $msg]
  1203     set env(HOME) $home
  1204     set x
  1205 } {1 {couldn't find HOME environment variable to expand path}}
  1206 
  1207 if {[tcltest::testConstraint testsetplatform]} {
  1208     testsetplatform $platform
  1209 }
  1210 
  1211 test filename-11.13 {Tcl_GlobCmd} {
  1212     list [catch {file join [lindex [glob ~] 0]} msg] $msg
  1213 } [list 0 [file join $env(HOME)]]
  1214 
  1215 set oldpwd [pwd]
  1216 set oldhome $env(HOME)
  1217 cd [temporaryDirectory]
  1218 set env(HOME) [pwd]
  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]
  1230 
  1231 catch {close [open globTest/.1 w]}
  1232 catch {close [open globTest/x,z1.c w]}
  1233 
  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
  1242 } {0 globTest}
  1243 
  1244 set globname "globTest"
  1245 set horribleglobname "glob\[\{Test"
  1246 
  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
  1268     } else {
  1269 	tcltest::testConstraint linkDirectory 0
  1270     }
  1271 } elseif {[string equal $tcl_platform(osSystemName) "Symbian"]} {
  1272     tcltest::testConstraint linkDirectory 0
  1273 } else {
  1274     tcltest::testConstraint linkDirectory 1
  1275 }
  1276 if {[string equal $tcl_platform(platform) "windows"] || [string equal $tcl_platform(osSystemName) "Symbian"]} {
  1277     tcltest::testConstraint symbolicLinkFile 0
  1278 } else {
  1279     tcltest::testConstraint symbolicLinkFile 1
  1280 }
  1281 test filename-11.17.2 {Tcl_GlobCmd} {notRoot linkDirectory} {
  1282     set dir [pwd]
  1283     set ret "error in test"
  1284     if {[catch {
  1285 	cd $globname
  1286 	file link -symbolic link a1
  1287 	cd $dir
  1288 	set ret [list [catch {
  1289 	    lsort [glob -directory $globname -join * b1]
  1290 	} msg] $msg]
  1291     }]} {
  1292 	cd $dir
  1293     }
  1294     file delete [file join $globname link]
  1295     set ret
  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} {
  1300     set dir [pwd]
  1301     set ret "error in test"
  1302     if {[catch {
  1303 	cd $globname
  1304 	file link -symbolic link a1
  1305 	cd $dir
  1306 	set ret [list [catch {
  1307 	    lsort [glob -directory $globname -type d *]
  1308 	} msg] $msg]
  1309     }]} {
  1310 	cd $dir
  1311     }
  1312     file delete [file join $globname link]
  1313     set ret
  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} {
  1321     set dir [pwd]
  1322     set ret "error in test"
  1323     if {[catch {
  1324 	cd $globname
  1325 	file link -symbolic link a1
  1326 	cd $dir
  1327 	set ret [list [catch {
  1328 	    lsort [glob -directory $globname -type l *]
  1329 	} msg] $msg]
  1330     }]} {
  1331 	cd $dir
  1332     }
  1333     file delete [file join $globname link]
  1334     set ret
  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} {
  1344     set dir [pwd]
  1345     set ret "error in test"
  1346     if {[catch {
  1347 	cd $globname
  1348 	file mkdir nonexistent
  1349 	file link -symbolic link nonexistent
  1350 	file delete nonexistent
  1351 	cd $dir
  1352 	set ret [list [catch {
  1353 	    lsort [glob -nocomplain -directory $globname -type l *]
  1354 	} msg] $msg]
  1355     }]} {
  1356 	cd $dir
  1357     }
  1358     file delete [file join $globname link]
  1359     set ret
  1360 } [list 0 [list [file join $globname link]]]
  1361 test filename-11.17.8 {Tcl_GlobCmd: broken link and glob -l} {symbolicLinkFile} {
  1362     set dir [pwd]
  1363     set ret "error in test"
  1364     if {[catch {
  1365 	cd $globname
  1366 	close [open "nonexistent" w]
  1367 	file link -symbolic link nonexistent
  1368 	file delete nonexistent
  1369 	cd $dir
  1370 	set ret [list [catch {
  1371 	    lsort [glob -nocomplain -directory $globname -type l *]
  1372 	} msg] $msg]
  1373     }]} {
  1374 	cd $dir
  1375     }
  1376     file delete [file join $globname link]
  1377     set ret
  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]]]
  1423 
  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}
  1428     set res
  1429 } [list 0 {{[tcl].testremains}}]
  1430 
  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
  1435 }
  1436 file rename globTest $horribleglobname
  1437 set globname $horribleglobname
  1438 
  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 *]}
  1553 } {1}
  1554 test filename-11.41 {Tcl_GlobCmd} {
  1555     expr {[glob -dir [pwd] -tails *] != [glob -dir [pwd] *]}
  1556 } {1}
  1557 test filename-11.42 {Tcl_GlobCmd} {
  1558     set res [list]
  1559     foreach f [glob -dir [pwd] *] {
  1560 	lappend res [file tail $f]
  1561     }
  1562     expr {$res == [glob *]}
  1563 } {1}
  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} {
  1571     set res1 ""
  1572     set res2 ""
  1573     catch {
  1574 	set res1 [glob -dir [lindex [file volumes] 0] -tails *]
  1575     }
  1576     catch {
  1577 	set tmpd [pwd]
  1578 	cd [lindex [file volumes] 0]
  1579 	set res2 [glob *]
  1580 	cd $tmpd
  1581     }
  1582     expr {$res1 == $res2}
  1583 } {1}
  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}}
  1596 
  1597 file rename $horribleglobname globTest
  1598 set globname globTest
  1599 unset horribleglobname
  1600 
  1601 test filename-12.1 {simple globbing} {unixOrPc} {
  1602     list [catch {glob {}} msg] $msg
  1603 } {0 .}
  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
  1609 } {0 .}
  1610 test filename-12.1.3 {simple globbing} {unixOnly} {
  1611     list [catch {glob -types hidden {}} msg] $msg
  1612 } {0 .}
  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
  1621 } {0 c:/}
  1622 test filename-12.2 {simple globbing} {macOnly} {
  1623     list [catch {glob {}} msg] $msg
  1624 } {0 :}
  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
  1630 } {0 :}
  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
  1636 } {0 {}}
  1637 
  1638 if {$tcl_platform(platform) == "macintosh"} {
  1639     set globPreResult :globTest:
  1640 } else {
  1641     set globPreResult globTest/
  1642 }
  1643 set x1 x1.c
  1644 set y1 y1.c
  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]
  1658     if {!$equal} {
  1659 	lappend equal "not equal" $res1 $res2
  1660     }
  1661     set equal
  1662 } {1}
  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]
  1669     if {!$equal} {
  1670 	lappend equal "not equal" $res1 $res2
  1671     }
  1672     set equal
  1673 } {1}
  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]
  1682     if {!$equal} {
  1683 	lappend equal "not equal" $res1 $res2
  1684     }
  1685     set equal
  1686 } {1}
  1687 
  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}}
  1754 
  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}
  1767 
  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]
  1771 set savepwd [pwd]
  1772 cd globTestContext
  1773 
  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}
  1780 
  1781 # Reset to where we were
  1782 cd $savepwd
  1783 file rename [file join globTestContext globTest] globTest
  1784 file delete globTestContext
  1785 
  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/.*]
  1800 } {globTest/.1}
  1801 test filename-14.10 {asterisks, question marks, and brackets} {macOnly} {
  1802     lsort [glob globTest/.*]
  1803 } {:globTest:.1}
  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} {
  1823     global env
  1824     set temp $env(HOME)
  1825     set env(HOME) [file join $env(HOME) globTest]
  1826     set result [list [catch {glob ~/z*} msg] $msg]
  1827     set env(HOME) $temp
  1828     set result
  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
  1838 } {0 {}}
  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} {
  1846     glob /
  1847 } /
  1848 test filename-14.24 {slash globbing} {pcOnly} {
  1849     glob {\\}
  1850 } /
  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
  1868 } [list 0 {}]
  1869 
  1870 unset globname
  1871 
  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.
  1875 
  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/*
  1882 } {}
  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
  1886     # is reset...
  1887     glob -nocomplain globTest/a2 globTest/a1/* globTest/a3
  1888 } {globTest/a2 globTest/a3}
  1889 
  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
  1900     # is reset... 
  1901     string equal [glob -nocomplain ~wontexist ~blah ~] \
  1902       [glob -nocomplain ~ ~blah ~wontexist]
  1903 } {1}
  1904 test filename-15.5 {unix specific globbing} {unixOnly nonPortable} {
  1905     glob ~ouster/.csh*
  1906 } "/home/ouster/.cshrc"
  1907 catch {close [open globTest/odd\\\[\]*?\{\}name w]}
  1908 test filename-15.6 {unix specific globbing} {unixOnly tempNotSymbian} {
  1909     global env
  1910     set temp $env(HOME)
  1911     set env(HOME) $env(HOME)/globTest/odd\\\[\]*?\{\}name
  1912     set result [list [catch {glob ~} msg] $msg]
  1913     set env(HOME) $temp
  1914     set result
  1915 } [list 0 [list [lindex [glob ~] 0]/globTest/odd\\\[\]*?\{\}name]]
  1916 catch {file delete -force globTest/odd\\\[\]*?\{\}name}
  1917 
  1918 # The following tests are only valid for Windows systems.
  1919 set oldDir [pwd]
  1920 if {$::tcltest::testConstraints(pcOnly)} {
  1921     cd c:/
  1922     file delete -force globTest
  1923     file mkdir globTest
  1924     close [open globTest/x1.BAT w]
  1925     close [open globTest/y1.Bat w]
  1926     close [open globTest/z1.bat w]
  1927 }
  1928 
  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} {
  1933     glob c:
  1934 } c:
  1935 test filename-16.3 {windows specific globbing} {pcOnly} {
  1936     glob c:\\\\
  1937 } c:/
  1938 test filename-16.4 {windows specific globbing} {pcOnly} {
  1939     glob c:/
  1940 } c:/
  1941 test filename-16.5 {windows specific globbing} {pcOnly} {
  1942     glob c:*bTest
  1943 } c:globTest
  1944 test filename-16.6 {windows specific globbing} {pcOnly} {
  1945     glob c:\\\\*bTest
  1946 } c:/globTest
  1947 test filename-16.7 {windows specific globbing} {pcOnly} {
  1948     glob c:/*bTest
  1949 } c:/globTest
  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}
  1962 
  1963 # some tests require a shared C drive
  1964 
  1965 if {[catch {cd //[info hostname]/c}]} {
  1966     set ::tcltest::testConstraints(sharedCdrive) 0
  1967 } else {
  1968     set ::tcltest::testConstraints(sharedCdrive) 1
  1969 }
  1970 
  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}
  1982 } {1}
  1983 test filename-16.15 {windows specific globbing} {pcOnly} {
  1984     cd [lindex [glob -types d -dir C:/ *] 0]
  1985     glob ..
  1986 } {..}
  1987 test filename-16.16 {windows specific globbing} {pcOnly} {
  1988     file tail [lindex [glob "[lindex [glob -types d -dir C:/ *] 0]/.."] 0]
  1989 } {..}
  1990 
  1991 test filename-17.1 {windows specific special files} {testsetplatform} {
  1992     testsetplatform win
  1993     list [file pathtype com1] [file pathtype con] [file pathtype lpt3] \
  1994       [file pathtype prn] [file pathtype nul] [file pathtype aux] \
  1995       [file pathtype foo]
  1996 } {absolute absolute absolute absolute absolute absolute relative}
  1997 
  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 \
  2003       -tails -types x *]
  2004     removeFile execglob/abc.exe
  2005     removeFile execglob/abc.notexecutable
  2006     removeDirectory execglob
  2007     set res
  2008 } {abc.exe}
  2009 
  2010 test fileName-18.1 {windows - split ADS name correctly} {winOnly} {
  2011     # bug 1194458
  2012     set x [file split c:/c:d]
  2013     set y [eval [linsert $x 0 file join]]
  2014     list $x $y
  2015 } {{c:/ ./c:d} c:/c:d}
  2016 
  2017 # cleanup
  2018 catch {file delete -force C:/globTest}
  2019 cd [temporaryDirectory]
  2020 file delete -force globTest
  2021 cd $oldpwd
  2022 set env(HOME) $oldhome
  2023 if {[tcltest::testConstraint testsetplatform]} {
  2024     testsetplatform $platform
  2025     catch {unset platform}
  2026 }
  2027 catch {unset oldhome temp result globPreResult}
  2028 ::tcltest::cleanupTests
  2029 return