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