| [25] | 1 | # This file tests the tclWinFCmd.c file. | 
|---|
 | 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) 1996-1997 Sun Microsystems, Inc. | 
|---|
 | 8 | # Copyright (c) 1998-1999 by Scriptics Corporation. | 
|---|
 | 9 | # | 
|---|
 | 10 | # See the file "license.terms" for information on usage and redistribution | 
|---|
 | 11 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. | 
|---|
 | 12 | # | 
|---|
 | 13 | # RCS: @(#) $Id: winFCmd.test,v 1.42 2007/02/20 15:36:47 patthoyts Exp $ | 
|---|
 | 14 | # | 
|---|
 | 15 |  | 
|---|
 | 16 | if {[lsearch [namespace children] ::tcltest] == -1} { | 
|---|
 | 17 |     package require tcltest | 
|---|
 | 18 |     namespace import -force ::tcltest::* | 
|---|
 | 19 | } | 
|---|
 | 20 |  | 
|---|
 | 21 | # Initialise the test constraints | 
|---|
 | 22 |  | 
|---|
 | 23 | testConstraint win2000orXP 0 | 
|---|
 | 24 | testConstraint winOlderThan2000 0 | 
|---|
 | 25 | testConstraint testvolumetype [llength [info commands testvolumetype]] | 
|---|
 | 26 | testConstraint testfile       [llength [info commands testfile]] | 
|---|
 | 27 | testConstraint testchmod      [llength [info commands testchmod]] | 
|---|
 | 28 | testConstraint cdrom 0 | 
|---|
 | 29 | testConstraint exdev 0 | 
|---|
 | 30 | testConstraint longFileNames 0 | 
|---|
 | 31 |  | 
|---|
 | 32 | proc createfile {file {string a}} { | 
|---|
 | 33 |     set f [open $file w] | 
|---|
 | 34 |     puts -nonewline $f $string | 
|---|
 | 35 |     close $f | 
|---|
 | 36 |     return $string | 
|---|
 | 37 | } | 
|---|
 | 38 |  | 
|---|
 | 39 | proc contents {file} { | 
|---|
 | 40 |     set f [open $file r] | 
|---|
 | 41 |     set r [read $f] | 
|---|
 | 42 |     close $f | 
|---|
 | 43 |     set r | 
|---|
 | 44 | } | 
|---|
 | 45 |  | 
|---|
 | 46 | proc cleanup {args} { | 
|---|
 | 47 |     foreach p ". $args" { | 
|---|
 | 48 |         set x "" | 
|---|
 | 49 |         catch { | 
|---|
 | 50 |             set x [glob -directory $p tf* td*] | 
|---|
 | 51 |         } | 
|---|
 | 52 |         if {$x != ""} { | 
|---|
 | 53 |             catch {file delete -force -- {*}$x} | 
|---|
 | 54 |         } | 
|---|
 | 55 |     } | 
|---|
 | 56 | } | 
|---|
 | 57 |  | 
|---|
 | 58 | if {[testConstraint winOnly]} { | 
|---|
 | 59 |     if {[testConstraint nt] && [string index $tcl_platform(osVersion) 0]==5} { | 
|---|
 | 60 |         # Warning: Win 6 will break this! | 
|---|
 | 61 |         testConstraint win2000orXP 1 | 
|---|
 | 62 |     } else { | 
|---|
 | 63 |         testConstraint winOlderThan2000 1 | 
|---|
 | 64 |     } | 
|---|
 | 65 | } | 
|---|
 | 66 |  | 
|---|
 | 67 | # find a CD-ROM so we can test read-only filesystems. | 
|---|
 | 68 |  | 
|---|
 | 69 | proc findfile {dir} { | 
|---|
 | 70 |     foreach p [glob -directory $dir *] { | 
|---|
 | 71 |         if {[file type $p] == "file"} { | 
|---|
 | 72 |             return $p | 
|---|
 | 73 |         } | 
|---|
 | 74 |     } | 
|---|
 | 75 |     foreach p [glob -directory $dir *] { | 
|---|
 | 76 |         if {[file type $p] == "directory"} { | 
|---|
 | 77 |             set f [findfile $p] | 
|---|
 | 78 |             if {$f != ""} { | 
|---|
 | 79 |                 return $f | 
|---|
 | 80 |             } | 
|---|
 | 81 |         } | 
|---|
 | 82 |     } | 
|---|
 | 83 |     return "" | 
|---|
 | 84 | } | 
|---|
 | 85 |  | 
|---|
 | 86 | if {[testConstraint testvolumetype]} { | 
|---|
 | 87 |     foreach p {d e f g h i j k l m n o p q r s t u v w x y z} { | 
|---|
 | 88 |         if {![catch {testvolumetype ${p}:} result] && $result eq "CDFS"} { | 
|---|
 | 89 |             set cdrom ${p}: | 
|---|
 | 90 |             set cdfile [findfile $cdrom] | 
|---|
 | 91 |             testConstraint cdrom 1 | 
|---|
 | 92 |             break | 
|---|
 | 93 |         } | 
|---|
 | 94 |     } | 
|---|
 | 95 | } | 
|---|
 | 96 |  | 
|---|
 | 97 | # NB: filename is chosen to be short but unlikely to clash with other apps | 
|---|
 | 98 | if {[file exists c:/] && [file exists d:/]} { | 
|---|
 | 99 |     catch {file delete d:/TclTmpF.1} | 
|---|
 | 100 |     if {[catch {close [open d:/TclTmpF.1 w]}] == 0} { | 
|---|
 | 101 |         file delete d:/TclTmpF.1 | 
|---|
 | 102 |         testConstraint exdev 1 | 
|---|
 | 103 |     } | 
|---|
 | 104 | } | 
|---|
 | 105 |  | 
|---|
 | 106 | file delete -force -- td1 | 
|---|
 | 107 | if {![catch {open td1 w} testfile]} { | 
|---|
 | 108 |     close $testfile | 
|---|
 | 109 |     testConstraint longFileNames 1 | 
|---|
 | 110 |     file delete -force -- td1 | 
|---|
 | 111 | } | 
|---|
 | 112 |  | 
|---|
 | 113 | # A really long file name | 
|---|
 | 114 | # length of longname is 1216 chars, which should be greater than any static | 
|---|
 | 115 | # buffer or allowable filename. | 
|---|
 | 116 |  | 
|---|
 | 117 | set longname "abcdefghihjllmnopqrstuvwxyz01234567890" | 
|---|
 | 118 | append longname $longname | 
|---|
 | 119 | append longname $longname | 
|---|
 | 120 | append longname $longname | 
|---|
 | 121 | append longname $longname | 
|---|
 | 122 | append longname $longname | 
|---|
 | 123 |  | 
|---|
 | 124 | # Uses the "testfile" command instead of the "file" command.  The "file" | 
|---|
 | 125 | # command provides several layers of sanity checks on the arguments and | 
|---|
 | 126 | # it can be difficult to actually forward "insane" arguments to the | 
|---|
 | 127 | # low-level posix emulation layer. | 
|---|
 | 128 |  | 
|---|
 | 129 | test winFCmd-1.1 {TclpRenameFile: errno: EACCES} {win cdrom testfile} { | 
|---|
 | 130 |     list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg | 
|---|
 | 131 | } {1 EACCES} | 
|---|
 | 132 | test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} {win testfile} { | 
|---|
 | 133 |     cleanup | 
|---|
 | 134 |     file mkdir td1/td2/td3 | 
|---|
 | 135 |     file mkdir td2 | 
|---|
 | 136 |     list [catch {testfile mv td2 td1/td2} msg] $msg | 
|---|
 | 137 | } {1 EEXIST}  | 
|---|
 | 138 | test winFCmd-1.3 {TclpRenameFile: errno: EINVAL} {win testfile} { | 
|---|
 | 139 |     cleanup | 
|---|
 | 140 |     list [catch {testfile mv / td1} msg] $msg | 
|---|
 | 141 | } {1 EINVAL} | 
|---|
 | 142 | test winFCmd-1.4 {TclpRenameFile: errno: EINVAL} {win testfile} { | 
|---|
 | 143 |     cleanup | 
|---|
 | 144 |     file mkdir td1 | 
|---|
 | 145 |     list [catch {testfile mv td1 td1/td2} msg] $msg | 
|---|
 | 146 | } {1 EINVAL} | 
|---|
 | 147 | test winFCmd-1.5 {TclpRenameFile: errno: EISDIR} {win testfile} { | 
|---|
 | 148 |     cleanup | 
|---|
 | 149 |     file mkdir td1 | 
|---|
 | 150 |     createfile tf1 | 
|---|
 | 151 |     list [catch {testfile mv tf1 td1} msg] $msg | 
|---|
 | 152 | } {1 EISDIR} | 
|---|
 | 153 | test winFCmd-1.6 {TclpRenameFile: errno: ENOENT} {win testfile} { | 
|---|
 | 154 |     cleanup | 
|---|
 | 155 |     list [catch {testfile mv tf1 tf2} msg] $msg | 
|---|
 | 156 | } {1 ENOENT} | 
|---|
 | 157 | test winFCmd-1.7 {TclpRenameFile: errno: ENOENT} {win testfile} { | 
|---|
 | 158 |     cleanup | 
|---|
 | 159 |     list [catch {testfile mv "" tf2} msg] $msg | 
|---|
 | 160 | } {1 ENOENT} | 
|---|
 | 161 | test winFCmd-1.8 {TclpRenameFile: errno: ENOENT} {win testfile} { | 
|---|
 | 162 |     cleanup | 
|---|
 | 163 |     createfile tf1 | 
|---|
 | 164 |     list [catch {testfile mv tf1 ""} msg] $msg | 
|---|
 | 165 | } {1 ENOENT} | 
|---|
 | 166 | test winFCmd-1.9 {TclpRenameFile: errno: ENOTDIR} {win testfile} { | 
|---|
 | 167 |     cleanup | 
|---|
 | 168 |     file mkdir td1 | 
|---|
 | 169 |     createfile tf1 | 
|---|
 | 170 |     list [catch {testfile mv td1 tf1} msg] $msg | 
|---|
 | 171 | } {1 ENOTDIR} | 
|---|
 | 172 | test winFCmd-1.10 {TclpRenameFile: errno: EXDEV} {win exdev testfile} { | 
|---|
 | 173 |     file delete -force d:/tf1 | 
|---|
 | 174 |     file mkdir c:/tf1 | 
|---|
 | 175 |     set msg [list [catch {testfile mv c:/tf1 d:/tf1} msg] $msg] | 
|---|
 | 176 |     file delete -force c:/tf1 | 
|---|
 | 177 |     set msg | 
|---|
 | 178 | } {1 EXDEV} | 
|---|
 | 179 | test winFCmd-1.11 {TclpRenameFile: errno: EACCES} {win testfile} { | 
|---|
 | 180 |     cleanup | 
|---|
 | 181 |     set fd [open tf1 w] | 
|---|
 | 182 |     set msg [list [catch {testfile mv tf1 tf2} msg] $msg] | 
|---|
 | 183 |     close $fd | 
|---|
 | 184 |     set msg | 
|---|
 | 185 | } {1 EACCES} | 
|---|
 | 186 | test winFCmd-1.12 {TclpRenameFile: errno: EACCES} {win testfile} { | 
|---|
 | 187 |     cleanup | 
|---|
 | 188 |     createfile tf1 | 
|---|
 | 189 |     set fd [open tf2 w] | 
|---|
 | 190 |     set msg [list [catch {testfile mv tf1 tf2} msg] $msg] | 
|---|
 | 191 |     close $fd | 
|---|
 | 192 |     set msg | 
|---|
 | 193 | } {1 EACCES} | 
|---|
 | 194 | test winFCmd-1.13 {TclpRenameFile: errno: EACCES} {win win2000orXP testfile} { | 
|---|
 | 195 |     cleanup | 
|---|
 | 196 |     list [catch {testfile mv nul tf1} msg] $msg | 
|---|
 | 197 | } {1 EINVAL} | 
|---|
 | 198 | test winFCmd-1.13.1 {TclpRenameFile: errno: EACCES} {win nt winOlderThan2000 testfile} { | 
|---|
 | 199 |     cleanup | 
|---|
 | 200 |     list [catch {testfile mv nul tf1} msg] $msg | 
|---|
 | 201 | } {1 EACCES} | 
|---|
 | 202 | test winFCmd-1.13.2 {TclpRenameFile: errno: ENOENT} {win 95 testfile} { | 
|---|
 | 203 |     cleanup | 
|---|
 | 204 |     list [catch {testfile mv nul tf1} msg] $msg | 
|---|
 | 205 | } {1 ENOENT} | 
|---|
 | 206 | test winFCmd-1.14 {TclpRenameFile: errno: EACCES} {win 95 testfile} { | 
|---|
 | 207 |     cleanup | 
|---|
 | 208 |     createfile tf1 | 
|---|
 | 209 |     list [catch {testfile mv tf1 nul} msg] $msg | 
|---|
 | 210 | } {1 EACCES} | 
|---|
 | 211 | test winFCmd-1.15 {TclpRenameFile: errno: EEXIST} {win nt testfile} { | 
|---|
 | 212 |     cleanup | 
|---|
 | 213 |     createfile tf1 | 
|---|
 | 214 |     list [catch {testfile mv tf1 nul} msg] $msg | 
|---|
 | 215 | } {1 EEXIST} | 
|---|
 | 216 | test winFCmd-1.16 {TclpRenameFile: MoveFile() != FALSE} {win testfile} { | 
|---|
 | 217 |     cleanup | 
|---|
 | 218 |     createfile tf1 tf1 | 
|---|
 | 219 |     testfile mv tf1 tf2 | 
|---|
 | 220 |     list [file exists tf1] [contents tf2] | 
|---|
 | 221 | } {0 tf1} | 
|---|
 | 222 | test winFCmd-1.17 {TclpRenameFile: MoveFile() == FALSE} {win testfile} { | 
|---|
 | 223 |     cleanup | 
|---|
 | 224 |     list [catch {testfile mv tf1 tf2} msg] $msg | 
|---|
 | 225 | } {1 ENOENT}  | 
|---|
 | 226 | test winFCmd-1.18 {TclpRenameFile: srcAttr == -1} {win testfile} { | 
|---|
 | 227 |     cleanup | 
|---|
 | 228 |     list [catch {testfile mv tf1 tf2} msg] $msg | 
|---|
 | 229 | } {1 ENOENT}  | 
|---|
 | 230 | test winFCmd-1.19 {TclpRenameFile: errno == EACCES} {win win2000orXP testfile} { | 
|---|
 | 231 |     cleanup | 
|---|
 | 232 |     list [catch {testfile mv nul tf1} msg] $msg | 
|---|
 | 233 | } {1 EINVAL} | 
|---|
 | 234 | test winFCmd-1.19.1 {TclpRenameFile: errno == EACCES} {win nt winOlderThan2000 testfile} { | 
|---|
 | 235 |     cleanup | 
|---|
 | 236 |     list [catch {testfile mv nul tf1} msg] $msg | 
|---|
 | 237 | } {1 EACCES} | 
|---|
 | 238 | test winFCmd-1.19.2 {TclpRenameFile: errno == ENOENT} {win 95 testfile} { | 
|---|
 | 239 |     cleanup | 
|---|
 | 240 |     list [catch {testfile mv nul tf1} msg] $msg | 
|---|
 | 241 | } {1 ENOENT} | 
|---|
 | 242 | test winFCmd-1.20 {TclpRenameFile: src is dir} {win nt testfile} { | 
|---|
 | 243 |     # under 95, this would actually succeed and move the current dir out from  | 
|---|
 | 244 |     # under the current process! | 
|---|
 | 245 |     cleanup | 
|---|
 | 246 |     file delete /tf1 | 
|---|
 | 247 |     list [catch {testfile mv [pwd] /tf1} msg] $msg | 
|---|
 | 248 | } {1 EACCES} | 
|---|
 | 249 | test winFCmd-1.21 {TclpRenameFile: long src} {win testfile} { | 
|---|
 | 250 |     cleanup | 
|---|
 | 251 |     list [catch {testfile mv $longname tf1} msg] $msg | 
|---|
 | 252 | } {1 ENAMETOOLONG} | 
|---|
 | 253 | test winFCmd-1.22 {TclpRenameFile: long dst} {win testfile} { | 
|---|
 | 254 |     cleanup | 
|---|
 | 255 |     createfile tf1 | 
|---|
 | 256 |     list [catch {testfile mv tf1 $longname} msg] $msg | 
|---|
 | 257 | } {1 ENAMETOOLONG} | 
|---|
 | 258 | test winFCmd-1.23 {TclpRenameFile: move dir into self} {win testfile} { | 
|---|
 | 259 |     cleanup | 
|---|
 | 260 |     file mkdir td1 | 
|---|
 | 261 |     list [catch {testfile mv [pwd]/td1 td1/td2} msg] $msg | 
|---|
 | 262 | } {1 EINVAL} | 
|---|
 | 263 | test winFCmd-1.24 {TclpRenameFile: move a root dir} {win testfile} { | 
|---|
 | 264 |     cleanup | 
|---|
 | 265 |     list [catch {testfile mv / c:/} msg] $msg | 
|---|
 | 266 | } {1 EINVAL} | 
|---|
 | 267 | test winFCmd-1.25 {TclpRenameFile: cross file systems} {win cdrom testfile} { | 
|---|
 | 268 |     cleanup | 
|---|
 | 269 |     file mkdir td1 | 
|---|
 | 270 |     list [catch {testfile mv td1 $cdrom/td1} msg] $msg | 
|---|
 | 271 | } {1 EXDEV}  | 
|---|
 | 272 | test winFCmd-1.26 {TclpRenameFile: readonly fs} {win cdrom testfile} { | 
|---|
 | 273 |     cleanup | 
|---|
 | 274 |     list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg | 
|---|
 | 275 | } {1 EACCES} | 
|---|
 | 276 | test winFCmd-1.27 {TclpRenameFile: open file} {win testfile} { | 
|---|
 | 277 |     cleanup | 
|---|
 | 278 |     set fd [open tf1 w] | 
|---|
 | 279 |     set msg [list [catch {testfile mv tf1 tf2} msg] $msg] | 
|---|
 | 280 |     close $fd | 
|---|
 | 281 |     set msg | 
|---|
 | 282 | } {1 EACCES}     | 
|---|
 | 283 | test winFCmd-1.28 {TclpRenameFile: errno == EEXIST} {win testfile} { | 
|---|
 | 284 |     cleanup | 
|---|
 | 285 |     createfile tf1 | 
|---|
 | 286 |     createfile tf2 | 
|---|
 | 287 |     testfile mv tf1 tf2 | 
|---|
 | 288 |     list [file exists tf1] [file exists tf2] | 
|---|
 | 289 | } {0 1} | 
|---|
 | 290 | test winFCmd-1.29 {TclpRenameFile: src is dir} {win testfile} { | 
|---|
 | 291 |     cleanup | 
|---|
 | 292 |     file mkdir td1 | 
|---|
 | 293 |     createfile tf1 | 
|---|
 | 294 |     list [catch {testfile mv td1 tf1} msg] $msg | 
|---|
 | 295 | } {1 ENOTDIR}  | 
|---|
 | 296 | test winFCmd-1.30 {TclpRenameFile: dst is dir} {win testfile} { | 
|---|
 | 297 |     cleanup | 
|---|
 | 298 |     file mkdir td1 | 
|---|
 | 299 |     file mkdir td2/td2 | 
|---|
 | 300 |     list [catch {testfile mv td1 td2} msg] $msg | 
|---|
 | 301 | } {1 EEXIST} | 
|---|
 | 302 | test winFCmd-1.31 {TclpRenameFile: TclpRemoveDirectory fails} {win testfile} { | 
|---|
 | 303 |     cleanup | 
|---|
 | 304 |     file mkdir td1 | 
|---|
 | 305 |     file mkdir td2/td2 | 
|---|
 | 306 |     list [catch {testfile mv td1 td2} msg] $msg | 
|---|
 | 307 | } {1 EEXIST} | 
|---|
 | 308 | test winFCmd-1.32 {TclpRenameFile: TclpRemoveDirectory succeeds} {win testfile} { | 
|---|
 | 309 |     cleanup | 
|---|
 | 310 |     file mkdir td1/td2 | 
|---|
 | 311 |     file mkdir td2 | 
|---|
 | 312 |     testfile mv td1 td2 | 
|---|
 | 313 |     list [file exists td1] [file exists td2] [file exists td2/td2] | 
|---|
 | 314 | } {0 1 1} | 
|---|
 | 315 | test winFCmd-1.33 {TclpRenameFile: After removing dst dir, MoveFile fails} \ | 
|---|
 | 316 |         {win exdev testfile testchmod} { | 
|---|
 | 317 |     file mkdir d:/td1 | 
|---|
 | 318 |     testchmod 000 d:/td1 | 
|---|
 | 319 |     file mkdir c:/tf1 | 
|---|
 | 320 |     set msg [list [catch {testfile mv c:/tf1 d:/td1} msg] $msg] | 
|---|
 | 321 |     set msg "$msg [file writable d:/td1]" | 
|---|
 | 322 |     file delete d:/td1 | 
|---|
 | 323 |     file delete -force c:/tf1 | 
|---|
 | 324 |     set msg | 
|---|
 | 325 | } {1 EXDEV 0} | 
|---|
 | 326 | test winFCmd-1.34 {TclpRenameFile: src is dir, dst is not} {win testfile} { | 
|---|
 | 327 |     file mkdir td1 | 
|---|
 | 328 |     createfile tf1 | 
|---|
 | 329 |     list [catch {testfile mv td1 tf1} msg] $msg | 
|---|
 | 330 | } {1 ENOTDIR} | 
|---|
 | 331 | test winFCmd-1.35 {TclpRenameFile: src is not dir, dst is} {win testfile} { | 
|---|
 | 332 |     file mkdir td1 | 
|---|
 | 333 |     createfile tf1 | 
|---|
 | 334 |     list [catch {testfile mv tf1 td1} msg] $msg | 
|---|
 | 335 | } {1 EISDIR} | 
|---|
 | 336 | test winFCmd-1.36 {TclpRenameFile: src and dst not dir} {win testfile} { | 
|---|
 | 337 |     createfile tf1 tf1 | 
|---|
 | 338 |     createfile tf2 tf2 | 
|---|
 | 339 |     testfile mv tf1 tf2 | 
|---|
 | 340 |     contents tf2 | 
|---|
 | 341 | } {tf1} | 
|---|
 | 342 | test winFCmd-1.37 {TclpRenameFile: need to restore temp file} {win emptyTest} { | 
|---|
 | 343 |     # Can't figure out how to cause this.  | 
|---|
 | 344 |     # Need a file that can't be copied. | 
|---|
 | 345 | } {} | 
|---|
 | 346 |  | 
|---|
 | 347 | test winFCmd-2.1 {TclpCopyFile: errno: EACCES} {win cdrom testfile} { | 
|---|
 | 348 |     cleanup | 
|---|
 | 349 |     list [catch {testfile cp $cdfile $cdrom/dummy~~.fil} msg] $msg | 
|---|
 | 350 | } {1 EACCES} | 
|---|
 | 351 | test winFCmd-2.2 {TclpCopyFile: errno: EISDIR} {win testfile} { | 
|---|
 | 352 |     cleanup | 
|---|
 | 353 |     file mkdir td1 | 
|---|
 | 354 |     list [catch {testfile cp td1 tf1} msg] $msg | 
|---|
 | 355 | } {1 EISDIR} | 
|---|
 | 356 | test winFCmd-2.3 {TclpCopyFile: errno: EISDIR} {win testfile} { | 
|---|
 | 357 |     cleanup | 
|---|
 | 358 |     createfile tf1 | 
|---|
 | 359 |     file mkdir td1 | 
|---|
 | 360 |     list [catch {testfile cp tf1 td1} msg] $msg | 
|---|
 | 361 | } {1 EISDIR} | 
|---|
 | 362 | test winFCmd-2.4 {TclpCopyFile: errno: ENOENT} {win testfile} { | 
|---|
 | 363 |     cleanup | 
|---|
 | 364 |     list [catch {testfile cp tf1 tf2} msg] $msg | 
|---|
 | 365 | } {1 ENOENT} | 
|---|
 | 366 | test winFCmd-2.5 {TclpCopyFile: errno: ENOENT} {win testfile} { | 
|---|
 | 367 |     cleanup | 
|---|
 | 368 |     list [catch {testfile cp "" tf2} msg] $msg | 
|---|
 | 369 | } {1 ENOENT} | 
|---|
 | 370 | test winFCmd-2.6 {TclpCopyFile: errno: ENOENT} {win testfile} { | 
|---|
 | 371 |     cleanup | 
|---|
 | 372 |     createfile tf1 | 
|---|
 | 373 |     list [catch {testfile cp tf1 ""} msg] $msg | 
|---|
 | 374 | } {1 ENOENT} | 
|---|
 | 375 | test winFCmd-2.7 {TclpCopyFile: errno: EACCES} {win 95 testfile} { | 
|---|
 | 376 |     cleanup | 
|---|
 | 377 |     createfile tf1 | 
|---|
 | 378 |     set fd [open tf2 w] | 
|---|
 | 379 |     set msg [list [catch {testfile cp tf1 tf2} msg] $msg] | 
|---|
 | 380 |     close $fd | 
|---|
 | 381 |     set msg | 
|---|
 | 382 | } {1 EACCES} | 
|---|
 | 383 | test winFCmd-2.8 {TclpCopyFile: errno: EACCES} {win win2000orXP testfile} { | 
|---|
 | 384 |     cleanup | 
|---|
 | 385 |     list [catch {testfile cp nul tf1} msg] $msg | 
|---|
 | 386 | } {1 EINVAL} | 
|---|
 | 387 | test winFCmd-2.8.1 {TclpCopyFile: errno: EACCES} {win nt winOlderThan2000 testfile} { | 
|---|
 | 388 |     cleanup | 
|---|
 | 389 |     list [catch {testfile cp nul tf1} msg] $msg | 
|---|
 | 390 | } {1 EACCES} | 
|---|
 | 391 | test winFCmd-2.9 {TclpCopyFile: errno: ENOENT} {win 95 testfile} { | 
|---|
 | 392 |     cleanup | 
|---|
 | 393 |     list [catch {testfile cp nul tf1} msg] $msg | 
|---|
 | 394 | } {1 ENOENT} | 
|---|
 | 395 | test winFCmd-2.10 {TclpCopyFile: CopyFile succeeds} {win testfile} { | 
|---|
 | 396 |     cleanup | 
|---|
 | 397 |     createfile tf1 tf1 | 
|---|
 | 398 |     testfile cp tf1 tf2 | 
|---|
 | 399 |     list [contents tf1] [contents tf2] | 
|---|
 | 400 | } {tf1 tf1} | 
|---|
 | 401 | test winFCmd-2.11 {TclpCopyFile: CopyFile succeeds} {win testfile} { | 
|---|
 | 402 |     cleanup | 
|---|
 | 403 |     createfile tf1 tf1 | 
|---|
 | 404 |     createfile tf2 tf2 | 
|---|
 | 405 |     testfile cp tf1 tf2 | 
|---|
 | 406 |     list [contents tf1] [contents tf2] | 
|---|
 | 407 | } {tf1 tf1} | 
|---|
 | 408 | test winFCmd-2.12 {TclpCopyFile: CopyFile succeeds} {win testfile} { | 
|---|
 | 409 |     cleanup | 
|---|
 | 410 |     createfile tf1 tf1 | 
|---|
 | 411 |     testchmod 000 tf1 | 
|---|
 | 412 |     testfile cp tf1 tf2 | 
|---|
 | 413 |     list [contents tf2] [file writable tf2] | 
|---|
 | 414 | } {tf1 0} | 
|---|
 | 415 | test winFCmd-2.13 {TclpCopyFile: CopyFile fails} {win testfile} { | 
|---|
 | 416 |     cleanup | 
|---|
 | 417 |     createfile tf1 | 
|---|
 | 418 |     file mkdir td1 | 
|---|
 | 419 |     list [catch {testfile cp tf1 td1} msg] $msg | 
|---|
 | 420 | } {1 EISDIR}  | 
|---|
 | 421 | test winFCmd-2.14 {TclpCopyFile: errno == EACCES} {win testfile} { | 
|---|
 | 422 |     cleanup | 
|---|
 | 423 |     file mkdir td1 | 
|---|
 | 424 |     list [catch {testfile cp td1 tf1} msg] $msg | 
|---|
 | 425 | } {1 EISDIR} | 
|---|
 | 426 | test winFCmd-2.15 {TclpCopyFile: src is directory} {win testfile} { | 
|---|
 | 427 |     cleanup | 
|---|
 | 428 |     file mkdir td1 | 
|---|
 | 429 |     list [catch {testfile cp td1 tf1} msg] $msg | 
|---|
 | 430 | } {1 EISDIR} | 
|---|
 | 431 | test winFCmd-2.16 {TclpCopyFile: dst is directory} {win testfile} { | 
|---|
 | 432 |     cleanup | 
|---|
 | 433 |     createfile tf1 | 
|---|
 | 434 |     file mkdir td1 | 
|---|
 | 435 |     list [catch {testfile cp tf1 td1} msg] $msg | 
|---|
 | 436 | } {1 EISDIR} | 
|---|
 | 437 | test winFCmd-2.17 {TclpCopyFile: dst is readonly} {win testfile testchmod} { | 
|---|
 | 438 |     cleanup | 
|---|
 | 439 |     createfile tf1 tf1 | 
|---|
 | 440 |     createfile tf2 tf2 | 
|---|
 | 441 |     testchmod 000 tf2 | 
|---|
 | 442 |     testfile cp tf1 tf2 | 
|---|
 | 443 |     list [file writable tf2] [contents tf2] | 
|---|
 | 444 | } {1 tf1} | 
|---|
 | 445 | test winFCmd-2.18 {TclpCopyFile: still can't copy onto dst} {win 95 testfile testchmod} { | 
|---|
 | 446 |     cleanup | 
|---|
 | 447 |     createfile tf1 | 
|---|
 | 448 |     createfile tf2 | 
|---|
 | 449 |     testchmod 000 tf2 | 
|---|
 | 450 |     set fd [open tf2] | 
|---|
 | 451 |     set msg [list [catch {testfile cp tf1 tf2} msg] $msg] | 
|---|
 | 452 |     close $fd | 
|---|
 | 453 |     set msg "$msg [file writable tf2]" | 
|---|
 | 454 | } {1 EACCES 0}     | 
|---|
 | 455 |  | 
|---|
 | 456 | test winFCmd-3.1 {TclpDeleteFile: errno: EACCES} {win cdrom testfile} { | 
|---|
 | 457 |     list [catch {testfile rm $cdfile $cdrom/dummy~~.fil} msg] $msg | 
|---|
 | 458 | } {1 EACCES} | 
|---|
 | 459 | test winFCmd-3.2 {TclpDeleteFile: errno: EISDIR} {win testfile} { | 
|---|
 | 460 |     cleanup | 
|---|
 | 461 |     file mkdir td1 | 
|---|
 | 462 |     list [catch {testfile rm td1} msg] $msg | 
|---|
 | 463 | } {1 EISDIR}  | 
|---|
 | 464 | test winFCmd-3.3 {TclpDeleteFile: errno: ENOENT} {win testfile} { | 
|---|
 | 465 |     cleanup | 
|---|
 | 466 |     list [catch {testfile rm tf1} msg] $msg | 
|---|
 | 467 | } {1 ENOENT} | 
|---|
 | 468 | test winFCmd-3.4 {TclpDeleteFile: errno: ENOENT} {win testfile} { | 
|---|
 | 469 |     cleanup | 
|---|
 | 470 |     list [catch {testfile rm ""} msg] $msg | 
|---|
 | 471 | } {1 ENOENT} | 
|---|
 | 472 | test winFCmd-3.5 {TclpDeleteFile: errno: EACCES} {win testfile} { | 
|---|
 | 473 |     cleanup | 
|---|
 | 474 |     set fd [open tf1 w] | 
|---|
 | 475 |     set msg [list [catch {testfile rm tf1} msg] $msg] | 
|---|
 | 476 |     close $fd | 
|---|
 | 477 |     set msg | 
|---|
 | 478 | } {1 EACCES} | 
|---|
 | 479 | test winFCmd-3.6 {TclpDeleteFile: errno: EACCES} {win testfile} { | 
|---|
 | 480 |     cleanup | 
|---|
 | 481 |     list [catch {testfile rm nul} msg] $msg | 
|---|
 | 482 | } {1 EACCES} | 
|---|
 | 483 | test winFCmd-3.7 {TclpDeleteFile: DeleteFile succeeds} {win testfile} { | 
|---|
 | 484 |     cleanup | 
|---|
 | 485 |     createfile tf1 | 
|---|
 | 486 |     testfile rm tf1 | 
|---|
 | 487 |     file exists tf1 | 
|---|
 | 488 | } {0} | 
|---|
 | 489 | test winFCmd-3.8 {TclpDeleteFile: DeleteFile fails} {win testfile} { | 
|---|
 | 490 |     cleanup | 
|---|
 | 491 |     file mkdir td1 | 
|---|
 | 492 |     list [catch {testfile rm td1} msg] $msg | 
|---|
 | 493 | } {1 EISDIR} | 
|---|
 | 494 | test winFCmd-3.9 {TclpDeleteFile: errno == EACCES} {win testfile} { | 
|---|
 | 495 |     cleanup | 
|---|
 | 496 |     set fd [open tf1 w] | 
|---|
 | 497 |     set msg [list [catch {testfile rm tf1} msg] $msg] | 
|---|
 | 498 |     close $fd | 
|---|
 | 499 |     set msg | 
|---|
 | 500 | } {1 EACCES} | 
|---|
 | 501 | test winFCmd-3.10 {TclpDeleteFile: path is readonly} {win testfile testchmod} { | 
|---|
 | 502 |     cleanup | 
|---|
 | 503 |     createfile tf1 | 
|---|
 | 504 |     testchmod 000 tf1 | 
|---|
 | 505 |     testfile rm tf1 | 
|---|
 | 506 |     file exists tf1 | 
|---|
 | 507 | } {0} | 
|---|
 | 508 | test winFCmd-3.11 {TclpDeleteFile: still can't remove path} {win testfile testchmod} { | 
|---|
 | 509 |     cleanup | 
|---|
 | 510 |     set fd [open tf1 w] | 
|---|
 | 511 |     testchmod 000 tf1 | 
|---|
 | 512 |     set msg [list [catch {testfile rm tf1} msg] $msg] | 
|---|
 | 513 |     close $fd | 
|---|
 | 514 |     set msg | 
|---|
 | 515 | } {1 EACCES} | 
|---|
 | 516 |  | 
|---|
 | 517 | test winFCmd-4.1 {TclpCreateDirectory: errno: EACCES} {win nt cdrom testfile} { | 
|---|
 | 518 |     list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg | 
|---|
 | 519 | } {1 EACCES} | 
|---|
 | 520 | test winFCmd-4.2 {TclpCreateDirectory: errno: EACCES} {win 95 cdrom testfile} { | 
|---|
 | 521 |     list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg | 
|---|
 | 522 | } {1 ENOSPC} | 
|---|
 | 523 | test winFCmd-4.3 {TclpCreateDirectory: errno: EEXIST} {win testfile} { | 
|---|
 | 524 |     cleanup | 
|---|
 | 525 |     file mkdir td1 | 
|---|
 | 526 |     list [catch {testfile mkdir td1} msg] $msg | 
|---|
 | 527 | } {1 EEXIST} | 
|---|
 | 528 | test winFCmd-4.4 {TclpCreateDirectory: errno: ENOENT} {win testfile} { | 
|---|
 | 529 |     cleanup | 
|---|
 | 530 |     list [catch {testfile mkdir td1/td2} msg] $msg | 
|---|
 | 531 | } {1 ENOENT} | 
|---|
 | 532 | test winFCmd-4.5 {TclpCreateDirectory: CreateDirectory succeeds} {win testfile} { | 
|---|
 | 533 |     cleanup | 
|---|
 | 534 |     testfile mkdir td1 | 
|---|
 | 535 |     file type td1 | 
|---|
 | 536 | } {directory} | 
|---|
 | 537 |  | 
|---|
 | 538 | test winFCmd-5.1 {TclpCopyDirectory: calls TraverseWinTree} {win testfile} { | 
|---|
 | 539 |     cleanup | 
|---|
 | 540 |     file mkdir td1 | 
|---|
 | 541 |     testfile cpdir td1 td2 | 
|---|
 | 542 |     list [file type td1] [file type td2] | 
|---|
 | 543 | } {directory directory} | 
|---|
 | 544 |  | 
|---|
 | 545 | test winFCmd-6.1 {TclpRemoveDirectory: errno: EACCES} {win testfile testchmod} { | 
|---|
 | 546 |     cleanup | 
|---|
 | 547 |     file mkdir td1 | 
|---|
 | 548 |     testchmod 000 td1 | 
|---|
 | 549 |     testfile rmdir td1 | 
|---|
 | 550 |     file exists td1 | 
|---|
 | 551 | } {0} | 
|---|
 | 552 | test winFCmd-6.2 {TclpRemoveDirectory: errno: EEXIST} {win testfile} { | 
|---|
 | 553 |     cleanup | 
|---|
 | 554 |     file mkdir td1/td2 | 
|---|
 | 555 |     list [catch {testfile rmdir td1} msg] [file tail $msg] | 
|---|
 | 556 | } {1 {td1 EEXIST}} | 
|---|
 | 557 | test winFCmd-6.3 {TclpRemoveDirectory: errno: EACCES} {win emptyTest} { | 
|---|
 | 558 |     # can't test this w/o removing everything on your hard disk first! | 
|---|
 | 559 |     # testfile rmdir / | 
|---|
 | 560 | } {} | 
|---|
 | 561 | test winFCmd-6.4 {TclpRemoveDirectory: errno: ENOENT} {win testfile} { | 
|---|
 | 562 |     cleanup | 
|---|
 | 563 |     list [catch {testfile rmdir td1} msg] [file tail $msg] | 
|---|
 | 564 | } {1 {td1 ENOENT}} | 
|---|
 | 565 | test winFCmd-6.5 {TclpRemoveDirectory: errno: ENOENT} {win testfile} { | 
|---|
 | 566 |     cleanup | 
|---|
 | 567 |     list [catch {testfile rmdir ""} msg] $msg | 
|---|
 | 568 | } {1 ENOENT} | 
|---|
 | 569 | test winFCmd-6.6 {TclpRemoveDirectory: errno: ENOTDIR} {win testfile} { | 
|---|
 | 570 |     cleanup | 
|---|
 | 571 |     createfile tf1 | 
|---|
 | 572 |     list [catch {testfile rmdir tf1} msg] [file tail $msg] | 
|---|
 | 573 | } {1 {tf1 ENOTDIR}} | 
|---|
 | 574 | test winFCmd-6.7 {TclpRemoveDirectory: RemoveDirectory succeeds} {win testfile} { | 
|---|
 | 575 |     cleanup | 
|---|
 | 576 |     file mkdir td1 | 
|---|
 | 577 |     testfile rmdir td1 | 
|---|
 | 578 |     file exists td1 | 
|---|
 | 579 | } {0} | 
|---|
 | 580 | test winFCmd-6.8 {TclpRemoveDirectory: RemoveDirectory fails} {win testfile} { | 
|---|
 | 581 |     cleanup | 
|---|
 | 582 |     createfile tf1 | 
|---|
 | 583 |     list [catch {testfile rmdir tf1} msg] [file tail $msg] | 
|---|
 | 584 | } {1 {tf1 ENOTDIR}} | 
|---|
 | 585 | test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} {win testfile testchmod} { | 
|---|
 | 586 |     cleanup | 
|---|
 | 587 |     file mkdir td1 | 
|---|
 | 588 |     testchmod 000 td1 | 
|---|
 | 589 |     testfile rmdir td1 | 
|---|
 | 590 |     file exists td1 | 
|---|
 | 591 | } {0} | 
|---|
 | 592 | test winFCmd-6.10 {TclpRemoveDirectory: attr == -1} {win 95 testfile} { | 
|---|
 | 593 |     cleanup | 
|---|
 | 594 |     list [catch {testfile rmdir nul} msg] $msg | 
|---|
 | 595 | } {1 {nul EACCES}} | 
|---|
 | 596 | test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} {win nt testfile} { | 
|---|
 | 597 |     cleanup | 
|---|
 | 598 |     set res [list [catch {testfile rmdir /} msg] $msg] | 
|---|
 | 599 |     # WinXP returns EEXIST, WinNT seems to return EACCES.  No policy | 
|---|
 | 600 |     # decision has been made as to which is correct. | 
|---|
 | 601 |     regsub {E(ACCES|EXIST)} $res "EACCES or EEXIST" | 
|---|
 | 602 | } [list 1 [list / EACCES or EEXIST]] | 
|---|
 | 603 | test winFCmd-6.12 {TclpRemoveDirectory: errno == EACCES} {win 95 testfile} { | 
|---|
 | 604 |     cleanup | 
|---|
 | 605 |     createfile tf1 | 
|---|
 | 606 |     set res [catch {testfile rmdir tf1} msg] | 
|---|
 | 607 |     # get rid of path | 
|---|
 | 608 |     set msg [list [file tail [lindex $msg 0]] [lindex $msg 1]] | 
|---|
 | 609 |     list $res $msg | 
|---|
 | 610 | } {1 {tf1 ENOTDIR}} | 
|---|
 | 611 | test winFCmd-6.13 {TclpRemoveDirectory: write-protected} {win testfile testchmod} { | 
|---|
 | 612 |     cleanup | 
|---|
 | 613 |     file mkdir td1 | 
|---|
 | 614 |     testchmod 000 td1 | 
|---|
 | 615 |     testfile rmdir td1 | 
|---|
 | 616 |     file exists td1 | 
|---|
 | 617 | } {0} | 
|---|
 | 618 | test winFCmd-6.14 {TclpRemoveDirectory: check if empty dir} {win 95 testfile} { | 
|---|
 | 619 |     cleanup | 
|---|
 | 620 |     file mkdir td1/td2 | 
|---|
 | 621 |     set res [catch {testfile rmdir td1} msg] | 
|---|
 | 622 |     # get rid of path | 
|---|
 | 623 |     set msg [list [file tail [lindex $msg 0]] [lindex $msg 1]] | 
|---|
 | 624 |     list $res $msg | 
|---|
 | 625 | } {1 {td1 EEXIST}} | 
|---|
 | 626 | test winFCmd-6.15 {TclpRemoveDirectory: !recursive} {win testfile} { | 
|---|
 | 627 |     cleanup | 
|---|
 | 628 |     file mkdir td1/td2 | 
|---|
 | 629 |     list [catch {testfile rmdir td1} msg] [file tail $msg] | 
|---|
 | 630 | } {1 {td1 EEXIST}} | 
|---|
 | 631 | test winFCmd-6.16 {TclpRemoveDirectory: recursive, but errno != EEXIST} {win testfile} { | 
|---|
 | 632 |     cleanup | 
|---|
 | 633 |     createfile tf1 | 
|---|
 | 634 |     list [catch {testfile rmdir -force tf1} msg] $msg | 
|---|
 | 635 | } {1 {tf1 ENOTDIR}} | 
|---|
 | 636 | test winFCmd-6.17 {TclpRemoveDirectory: calls TraverseWinTree} {win testfile} { | 
|---|
 | 637 |     cleanup | 
|---|
 | 638 |     file mkdir td1/td2 | 
|---|
 | 639 |     testfile rmdir -force td1 | 
|---|
 | 640 |     file exists td1 | 
|---|
 | 641 | } {0} | 
|---|
 | 642 |  | 
|---|
 | 643 | test winFCmd-7.1 {TraverseWinTree: targetPtr == NULL} {win testfile} { | 
|---|
 | 644 |     cleanup | 
|---|
 | 645 |     file mkdir td1/td2/td3 | 
|---|
 | 646 |     testfile rmdir -force td1 | 
|---|
 | 647 |     file exists td1 | 
|---|
 | 648 | } {0} | 
|---|
 | 649 | test winFCmd-7.2 {TraverseWinTree: targetPtr != NULL} {win testfile} { | 
|---|
 | 650 |     cleanup | 
|---|
 | 651 |     file mkdir td1/td2/td3 | 
|---|
 | 652 |     testfile cpdir td1 td2 | 
|---|
 | 653 |     list [file exists td1] [file exists td2] | 
|---|
 | 654 | } {1 1} | 
|---|
 | 655 | test winFCmd-7.3 {TraverseWinTree: sourceAttr == -1} {win testfile} { | 
|---|
 | 656 |     cleanup | 
|---|
 | 657 |     list [catch {testfile cpdir td1 td2} msg] $msg | 
|---|
 | 658 | } {1 {td1 ENOENT}} | 
|---|
 | 659 | test winFCmd-7.4 {TraverseWinTree: source isn't directory} {win testfile} { | 
|---|
 | 660 |     cleanup | 
|---|
 | 661 |     file mkdir td1 | 
|---|
 | 662 |     createfile td1/tf1 tf1 | 
|---|
 | 663 |     testfile cpdir td1 td2 | 
|---|
 | 664 |     contents td2/tf1 | 
|---|
 | 665 | } {tf1} | 
|---|
 | 666 | test winFCmd-7.5 {TraverseWinTree: call TraversalCopy: DOTREE_F} {win testfile} { | 
|---|
 | 667 |     cleanup | 
|---|
 | 668 |     file mkdir td1 | 
|---|
 | 669 |     createfile td1/tf1 tf1 | 
|---|
 | 670 |     testfile cpdir td1 td2 | 
|---|
 | 671 |     contents td2/tf1 | 
|---|
 | 672 | } {tf1} | 
|---|
 | 673 | test winFCmd-7.6 {TraverseWinTree: call TraversalDelete: DOTREE_F} {win testfile} { | 
|---|
 | 674 |     cleanup | 
|---|
 | 675 |     file mkdir td1 | 
|---|
 | 676 |     createfile td1/tf1 tf1 | 
|---|
 | 677 |     testfile rmdir -force td1 | 
|---|
 | 678 |     file exists td1 | 
|---|
 | 679 | } {0} | 
|---|
 | 680 | test winFCmd-7.7 {TraverseWinTree: append \ to source if necessary} {win testfile} { | 
|---|
 | 681 |     cleanup | 
|---|
 | 682 |     file mkdir td1 | 
|---|
 | 683 |     createfile td1/tf1 tf1 | 
|---|
 | 684 |     testfile cpdir td1 td2 | 
|---|
 | 685 |     contents td2/tf1 | 
|---|
 | 686 | } {tf1}     | 
|---|
 | 687 | test winFCmd-7.8 {TraverseWinTree: append \ to source if necessary} {win 95 cdrom testfile} { | 
|---|
 | 688 |     # cdrom can return either d:\ or D:/, but we only care about the errcode | 
|---|
 | 689 |     list [catch {testfile rmdir $cdrom/} msg] [lindex $msg 1] | 
|---|
 | 690 | } {1 EACCES} ; # was EEXIST, but changed for win98. | 
|---|
 | 691 | test winFCmd-7.9 {TraverseWinTree: append \ to source if necessary} {win nt cdrom testfile} { | 
|---|
 | 692 |     list [catch {testfile rmdir $cdrom/} msg]  [lindex $msg 1] | 
|---|
 | 693 | } {1 EACCES} | 
|---|
 | 694 | test winFCmd-7.10 {TraverseWinTree: can't read directory: handle == INVALID} \ | 
|---|
 | 695 |         {win emptyTest} { | 
|---|
 | 696 |     # can't make it happen | 
|---|
 | 697 | } {} | 
|---|
 | 698 | test winFCmd-7.11 {TraverseWinTree: call TraversalCopy: DOTREE_PRED} {win testfile testchmod} { | 
|---|
 | 699 |     cleanup | 
|---|
 | 700 |     file mkdir td1 | 
|---|
 | 701 |     createfile td1/tf1 tf1 | 
|---|
 | 702 |     testchmod 000 td1 | 
|---|
 | 703 |     testfile cpdir td1 td2 | 
|---|
 | 704 |     list [file exists td2] [file writable td2] | 
|---|
 | 705 | } {1 1} | 
|---|
 | 706 | test winFCmd-7.12 {TraverseWinTree: call TraversalDelete: DOTREE_PRED} {win testfile} { | 
|---|
 | 707 |     cleanup | 
|---|
 | 708 |     file mkdir td1 | 
|---|
 | 709 |     createfile td1/tf1 tf1 | 
|---|
 | 710 |     testfile rmdir -force td1 | 
|---|
 | 711 |     file exists td1 | 
|---|
 | 712 | } {0} | 
|---|
 | 713 | test winFCmd-7.13 {TraverseWinTree: append \ to target if necessary} {win testfile} { | 
|---|
 | 714 |     cleanup | 
|---|
 | 715 |     file mkdir td1 | 
|---|
 | 716 |     createfile td1/tf1 tf1 | 
|---|
 | 717 |     testfile cpdir td1 td2 | 
|---|
 | 718 |     contents td2/tf1 | 
|---|
 | 719 | } {tf1}     | 
|---|
 | 720 | test winFCmd-7.14 {TraverseWinTree: append \ to target if necessary} {win 95 testfile} { | 
|---|
 | 721 |     cleanup | 
|---|
 | 722 |     file mkdir td1 | 
|---|
 | 723 |     list [catch {testfile cpdir td1 /} msg] $msg | 
|---|
 | 724 | } {1 {/ EEXIST}} | 
|---|
 | 725 | test winFCmd-7.15 {TraverseWinTree: append \ to target if necessary} {win nt testfile} { | 
|---|
 | 726 |     cleanup | 
|---|
 | 727 |     file mkdir td1 | 
|---|
 | 728 |     list [catch {testfile cpdir td1 /} msg] $msg | 
|---|
 | 729 | } {1 {/ EACCES}} | 
|---|
 | 730 | test winFCmd-7.16 {TraverseWinTree: recurse on files: no files} {win testfile} { | 
|---|
 | 731 |     cleanup | 
|---|
 | 732 |     file mkdir td1 | 
|---|
 | 733 |     testfile cpdir td1 td2 | 
|---|
 | 734 | } {} | 
|---|
 | 735 | test winFCmd-7.17 {TraverseWinTree: recurse on files: one file} {win testfile} { | 
|---|
 | 736 |     cleanup | 
|---|
 | 737 |     file mkdir td1 | 
|---|
 | 738 |     createfile td1/td2 | 
|---|
 | 739 |     testfile cpdir td1 td2 | 
|---|
 | 740 |     glob td2/* | 
|---|
 | 741 | } {td2/td2} | 
|---|
 | 742 | test winFCmd-7.18 {TraverseWinTree: recurse on files: several files and dir} \ | 
|---|
 | 743 |         {win testfile} { | 
|---|
 | 744 |     cleanup | 
|---|
 | 745 |     file mkdir td1 | 
|---|
 | 746 |     createfile td1/tf1 | 
|---|
 | 747 |     createfile td1/tf2 | 
|---|
 | 748 |     file mkdir td1/td2/td3 | 
|---|
 | 749 |     createfile td1/tf3 | 
|---|
 | 750 |     createfile td1/tf4 | 
|---|
 | 751 |     testfile cpdir td1 td2 | 
|---|
 | 752 |     lsort [glob td2/*] | 
|---|
 | 753 | } {td2/td2 td2/tf1 td2/tf2 td2/tf3 td2/tf4} | 
|---|
 | 754 | test winFCmd-7.19 {TraverseWinTree: call TraversalCopy: DOTREE_POSTD} {win testfile testchmod} { | 
|---|
 | 755 |     cleanup | 
|---|
 | 756 |     file mkdir td1 | 
|---|
 | 757 |     createfile td1/tf1 tf1 | 
|---|
 | 758 |     testchmod 000 td1 | 
|---|
 | 759 |     testfile cpdir td1 td2 | 
|---|
 | 760 |     list [file exists td2] [file writable td2] | 
|---|
 | 761 | } {1 1} | 
|---|
 | 762 | test winFCmd-7.20 {TraverseWinTree: call TraversalDelete: DOTREE_POSTD} \ | 
|---|
 | 763 |         {win testfile} { | 
|---|
 | 764 |     cleanup | 
|---|
 | 765 |     file mkdir td1 | 
|---|
 | 766 |     createfile td1/tf1 tf1 | 
|---|
 | 767 |     testfile rmdir -force td1 | 
|---|
 | 768 |     file exists td1 | 
|---|
 | 769 | } {0} | 
|---|
 | 770 | test winFCmd-7.21 {TraverseWinTree: fill errorPtr} {win testfile} { | 
|---|
 | 771 |     cleanup | 
|---|
 | 772 |     list [catch {testfile cpdir td1 td2} msg] $msg | 
|---|
 | 773 | } {1 {td1 ENOENT}} | 
|---|
 | 774 |  | 
|---|
 | 775 | test winFCmd-8.1 {TraversalCopy: DOTREE_F} {win testfile} { | 
|---|
 | 776 |     cleanup | 
|---|
 | 777 |     file mkdir td1 | 
|---|
 | 778 |     list [catch {testfile cpdir td1 td1} msg] $msg | 
|---|
 | 779 | } {1 {td1 EEXIST}} | 
|---|
 | 780 | test winFCmd-8.2 {TraversalCopy: DOTREE_PRED} {win testfile testchmod} { | 
|---|
 | 781 |     cleanup | 
|---|
 | 782 |     file mkdir td1/td2 | 
|---|
 | 783 |     testchmod 000 td1 | 
|---|
 | 784 |     testfile cpdir td1 td2 | 
|---|
 | 785 |     list [file writable td1] [file writable td1/td2] | 
|---|
 | 786 | } {0 1} | 
|---|
 | 787 | test winFCmd-8.3 {TraversalCopy: DOTREE_POSTD} {win testfile} { | 
|---|
 | 788 |     cleanup | 
|---|
 | 789 |     file mkdir td1 | 
|---|
 | 790 |     testfile cpdir td1 td2 | 
|---|
 | 791 | } {} | 
|---|
 | 792 |  | 
|---|
 | 793 | test winFCmd-9.1 {TraversalDelete: DOTREE_F} {win testfile} { | 
|---|
 | 794 |     cleanup | 
|---|
 | 795 |     file mkdir td1 | 
|---|
 | 796 |     createfile td1/tf1 | 
|---|
 | 797 |     testfile rmdir -force td1 | 
|---|
 | 798 | } {} | 
|---|
 | 799 | test winFCmd-9.2 {TraversalDelete: DOTREE_F} {win 95 testfile} { | 
|---|
 | 800 |     cleanup | 
|---|
 | 801 |     file mkdir td1 | 
|---|
 | 802 |     set fd [open td1/tf1 w] | 
|---|
 | 803 |     set msg [list [catch {testfile rmdir -force td1} msg] $msg] | 
|---|
 | 804 |     close $fd | 
|---|
 | 805 |     set msg | 
|---|
 | 806 | } {1 {td1\tf1 EACCES}} | 
|---|
 | 807 | test winFCmd-9.3 {TraversalDelete: DOTREE_PRED} {win testfile testchmod} { | 
|---|
 | 808 |     cleanup | 
|---|
 | 809 |     file mkdir td1/td2 | 
|---|
 | 810 |     testchmod 000 td1 | 
|---|
 | 811 |     testfile rmdir -force td1 | 
|---|
 | 812 |     file exists td1 | 
|---|
 | 813 | } {0} | 
|---|
 | 814 | test winFCmd-9.4 {TraversalDelete: DOTREE_POSTD} {win testfile} { | 
|---|
 | 815 |     cleanup | 
|---|
 | 816 |     file mkdir td1/td1/td3/td4/td5 | 
|---|
 | 817 |     testfile rmdir -force td1 | 
|---|
 | 818 | } {} | 
|---|
 | 819 |  | 
|---|
 | 820 | test winFCmd-10.1 {AttributesPosixError - get} {win} { | 
|---|
 | 821 |     cleanup | 
|---|
 | 822 |     list [catch {file attributes td1 -archive} msg] $msg | 
|---|
 | 823 | } {1 {could not read "td1": no such file or directory}} | 
|---|
 | 824 | test winFCmd-10.2 {AttributesPosixError - set} {win} { | 
|---|
 | 825 |     cleanup | 
|---|
 | 826 |     list [catch {file attributes td1 -archive 0} msg] $msg | 
|---|
 | 827 | } {1 {could not read "td1": no such file or directory}} | 
|---|
 | 828 |  | 
|---|
 | 829 | test winFCmd-11.1 {GetWinFileAttributes} {win} { | 
|---|
 | 830 |     cleanup | 
|---|
 | 831 |     close [open td1 w] | 
|---|
 | 832 |     list [catch {file attributes td1 -archive} msg] $msg [cleanup] | 
|---|
 | 833 | } {0 1 {}} | 
|---|
 | 834 | test winFCmd-11.2 {GetWinFileAttributes} {win} { | 
|---|
 | 835 |     cleanup | 
|---|
 | 836 |     close [open td1 w] | 
|---|
 | 837 |     list [catch {file attributes td1 -readonly} msg] $msg [cleanup] | 
|---|
 | 838 | } {0 0 {}} | 
|---|
 | 839 | test winFCmd-11.3 {GetWinFileAttributes} {win} { | 
|---|
 | 840 |     cleanup | 
|---|
 | 841 |     close [open td1 w] | 
|---|
 | 842 |     list [catch {file attributes td1 -hidden} msg] $msg [cleanup] | 
|---|
 | 843 | } {0 0 {}} | 
|---|
 | 844 | test winFCmd-11.4 {GetWinFileAttributes} {win} { | 
|---|
 | 845 |     cleanup | 
|---|
 | 846 |     close [open td1 w] | 
|---|
 | 847 |     list [catch {file attributes td1 -system} msg] $msg [cleanup] | 
|---|
 | 848 | } {0 0 {}} | 
|---|
 | 849 | test winFCmd-11.5 {GetWinFileAttributes} {win} { | 
|---|
 | 850 |     # attr of relative paths that resolve to root was failing | 
|---|
 | 851 |     # don't care about answer, just that test runs. | 
|---|
 | 852 |  | 
|---|
 | 853 |     set old [pwd] | 
|---|
 | 854 |     cd c:/ | 
|---|
 | 855 |     file attr c:             | 
|---|
 | 856 |     file attr c:. | 
|---|
 | 857 |     file attr .  | 
|---|
 | 858 |     cd $old | 
|---|
 | 859 | } {} | 
|---|
 | 860 | test winFCmd-11.6 {GetWinFileAttributes} {win} { | 
|---|
 | 861 |     file attr c:/ -hidden | 
|---|
 | 862 | } {0} | 
|---|
 | 863 |  | 
|---|
 | 864 | test winFCmd-12.1 {ConvertFileNameFormat} {win} { | 
|---|
 | 865 |     cleanup | 
|---|
 | 866 |     close [open td1 w] | 
|---|
 | 867 |     list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup] | 
|---|
 | 868 | } {0 td1 {}} | 
|---|
 | 869 | test winFCmd-12.2 {ConvertFileNameFormat} {win} { | 
|---|
 | 870 |     cleanup | 
|---|
 | 871 |     file mkdir td1 | 
|---|
 | 872 |     close [open td1/td1 w] | 
|---|
 | 873 |     list [catch {string tolower [file attributes td1/td1 -longname]} msg] $msg [cleanup] | 
|---|
 | 874 | } {0 td1/td1 {}} | 
|---|
 | 875 | test winFCmd-12.3 {ConvertFileNameFormat} {win} { | 
|---|
 | 876 |     cleanup | 
|---|
 | 877 |     file mkdir td1 | 
|---|
 | 878 |     file mkdir td1/td2 | 
|---|
 | 879 |     close [open td1/td3 w] | 
|---|
 | 880 |     list [catch {string tolower [file attributes td1/td2/../td3 -longname]} msg] $msg [cleanup] | 
|---|
 | 881 | } {0 td1/td2/../td3 {}} | 
|---|
 | 882 | test winFCmd-12.4 {ConvertFileNameFormat} {win} { | 
|---|
 | 883 |     cleanup | 
|---|
 | 884 |     close [open td1 w] | 
|---|
 | 885 |     list [catch {string tolower [file attributes ./td1 -longname]} msg] $msg [cleanup] | 
|---|
 | 886 | } {0 ./td1 {}} | 
|---|
 | 887 | test winFCmd-12.5 {ConvertFileNameFormat: absolute path} {win} { | 
|---|
 | 888 |     list [file attributes / -longname] [file attributes \\ -longname] | 
|---|
 | 889 | } {/ /} | 
|---|
 | 890 | test winFCmd-12.6 {ConvertFileNameFormat: absolute path with drive} {win} { | 
|---|
 | 891 |     catch {file delete -force -- c:/td1} | 
|---|
 | 892 |     close [open c:/td1 w] | 
|---|
 | 893 |     list [catch {string tolower [file attributes c:/td1 -longname]} msg] $msg [file delete -force -- c:/td1] | 
|---|
 | 894 | } {0 c:/td1 {}} | 
|---|
 | 895 | test winFCmd-12.7 {ConvertFileNameFormat} {nonPortable win} { | 
|---|
 | 896 |     string tolower [file attributes //bisque/tcl/ws -longname] | 
|---|
 | 897 | } {//bisque/tcl/ws} | 
|---|
 | 898 | test winFCmd-12.8 {ConvertFileNameFormat} {win longFileNames} { | 
|---|
 | 899 |     cleanup | 
|---|
 | 900 |     close [open td1 w] | 
|---|
 | 901 |     list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup] | 
|---|
 | 902 | } {0 td1 {}} | 
|---|
 | 903 | test winFCmd-12.10 {ConvertFileNameFormat} {longFileNames win} { | 
|---|
 | 904 |     cleanup | 
|---|
 | 905 |     close [open td1td1td1 w] | 
|---|
 | 906 |     list [catch {file attributes td1td1td1 -shortname}] [cleanup] | 
|---|
 | 907 | } {0 {}} | 
|---|
 | 908 | test winFCmd-12.11 {ConvertFileNameFormat} {longFileNames win} { | 
|---|
 | 909 |     cleanup | 
|---|
 | 910 |     close [open td1 w] | 
|---|
 | 911 |     list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup] | 
|---|
 | 912 | } {0 td1 {}} | 
|---|
 | 913 |  | 
|---|
 | 914 | test winFCmd-13.1 {GetWinFileLongName} {win} { | 
|---|
 | 915 |     cleanup | 
|---|
 | 916 |     close [open td1 w] | 
|---|
 | 917 |     list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup] | 
|---|
 | 918 | } {0 td1 {}} | 
|---|
 | 919 |  | 
|---|
 | 920 | test winFCmd-14.1 {GetWinFileShortName} {win} { | 
|---|
 | 921 |     cleanup | 
|---|
 | 922 |     close [open td1 w] | 
|---|
 | 923 |     list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup] | 
|---|
 | 924 | } {0 td1 {}} | 
|---|
 | 925 |  | 
|---|
 | 926 | test winFCmd-15.1 {SetWinFileAttributes} {win} { | 
|---|
 | 927 |     cleanup | 
|---|
 | 928 |     list [catch {file attributes td1 -archive 0} msg] $msg | 
|---|
 | 929 | } {1 {could not read "td1": no such file or directory}} | 
|---|
 | 930 | test winFCmd-15.2 {SetWinFileAttributes - archive} {win} { | 
|---|
 | 931 |     cleanup | 
|---|
 | 932 |     close [open td1 w] | 
|---|
 | 933 |     list [catch {file attributes td1 -archive 1} msg] $msg [file attributes td1 -archive] [cleanup] | 
|---|
 | 934 | } {0 {} 1 {}} | 
|---|
 | 935 | test winFCmd-15.3 {SetWinFileAttributes - archive} {win} { | 
|---|
 | 936 |     cleanup | 
|---|
 | 937 |     close [open td1 w] | 
|---|
 | 938 |     list [catch {file attributes td1 -archive 0} msg] $msg [file attributes td1 -archive] [cleanup] | 
|---|
 | 939 | } {0 {} 0 {}} | 
|---|
 | 940 | test winFCmd-15.4 {SetWinFileAttributes - hidden} {win} { | 
|---|
 | 941 |     cleanup | 
|---|
 | 942 |     close [open td1 w] | 
|---|
 | 943 |     list [catch {file attributes td1 -hidden 1} msg] $msg [file attributes td1 -hidden] [file attributes td1 -hidden 0] [cleanup] | 
|---|
 | 944 | } {0 {} 1 {} {}} | 
|---|
 | 945 | test winFCmd-15.5 {SetWinFileAttributes - hidden} {win} { | 
|---|
 | 946 |     cleanup | 
|---|
 | 947 |     close [open td1 w] | 
|---|
 | 948 |     list [catch {file attributes td1 -hidden 0} msg] $msg [file attributes td1 -hidden] [cleanup] | 
|---|
 | 949 | } {0 {} 0 {}} | 
|---|
 | 950 | test winFCmd-15.6 {SetWinFileAttributes - readonly} {win} { | 
|---|
 | 951 |     cleanup | 
|---|
 | 952 |     close [open td1 w] | 
|---|
 | 953 |     list [catch {file attributes td1 -readonly 1} msg] $msg [file attributes td1 -readonly] [cleanup] | 
|---|
 | 954 | } {0 {} 1 {}} | 
|---|
 | 955 | test winFCmd-15.7 {SetWinFileAttributes - readonly} {win} { | 
|---|
 | 956 |     cleanup | 
|---|
 | 957 |     close [open td1 w] | 
|---|
 | 958 |     list [catch {file attributes td1 -readonly 0} msg] $msg [file attributes td1 -readonly] [cleanup] | 
|---|
 | 959 | } {0 {} 0 {}} | 
|---|
 | 960 | test winFCmd-15.8 {SetWinFileAttributes - system} {win} { | 
|---|
 | 961 |     cleanup | 
|---|
 | 962 |     close [open td1 w] | 
|---|
 | 963 |     list [catch {file attributes td1 -system 1} msg] $msg [file attributes td1 -system] [cleanup] | 
|---|
 | 964 | } {0 {} 1 {}} | 
|---|
 | 965 | test winFCmd-15.9 {SetWinFileAttributes - system} {win} { | 
|---|
 | 966 |     cleanup | 
|---|
 | 967 |     close [open td1 w] | 
|---|
 | 968 |     list [catch {file attributes td1 -system 0} msg] $msg [file attributes td1 -system] [cleanup] | 
|---|
 | 969 | } {0 {} 0 {}} | 
|---|
 | 970 | test winFCmd-15.10 {SetWinFileAttributes - failing} {win cdrom} { | 
|---|
 | 971 |     cleanup | 
|---|
 | 972 |     catch {file attributes $cdfile -archive 1} | 
|---|
 | 973 | } {1} | 
|---|
 | 974 | test winFCmd-16.1 {Windows file normalization} {win} { | 
|---|
 | 975 |     list [file normalize c:/] [file normalize C:/] | 
|---|
 | 976 | } {C:/ C:/} | 
|---|
 | 977 | test winFCmd-16.2 {Windows file normalization} {win} { | 
|---|
 | 978 |     close [open td1... w] | 
|---|
 | 979 |     set res [file tail [file normalize td1]] | 
|---|
 | 980 |     file delete td1... | 
|---|
 | 981 |     set res | 
|---|
 | 982 | } {td1} | 
|---|
 | 983 |  | 
|---|
 | 984 | set pwd [pwd] | 
|---|
 | 985 | set d [string index $pwd 0] | 
|---|
 | 986 |  | 
|---|
 | 987 | test winFCmd-16.3 {Windows file normalization} {win} { | 
|---|
 | 988 |     file norm ${d}:foo | 
|---|
 | 989 | } [file join $pwd foo] | 
|---|
 | 990 | test winFCmd-16.4 {Windows file normalization} {win} { | 
|---|
 | 991 |     file norm [string tolower ${d}]:foo | 
|---|
 | 992 | } [file join $pwd foo] | 
|---|
 | 993 | test winFCmd-16.5 {Windows file normalization} {win} { | 
|---|
 | 994 |     file norm ${d}:foo/bar | 
|---|
 | 995 | } [file join $pwd foo/bar] | 
|---|
 | 996 | test winFCmd-16.6 {Windows file normalization} {win} { | 
|---|
 | 997 |     file norm ${d}:foo\\bar | 
|---|
 | 998 | } [file join $pwd foo/bar] | 
|---|
 | 999 | test winFCmd-16.7 {Windows file normalization} {win} { | 
|---|
 | 1000 |     file norm /bar | 
|---|
 | 1001 | } "${d}:/bar" | 
|---|
 | 1002 | test winFCmd-16.8 {Windows file normalization} {win} { | 
|---|
 | 1003 |     file norm ///bar | 
|---|
 | 1004 | } "${d}:/bar" | 
|---|
 | 1005 | test winFCmd-16.9 {Windows file normalization} {win} { | 
|---|
 | 1006 |     file norm /bar/foo | 
|---|
 | 1007 | } "${d}:/bar/foo" | 
|---|
 | 1008 | if {$d eq "C"} { set dd "D" } else { set dd "C" } | 
|---|
 | 1009 | test winFCmd-16.10 {Windows file normalization} {win} { | 
|---|
 | 1010 |     file norm ${dd}:foo | 
|---|
 | 1011 | } "${dd}:/foo" | 
|---|
 | 1012 | test winFCmd-16.11 {Windows file normalization} -constraints {win cdrom} \ | 
|---|
 | 1013 | -body { | 
|---|
 | 1014 |     cd ${d}: | 
|---|
 | 1015 |     cd $cdrom | 
|---|
 | 1016 |     cd ${d}: | 
|---|
 | 1017 |     cd $cdrom | 
|---|
 | 1018 |     # Must not crash | 
|---|
 | 1019 |     set result "no crash" | 
|---|
 | 1020 | } -cleanup { | 
|---|
 | 1021 |     cd $pwd | 
|---|
 | 1022 | } -result {no crash} | 
|---|
 | 1023 |  | 
|---|
 | 1024 | test winFCmd-16.12 {Windows file normalization - no crash} \ | 
|---|
 | 1025 |   -constraints win -setup { | 
|---|
 | 1026 |     set oldhome "" | 
|---|
 | 1027 |     catch {set oldhome $::env(HOME)} | 
|---|
 | 1028 | } -body { | 
|---|
 | 1029 |     set expectedResult [file normalize ${d}:] | 
|---|
 | 1030 |     set ::env(HOME) ${d}: | 
|---|
 | 1031 |     cd | 
|---|
 | 1032 |     # At one point this led to an infinite recursion in Tcl | 
|---|
 | 1033 |     set result [pwd]; # <- Must not crash | 
|---|
 | 1034 |     set result "no crash" | 
|---|
 | 1035 | } -cleanup { | 
|---|
 | 1036 |     set ::env(HOME) $oldhome | 
|---|
 | 1037 |     cd $pwd | 
|---|
 | 1038 | } -result {no crash} | 
|---|
 | 1039 |  | 
|---|
 | 1040 | test winFCmd-16.13 {Windows file normalization} -constraints win -setup { | 
|---|
 | 1041 |     set oldhome "" | 
|---|
 | 1042 |     catch {set oldhome $::env(HOME)} | 
|---|
 | 1043 | } -body { | 
|---|
 | 1044 |     # Test 'cd' normalization when HOME is absolute | 
|---|
 | 1045 |     set expectedResult [file normalize ${d}:/] | 
|---|
 | 1046 |     set ::env(HOME) ${d}:/ | 
|---|
 | 1047 |     cd | 
|---|
 | 1048 |     set result [pwd] | 
|---|
 | 1049 |     if { [string equal $result $expectedResult] } { | 
|---|
 | 1050 |         concat ok | 
|---|
 | 1051 |     } else { | 
|---|
 | 1052 |         list $result != $expectedResult | 
|---|
 | 1053 |     } | 
|---|
 | 1054 | } -cleanup { | 
|---|
 | 1055 |     set ::env(HOME) $oldhome | 
|---|
 | 1056 |     cd $pwd | 
|---|
 | 1057 | } -result ok | 
|---|
 | 1058 |  | 
|---|
 | 1059 | test winFCmd-16.14 {Windows file normalization} -constraints win -setup { | 
|---|
 | 1060 |     set oldhome "" | 
|---|
 | 1061 |     catch {set oldhome $::env(HOME)} | 
|---|
 | 1062 | } -body { | 
|---|
 | 1063 |     # Test 'cd' normalization when HOME is relative | 
|---|
 | 1064 |     set ::env(HOME) ${d}: | 
|---|
 | 1065 |     cd | 
|---|
 | 1066 |     set result [pwd] | 
|---|
 | 1067 |     if { [string equal $result $pwd] } { | 
|---|
 | 1068 |         concat ok | 
|---|
 | 1069 |     } else { | 
|---|
 | 1070 |         list $result != $pwd | 
|---|
 | 1071 |     } | 
|---|
 | 1072 | } -cleanup { | 
|---|
 | 1073 |     set ::env(HOME) $oldhome | 
|---|
 | 1074 |     cd $pwd | 
|---|
 | 1075 | } -result ok | 
|---|
 | 1076 |  | 
|---|
 | 1077 | test winFCmd-17.1 {Windows bad permissions cd} -constraints win -body { | 
|---|
 | 1078 |     set d {} | 
|---|
 | 1079 |     foreach dd {c:/ d:/ e:/} { | 
|---|
 | 1080 |         eval lappend d [glob -nocomplain \ | 
|---|
 | 1081 |           -types hidden -dir $dd "System Volume Information"] | 
|---|
 | 1082 |     } | 
|---|
 | 1083 |     # Old versions of Tcl gave a misleading error that the  | 
|---|
 | 1084 |     # directory in question didn't exist. | 
|---|
 | 1085 |     if {[llength $d] && [catch {cd [lindex $d 0]} err]} { | 
|---|
 | 1086 |         regsub ".*: " $err "" err | 
|---|
 | 1087 |         set err | 
|---|
 | 1088 |     } else { | 
|---|
 | 1089 |         set err "permission denied" | 
|---|
 | 1090 |     } | 
|---|
 | 1091 | } -cleanup { | 
|---|
 | 1092 |     cd $pwd | 
|---|
 | 1093 | } -result "permission denied" | 
|---|
 | 1094 |  | 
|---|
 | 1095 | cd $pwd | 
|---|
 | 1096 | unset d dd pwd | 
|---|
 | 1097 |  | 
|---|
 | 1098 | test winFCmd-18.1 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1099 |     file pathtype com1 | 
|---|
 | 1100 | } -result "absolute" | 
|---|
 | 1101 |  | 
|---|
 | 1102 | test winFCmd-18.1.2 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1103 |     file pathtype com4 | 
|---|
 | 1104 | } -result "absolute" | 
|---|
 | 1105 |  | 
|---|
 | 1106 | test winFCmd-18.1.3 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1107 |     file pathtype com5 | 
|---|
 | 1108 | } -result "relative" | 
|---|
 | 1109 |  | 
|---|
 | 1110 | test winFCmd-18.1.4 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1111 |     file pathtype lpt3 | 
|---|
 | 1112 | } -result "absolute" | 
|---|
 | 1113 |  | 
|---|
 | 1114 | test winFCmd-18.1.5 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1115 |     file pathtype lpt4 | 
|---|
 | 1116 | } -result "relative" | 
|---|
 | 1117 |  | 
|---|
 | 1118 | test winFCmd-18.1.6 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1119 |     file pathtype nul | 
|---|
 | 1120 | } -result "absolute" | 
|---|
 | 1121 |  | 
|---|
 | 1122 | test winFCmd-18.1.7 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1123 |     file pathtype null | 
|---|
 | 1124 | } -result "relative" | 
|---|
 | 1125 |  | 
|---|
 | 1126 | test winFCmd-18.2 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1127 |     file pathtype com1: | 
|---|
 | 1128 | } -result "absolute" | 
|---|
 | 1129 |  | 
|---|
 | 1130 | test winFCmd-18.3 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1131 |     file pathtype COM1 | 
|---|
 | 1132 | } -result "absolute" | 
|---|
 | 1133 |  | 
|---|
 | 1134 | test winFCmd-18.4 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1135 |     file pathtype CoM1: | 
|---|
 | 1136 | } -result "absolute" | 
|---|
 | 1137 |  | 
|---|
 | 1138 | test winFCmd-18.5 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1139 |     file normalize com1: | 
|---|
 | 1140 | } -result COM1 | 
|---|
 | 1141 |  | 
|---|
 | 1142 | test winFCmd-18.6 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1143 |     file normalize COM1: | 
|---|
 | 1144 | } -result COM1 | 
|---|
 | 1145 |  | 
|---|
 | 1146 | test winFCmd-18.7 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1147 |     file normalize cOm1 | 
|---|
 | 1148 | } -result COM1 | 
|---|
 | 1149 |  | 
|---|
 | 1150 | test winFCmd-18.8 {Windows reserved path names} -constraints win -body { | 
|---|
 | 1151 |     file normalize cOm1: | 
|---|
 | 1152 | } -result COM1 | 
|---|
 | 1153 |  | 
|---|
 | 1154 |  | 
|---|
 | 1155 | test winFCmd-19.1 {Windows extended path names} -constraints nt -body { | 
|---|
 | 1156 |     file normalize //?/c:/windows/win.ini | 
|---|
 | 1157 | } -result //?/c:/windows/win.ini | 
|---|
 | 1158 |  | 
|---|
 | 1159 | test winFCmd-19.2 {Windows extended path names} -constraints nt -body { | 
|---|
 | 1160 |     file normalize //?/c:/windows/../windows/win.ini | 
|---|
 | 1161 | } -result //?/c:/windows/win.ini | 
|---|
 | 1162 |  | 
|---|
 | 1163 | test winFCmd-19.3 {Windows extended path names} -constraints nt -setup { | 
|---|
 | 1164 |     set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp] | 
|---|
 | 1165 |     set tmpfile [file normalize $tmpfile] | 
|---|
 | 1166 | } -body { | 
|---|
 | 1167 |     list [catch { | 
|---|
 | 1168 |         set f [open $tmpfile [list WRONLY CREAT]] | 
|---|
 | 1169 |         close $f | 
|---|
 | 1170 |     } res] $res | 
|---|
 | 1171 | } -cleanup { | 
|---|
 | 1172 |     catch {file delete $tmpfile} | 
|---|
 | 1173 | } -result [list 0 {}] | 
|---|
 | 1174 |  | 
|---|
 | 1175 | test winFCmd-19.4 {Windows extended path names} -constraints nt -setup { | 
|---|
 | 1176 |     set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp] | 
|---|
 | 1177 |     set tmpfile //?/[file normalize $tmpfile] | 
|---|
 | 1178 | } -body { | 
|---|
 | 1179 |     list [catch { | 
|---|
 | 1180 |         set f [open $tmpfile [list WRONLY CREAT]] | 
|---|
 | 1181 |         close $f | 
|---|
 | 1182 |     } res] $res | 
|---|
 | 1183 | } -cleanup { | 
|---|
 | 1184 |     catch {file delete $tmpfile} | 
|---|
 | 1185 | } -result [list 0 {}] | 
|---|
 | 1186 |  | 
|---|
 | 1187 | test winFCmd-19.5 {Windows extended path names} -constraints nt -setup { | 
|---|
 | 1188 |     set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp] | 
|---|
 | 1189 |     set tmpfile [file normalize $tmpfile] | 
|---|
 | 1190 | } -body { | 
|---|
 | 1191 |     list [catch { | 
|---|
 | 1192 |         set f [open $tmpfile [list WRONLY CREAT]] | 
|---|
 | 1193 |         close $f | 
|---|
 | 1194 |     } res] errormsg ;#$res | 
|---|
 | 1195 | } -cleanup { | 
|---|
 | 1196 |     catch {file delete $tmpfile} | 
|---|
 | 1197 | } -result [list 1 errormsg] | 
|---|
 | 1198 |  | 
|---|
 | 1199 | test winFCmd-19.6 {Windows extended path names} -constraints nt -setup { | 
|---|
 | 1200 |     set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp] | 
|---|
 | 1201 |     set tmpfile //?/[file normalize $tmpfile] | 
|---|
 | 1202 | } -body { | 
|---|
 | 1203 |     list [catch { | 
|---|
 | 1204 |         set f [open $tmpfile [list WRONLY CREAT]] | 
|---|
 | 1205 |         close $f | 
|---|
 | 1206 |     } res] $res | 
|---|
 | 1207 | } -cleanup { | 
|---|
 | 1208 |     catch {file delete $tmpfile} | 
|---|
 | 1209 | } -result [list 0 {}] | 
|---|
 | 1210 |  | 
|---|
 | 1211 | test winFCmd-19.7 {Windows extended path names} -constraints nt -setup { | 
|---|
 | 1212 |     set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "] | 
|---|
 | 1213 |     set tmpfile [file normalize $tmpfile] | 
|---|
 | 1214 | } -body { | 
|---|
 | 1215 |     list [catch { | 
|---|
 | 1216 |         set f [open $tmpfile [list WRONLY CREAT]] | 
|---|
 | 1217 |         close $f | 
|---|
 | 1218 |     } res] $res [glob -directory $::env(TEMP) -tails tcl[pid].*] | 
|---|
 | 1219 | } -cleanup { | 
|---|
 | 1220 |     catch {file delete $tmpfile} | 
|---|
 | 1221 | } -result [list 0 {} [list tcl[pid].tmp]] | 
|---|
 | 1222 |  | 
|---|
 | 1223 | test winFCmd-19.8 {Windows extended path names} -constraints nt -setup { | 
|---|
 | 1224 |     set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "] | 
|---|
 | 1225 |     set tmpfile //?/[file normalize $tmpfile] | 
|---|
 | 1226 | } -body { | 
|---|
 | 1227 |     list [catch { | 
|---|
 | 1228 |         set f [open $tmpfile [list WRONLY CREAT]] | 
|---|
 | 1229 |         close $f | 
|---|
 | 1230 |     } res] $res [glob -directory $::env(TEMP) -tails tcl[pid].*] | 
|---|
 | 1231 | } -cleanup { | 
|---|
 | 1232 |     catch {file delete $tmpfile} | 
|---|
 | 1233 | } -result [list 0 {} [list "tcl[pid].tmp "]] | 
|---|
 | 1234 |  | 
|---|
 | 1235 | # This block of code used to occur after the "return" call, so I'm | 
|---|
 | 1236 | # commenting it out and assuming that this code is still under construction. | 
|---|
 | 1237 | #foreach source {tef ted tnf tnd "" nul com1} { | 
|---|
 | 1238 | #    foreach chmodsrc {000 755} { | 
|---|
 | 1239 | #        foreach dest "tfn tfe tdn tdempty tdfull td1/td2 $p $p/td1 {} nul" { | 
|---|
 | 1240 | #           foreach chmoddst {000 755} { | 
|---|
 | 1241 | #               puts hi | 
|---|
 | 1242 | #               cleanup | 
|---|
 | 1243 | #               file delete -force ted tef | 
|---|
 | 1244 | #               file mkdir ted | 
|---|
 | 1245 | #               createfile tef | 
|---|
 | 1246 | #               createfile tfe | 
|---|
 | 1247 | #               file mkdir tdempty | 
|---|
 | 1248 | #               file mkdir tdfull/td1/td2 | 
|---|
 | 1249 | # | 
|---|
 | 1250 | #               catch {testchmod $chmodsrc $source} | 
|---|
 | 1251 | #               catch {testchmod $chmoddst $dest} | 
|---|
 | 1252 | # | 
|---|
 | 1253 | #               if [catch {file rename $source $dest} msg] { | 
|---|
 | 1254 | #                   puts "file rename $source ($chmodsrc) $dest ($chmoddst)" | 
|---|
 | 1255 | #                   puts $msg | 
|---|
 | 1256 | #               } | 
|---|
 | 1257 | #           } | 
|---|
 | 1258 | #       } | 
|---|
 | 1259 | #    } | 
|---|
 | 1260 | #} | 
|---|
 | 1261 |  | 
|---|
 | 1262 | # cleanup | 
|---|
 | 1263 | cleanup | 
|---|
 | 1264 | ::tcltest::cleanupTests | 
|---|
 | 1265 | return | 
|---|
 | 1266 |  | 
|---|
 | 1267 | # Local Variables: | 
|---|
 | 1268 | # mode: tcl | 
|---|
 | 1269 | # End: | 
|---|