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
|
# The file tests the tclCmdAH.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 (c) 1996-1997 by Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# SCCS: @(#) cmdAH.test 1.35 97/07/22 14:07:43
if {[string compare test [info procs test]] == 1} then {source defs}
global env
catch {set platform [testgetplatform]}
test cmdAH-1.1 {Tcl_FileObjCmd} {
list [catch file msg] $msg
} {1 {wrong # args: should be "file option ?arg ...?"}}
test cmdAH-1.2 {Tcl_FileObjCmd} {
list [catch {file x} msg] $msg
} {1 {bad option "x": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-1.3 {Tcl_FileObjCmd} {
list [catch {file atime} msg] $msg
} {1 {wrong # args: should be "file atime name ?arg ...?"}}
#volume
test cmdAH-2.1 {Tcl_FileObjCmd: volumes} {
list [catch {file volumes x} msg] $msg
} {1 {wrong # args: should be "file volumes"}}
test cmdAH-2.2 {Tcl_FileObjCmd: volumes} {
set volumeList [file volumes]
if { [llength $volumeList] == 0 } {
set result 0
} else {
set result 1
}
} {1}
test cmdAH-2.3 {Tcl_FileObjCmd: volumes} {macOrUnix} {
set volumeList [file volumes]
catch [list glob -nocomplain [lindex $volumeList 0]*]
} {0}
test cmdAH-2.4 {Tcl_FileObjCmd: volumes} {pcOnly} {
set volumeList [file volumes]
list [catch {lsearch $volumeList "c:/"} element] [expr $element != -1] [catch {list glob -nocomplain [lindex $volumeList $element]*}]
} {0 1 0}
# attributes
test cmdAH-3.1 {Tcl_FileObjCmd - file attrs} {
catch {file delete -force foo.file}
close [open foo.file w]
list [catch {file attributes foo.file}] [file delete -force foo.file]
} {0 {}}
# dirname
if {[info commands testsetplatform] == {}} {
puts "This application hasn't been compiled with the \"testsetplatform\""
puts "command, so I can't test Tcl_FileObjCmd etc."
} else {
test cmdAH-4.1 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname a b} msg] $msg
} {1 {wrong # args: should be "file dirname name"}}
test cmdAH-4.2 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
file dirname /a/b
} /a
test cmdAH-4.3 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
file dirname {}
} .
test cmdAH-4.4 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
file dirname {}
} :
test cmdAH-4.5 {Tcl_FileObjCmd: dirname} {
testsetplatform win
file dirname {}
} .
test cmdAH-4.6 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
file dirname .def
} .
test cmdAH-4.7 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
file dirname a
} :
test cmdAH-4.8 {Tcl_FileObjCmd: dirname} {
testsetplatform win
file dirname a
} .
test cmdAH-4.9 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
file dirname a/b/c.d
} a/b
test cmdAH-4.10 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
file dirname a/b.c/d
} a/b.c
test cmdAH-4.11 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
file dirname /.
} /
test cmdAH-4.12 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname /} msg] $msg
} {0 /}
test cmdAH-4.13 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname /foo} msg] $msg
} {0 /}
test cmdAH-4.14 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname //foo} msg] $msg
} {0 /}
test cmdAH-4.15 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname //foo/bar} msg] $msg
} {0 /foo}
test cmdAH-4.16 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname {//foo\/bar/baz}} msg] $msg
} {0 {/foo\/bar}}
test cmdAH-4.17 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname {//foo\/bar/baz/blat}} msg] $msg
} {0 {/foo\/bar/baz}}
test cmdAH-4.18 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname /foo//} msg] $msg
} {0 /}
test cmdAH-4.19 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname ./a} msg] $msg
} {0 .}
test cmdAH-4.20 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname a/.a} msg] $msg
} {0 a}
test cmdAH-4.21 {Tcl_FileObjCmd: dirname} {
testsetplatform windows
list [catch {file dirname c:foo} msg] $msg
} {0 c:}
test cmdAH-4.22 {Tcl_FileObjCmd: dirname} {
testsetplatform windows
list [catch {file dirname c:} msg] $msg
} {0 c:}
test cmdAH-4.23 {Tcl_FileObjCmd: dirname} {
testsetplatform windows
list [catch {file dirname c:/} msg] $msg
} {0 c:/}
test cmdAH-4.24 {Tcl_FileObjCmd: dirname} {
testsetplatform windows
list [catch {file dirname {c:\foo}} msg] $msg
} {0 c:/}
test cmdAH-4.25 {Tcl_FileObjCmd: dirname} {
testsetplatform windows
list [catch {file dirname {//foo/bar/baz}} msg] $msg
} {0 //foo/bar}
test cmdAH-4.26 {Tcl_FileObjCmd: dirname} {
testsetplatform windows
list [catch {file dirname {//foo/bar}} msg] $msg
} {0 //foo/bar}
test cmdAH-4.27 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname :} msg] $msg
} {0 :}
test cmdAH-4.28 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname :Foo} msg] $msg
} {0 :}
test cmdAH-4.29 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname Foo:} msg] $msg
} {0 Foo:}
test cmdAH-4.30 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname Foo:bar} msg] $msg
} {0 Foo:}
test cmdAH-4.31 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname :Foo:bar} msg] $msg
} {0 :Foo}
test cmdAH-4.32 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname ::} msg] $msg
} {0 :}
test cmdAH-4.33 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname :::} msg] $msg
} {0 ::}
test cmdAH-4.34 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname /foo/bar/} msg] $msg
} {0 foo:}
test cmdAH-4.35 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname /foo/bar} msg] $msg
} {0 foo:}
test cmdAH-4.36 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname /foo} msg] $msg
} {0 foo:}
test cmdAH-4.37 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname foo} msg] $msg
} {0 :}
test cmdAH-4.38 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname ~/foo} msg] $msg
} {0 ~}
test cmdAH-4.39 {Tcl_FileObjCmd: dirname} {
testsetplatform unix
list [catch {file dirname ~bar/foo} msg] $msg
} {0 ~bar}
test cmdAH-4.40 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname ~bar/foo} msg] $msg
} {0 ~bar:}
test cmdAH-4.41 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname ~/foo} msg] $msg
} {0 ~:}
test cmdAH-4.42 {Tcl_FileObjCmd: dirname} {
testsetplatform mac
list [catch {file dirname ~:baz} msg] $msg
} {0 ~:}
test cmdAH-4.43 {Tcl_FileObjCmd: dirname} {
global env
set temp $env(HOME)
set env(HOME) "/home/test"
testsetplatform unix
set result [list [catch {file dirname ~} msg] $msg]
set env(HOME) $temp
set result
} {0 /home}
test cmdAH-4.44 {Tcl_FileObjCmd: dirname} {
global env
set temp $env(HOME)
set env(HOME) "~"
testsetplatform unix
set result [list [catch {file dirname ~} msg] $msg]
set env(HOME) $temp
set result
} {0 ~}
test cmdAH-4.45 {Tcl_FileObjCmd: dirname} {
global env
set temp $env(HOME)
set env(HOME) "/home/test"
testsetplatform windows
set result [list [catch {file dirname ~} msg] $msg]
set env(HOME) $temp
set result
} {0 /home}
test cmdAH-4.46 {Tcl_FileObjCmd: dirname} {
global env
set temp $env(HOME)
set env(HOME) "/home/test"
testsetplatform mac
set result [list [catch {file dirname ~} msg] $msg]
set env(HOME) $temp
set result
} {0 home:}
# tail
test cmdAH-5.1 {Tcl_FileObjCmd: tail} {
testsetplatform unix
list [catch {file tail a b} msg] $msg
} {1 {wrong # args: should be "file tail name"}}
test cmdAH-5.2 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail /a/b
} b
test cmdAH-5.3 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail {}
} {}
test cmdAH-5.4 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail {}
} {}
test cmdAH-5.5 {Tcl_FileObjCmd: tail} {
testsetplatform win
file tail {}
} {}
test cmdAH-5.6 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail .def
} .def
test cmdAH-5.7 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail a
} a
test cmdAH-5.8 {Tcl_FileObjCmd: tail} {
testsetplatform win
file tail a
} a
test cmdAH-5.9 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file ta a/b/c.d
} c.d
test cmdAH-5.10 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail a/b.c/d
} d
test cmdAH-5.11 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail /.
} .
test cmdAH-5.12 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail /
} {}
test cmdAH-5.13 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail /foo
} foo
test cmdAH-5.14 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail //foo
} foo
test cmdAH-5.15 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail //foo/bar
} bar
test cmdAH-5.16 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail {//foo\/bar/baz}
} baz
test cmdAH-5.17 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail {//foo\/bar/baz/blat}
} blat
test cmdAH-5.18 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail /foo//
} foo
test cmdAH-5.19 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail ./a
} a
test cmdAH-5.20 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail a/.a
} .a
test cmdAH-5.21 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail c:foo
} foo
test cmdAH-5.22 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail c:
} {}
test cmdAH-5.23 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail c:/
} {}
test cmdAH-5.24 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail {c:\foo}
} foo
test cmdAH-5.25 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail {//foo/bar/baz}
} baz
test cmdAH-5.26 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail {//foo/bar}
} {}
test cmdAH-5.27 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail :
} :
test cmdAH-5.28 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail :Foo
} Foo
test cmdAH-5.29 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail Foo:
} {}
test cmdAH-5.30 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail Foo:bar
} bar
test cmdAH-5.31 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail :Foo:bar
} bar
test cmdAH-5.32 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail ::
} ::
test cmdAH-5.33 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail :::
} ::
test cmdAH-5.34 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail /foo/bar/
} bar
test cmdAH-5.35 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail /foo/bar
} bar
test cmdAH-5.36 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail /foo
} {}
test cmdAH-5.37 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail foo
} foo
test cmdAH-5.38 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail ~:foo
} foo
test cmdAH-5.39 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail ~bar:foo
} foo
test cmdAH-5.40 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail ~bar/foo
} foo
test cmdAH-5.41 {Tcl_FileObjCmd: tail} {
testsetplatform mac
file tail ~/foo
} foo
test cmdAH-5.42 {Tcl_FileObjCmd: tail} {
global env
set temp $env(HOME)
set env(HOME) "/home/test"
testsetplatform unix
set result [file tail ~]
set env(HOME) $temp
set result
} test
test cmdAH-5.43 {Tcl_FileObjCmd: tail} {
global env
set temp $env(HOME)
set env(HOME) "~"
testsetplatform unix
set result [file tail ~]
set env(HOME) $temp
set result
} {}
test cmdAH-5.44 {Tcl_FileObjCmd: tail} {
global env
set temp $env(HOME)
set env(HOME) "/home/test"
testsetplatform windows
set result [file tail ~]
set env(HOME) $temp
set result
} test
test cmdAH-5.45 {Tcl_FileObjCmd: tail} {
global env
set temp $env(HOME)
set env(HOME) "/home/test"
testsetplatform mac
set result [file tail ~]
set env(HOME) $temp
set result
} test
test cmdAH-5.46 {Tcl_FileObjCmd: tail} {
testsetplatform unix
file tail {f.oo\bar/baz.bat}
} baz.bat
test cmdAH-5.47 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail c:foo
} foo
test cmdAH-5.48 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail c:
} {}
test cmdAH-5.49 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail c:/foo
} foo
test cmdAH-5.50 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail {c:/foo\bar}
} bar
test cmdAH-5.51 {Tcl_FileObjCmd: tail} {
testsetplatform windows
file tail {foo\bar}
} bar
# rootname
test cmdAH-6.1 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
list [catch {file rootname a b} msg] $msg
} {1 {wrong # args: should be "file rootname name"}}
test cmdAH-6.2 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname {}
} {}
test cmdAH-6.3 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file ro foo
} foo
test cmdAH-6.4 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname foo.
} foo
test cmdAH-6.5 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname .foo
} {}
test cmdAH-6.6 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname abc.def
} abc
test cmdAH-6.7 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname abc.def.ghi
} abc.def
test cmdAH-6.8 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname a/b/c.d
} a/b/c
test cmdAH-6.9 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname a/b.c/d
} a/b.c/d
test cmdAH-6.10 {Tcl_FileObjCmd: rootname} {
testsetplatform unix
file rootname a/b.c/
} a/b.c/
test cmdAH-6.11 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file ro foo
} foo
test cmdAH-6.12 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname {}
} {}
test cmdAH-6.13 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname foo.
} foo
test cmdAH-6.14 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname .foo
} {}
test cmdAH-6.15 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname abc.def
} abc
test cmdAH-6.16 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname abc.def.ghi
} abc.def
test cmdAH-6.17 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname a:b:c.d
} a:b:c
test cmdAH-6.18 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname a:b.c:d
} a:b.c:d
test cmdAH-6.19 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname a/b/c.d
} a/b/c
test cmdAH-6.20 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname a/b.c/d
} a/b.c/d
test cmdAH-6.21 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname /a.b
} /a
test cmdAH-6.22 {Tcl_FileObjCmd: rootname} {
testsetplatform mac
file rootname foo.c:
} foo.c:
test cmdAH-6.23 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname {}
} {}
test cmdAH-6.24 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file ro foo
} foo
test cmdAH-6.25 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname foo.
} foo
test cmdAH-6.26 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname .foo
} {}
test cmdAH-6.27 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname abc.def
} abc
test cmdAH-6.28 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname abc.def.ghi
} abc.def
test cmdAH-6.29 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname a/b/c.d
} a/b/c
test cmdAH-6.30 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname a/b.c/d
} a/b.c/d
test cmdAH-6.31 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname a\\b.c\\
} a\\b.c\\
test cmdAH-6.32 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname a\\b\\c.d
} a\\b\\c
test cmdAH-6.33 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname a\\b.c\\d
} a\\b.c\\d
test cmdAH-6.34 {Tcl_FileObjCmd: rootname} {
testsetplatform windows
file rootname a\\b.c\\
} a\\b.c\\
set num 35
foreach outer { {} a .a a. a.a } {
foreach inner { {} a .a a. a.a } {
set thing [format %s/%s $outer $inner]
; test cmdAH-6.$num {Tcl_FileObjCmd: rootname and extension options} {
testsetplatform unix
format %s%s [file rootname $thing] [file ext $thing]
} $thing
set num [expr $num+1]
}
}
# extension
test cmdAH-7.1 {Tcl_FileObjCmd: extension} {
testsetplatform unix
list [catch {file extension a b} msg] $msg
} {1 {wrong # args: should be "file extension name"}}
test cmdAH-7.2 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension {}
} {}
test cmdAH-7.3 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file ext foo
} {}
test cmdAH-7.4 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension foo.
} .
test cmdAH-7.5 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension .foo
} .foo
test cmdAH-7.6 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension abc.def
} .def
test cmdAH-7.7 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension abc.def.ghi
} .ghi
test cmdAH-7.8 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension a/b/c.d
} .d
test cmdAH-7.9 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension a/b.c/d
} {}
test cmdAH-7.10 {Tcl_FileObjCmd: extension} {
testsetplatform unix
file extension a/b.c/
} {}
test cmdAH-7.11 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file ext foo
} {}
test cmdAH-7.12 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension {}
} {}
test cmdAH-7.13 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension foo.
} .
test cmdAH-7.14 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension .foo
} .foo
test cmdAH-7.15 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension abc.def
} .def
test cmdAH-7.16 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension abc.def.ghi
} .ghi
test cmdAH-7.17 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension a:b:c.d
} .d
test cmdAH-7.18 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension a:b.c:d
} {}
test cmdAH-7.19 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension a/b/c.d
} .d
test cmdAH-7.20 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension a/b.c/d
} {}
test cmdAH-7.21 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension /a.b
} .b
test cmdAH-7.22 {Tcl_FileObjCmd: extension} {
testsetplatform mac
file extension foo.c:
} {}
test cmdAH-7.23 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension {}
} {}
test cmdAH-7.24 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file ext foo
} {}
test cmdAH-7.25 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension foo.
} .
test cmdAH-7.26 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension .foo
} .foo
test cmdAH-7.27 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension abc.def
} .def
test cmdAH-7.28 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension abc.def.ghi
} .ghi
test cmdAH-7.29 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension a/b/c.d
} .d
test cmdAH-7.30 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension a/b.c/d
} {}
test cmdAH-7.31 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension a\\b.c\\
} {}
test cmdAH-7.32 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension a\\b\\c.d
} .d
test cmdAH-7.33 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension a\\b.c\\d
} {}
test cmdAH-7.34 {Tcl_FileObjCmd: extension} {
testsetplatform windows
file extension a\\b.c\\
} {}
set num 35
foreach value {a..b a...b a.c..b ..b} result {..b ...b ..b ..b} {
foreach p {unix mac windows} {
; test cmdAH-7.$num {Tcl_FileObjCmd: extension} "
testsetplatform $p
file extension $value
" $result
incr num
}
}
# pathtype
test cmdAH-8.1 {Tcl_FileObjCmd: pathtype} {
testsetplatform unix
list [catch {file pathtype a b} msg] $msg
} {1 {wrong # args: should be "file pathtype name"}}
test cmdAH-8.2 {Tcl_FileObjCmd: pathtype} {
testsetplatform unix
file pathtype /a
} absolute
test cmdAH-8.3 {Tcl_FileObjCmd: pathtype} {
testsetplatform unix
file p a
} relative
test cmdAH-8.4 {Tcl_FileObjCmd: pathtype} {
testsetplatform windows
file pathtype c:a
} volumerelative
# split
test cmdAH-9.1 {Tcl_FileObjCmd: split} {
testsetplatform unix
list [catch {file split a b} msg] $msg
} {1 {wrong # args: should be "file split name"}}
test cmdAH-9.2 {Tcl_FileObjCmd: split} {
testsetplatform unix
file split a
} a
test cmdAH-9.3 {Tcl_FileObjCmd: split} {
testsetplatform unix
file split a/b
} {a b}
# join
test cmdAH-10.1 {Tcl_FileObjCmd: join} {
testsetplatform unix
file join a
} a
test cmdAH-10.2 {Tcl_FileObjCmd: join} {
testsetplatform unix
file join a b
} a/b
test cmdAH-10.3 {Tcl_FileObjCmd: join} {
testsetplatform unix
file join a b c d
} a/b/c/d
# error handling of Tcl_TranslateFileName
test cmdAH-11.1 {Tcl_FileObjCmd} {
testsetplatform unix
list [catch {file atime ~_bad_user} msg] $msg
} {1 {user "_bad_user" doesn't exist}}
testsetplatform $platform
}
# readable
if {[info commands testchmod] == {}} {
puts "This application hasn't been compiled with the \"testchmod\""
puts "command, so I can't test Tcl_FileObjCmd etc."
} else {
makeFile abcde gorp.file
makeDirectory dir.file
test cmdAH-12.1 {Tcl_FileObjCmd: readable} {
list [catch {file readable a b} msg] $msg
} {1 {wrong # args: should be "file readable name"}}
testchmod 444 gorp.file
test cmdAH-12.2 {Tcl_FileObjCmd: readable} {
file readable gorp.file
} 1
testchmod 333 gorp.file
test cmdAH-12.3 {Tcl_FileObjCmd: readable} {unixOnly && !root} {
file reada gorp.file
} 0
# writable
test cmdAH-13.1 {Tcl_FileObjCmd: writable} {
list [catch {file writable a b} msg] $msg
} {1 {wrong # args: should be "file writable name"}}
testchmod 555 gorp.file
test cmdAH-13.2 {Tcl_FileObjCmd: writable} {!root} {
file writable gorp.file
} 0
testchmod 222 gorp.file
test cmdAH-13.3 {Tcl_FileObjCmd: writable} {
file writable gorp.file
} 1
# executable
file delete -force dir.file gorp.file
file mkdir dir.file
makeFile abcde gorp.file
test cmdAH-14.1 {Tcl_FileObjCmd: executable} {
list [catch {file executable a b} msg] $msg
} {1 {wrong # args: should be "file executable name"}}
test cmdAH-14.2 {Tcl_FileObjCmd: executable} {
file executable gorp.file
} 0
test cmdAH-14.3 {Tcl_FileObjCmd: executable} {unix} {
# Only on unix will setting the execute bit on a regular file
# cause that file to be executable.
testchmod 775 gorp.file
file exe gorp.file
} 1
test cmdAH-14.4 {Tcl_FileObjCmd: executable} {mac} {
# On mac, the only executable files are of type APPL.
set x [file exe gorp.file]
file attrib gorp.file -type APPL
lappend x [file exe gorp.file]
} {0 1}
test cmdAH-14.5 {Tcl_FileObjCmd: executable} {pc} {
# On pc, must be a .exe, .com, etc.
set x [file exe gorp.file]
makeFile foo gorp.exe
lappend x [file exe gorp.exe]
file delete gorp.exe
set x
} {0 1}
test cmdAH-14.6 {Tcl_FileObjCmd: executable} {
# Directories are always executable.
file exe dir.file
} 1
file delete -force dir.file
file delete gorp.file
file delete link.file
}
# exists
test cmdAH-15.1 {Tcl_FileObjCmd: exists} {
list [catch {file exists a b} msg] $msg
} {1 {wrong # args: should be "file exists name"}}
test cmdAH-15.2 {Tcl_FileObjCmd: exists} {file exists gorp.file} 0
test cmdAH-15.3 {Tcl_FileObjCmd: exists} {
file exists [file join dir.file gorp.file]
} 0
catch {
makeFile abcde gorp.file
makeDirectory dir.file
makeFile 12345 [file join dir.file gorp.file]
}
test cmdAH-15.4 {Tcl_FileObjCmd: exists} {
file exists gorp.file
} 1
test cmdAH-15.5 {Tcl_FileObjCmd: exists} {
file exists [file join dir.file gorp.file]
} 1
# nativename
if {[info commands testsetplatform] == {}} {
puts "This application hasn't been compiled with the \"testsetplatform\""
puts "command, so I can't test Tcl_FileObjCmd etc."
} else {
test cmdAH-15.6 {Tcl_FileObjCmd: nativename} {
testsetplatform unix
list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
} {0 a/b {}}
test cmdAH-15.7 {Tcl_FileObjCmd: nativename} {
testsetplatform windows
list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
} {0 {a\b} {}}
test cmdAH-15.8 {Tcl_FileObjCmd: nativename} {
testsetplatform mac
list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
} {0 :a:b {}}
}
test cmdAH-15.9 {Tcl_FileObjCmd: ~ : exists} {
file exists ~nOsUcHuSeR
} 0
test cmdAH-15.10 {Tcl_FileObjCmd: ~ : nativename} {
# should probably be 0 in fact...
catch {file nativename ~nOsUcHuSeR}
} 1
# The test below has to be done in /tmp rather than the current
# directory in order to guarantee (?) a local file system: some
# NFS file systems won't do the stuff below correctly.
if {$tcl_platform(platform) == "unix"} {
file delete /tmp/tcl.foo.dir/file
removeDirectory /tmp/tcl.foo.dir
makeDirectory /tmp/tcl.foo.dir
makeFile 12345 /tmp/tcl.foo.dir/file
exec chmod 000 /tmp/tcl.foo.dir
if {$user != "root"} {
test cmdAH-15.9 {Tcl_FileObjCmd: exists} {
file exists /tmp/tcl.foo.dir/file
} 0
}
exec chmod 775 /tmp/tcl.foo.dir
file delete /tmp/tcl.foo.dir/file
removeDirectory /tmp/tcl.foo.dir
}
# Stat related commands
catch {testsetplatform $platform}
file delete gorp.file
makeFile "Test string" gorp.file
catch {exec chmod 765 gorp.file}
# atime
test cmdAH-16.1 {Tcl_FileObjCmd: atime} {
list [catch {file atime a b} msg] $msg
} {1 {wrong # args: should be "file atime name"}}
test cmdAH-16.2 {Tcl_FileObjCmd: atime} {
catch {unset stat}
file stat gorp.file stat
list [expr {[file mtime gorp.file] == $stat(mtime)}] \
[expr {[file atime gorp.file] == $stat(atime)}]
} {1 1}
test cmdAH-16.3 {Tcl_FileObjCmd: atime} {
string tolower [list [catch {file atime _bogus_} msg] \
$msg $errorCode]
} {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
# isdirectory
test cmdAH-17.1 {Tcl_FileObjCmd: isdirectory} {
list [catch {file isdirectory a b} msg] $msg
} {1 {wrong # args: should be "file isdirectory name"}}
test cmdAH-17.2 {Tcl_FileObjCmd: isdirectory} {
file isdirectory gorp.file
} 0
test cmdAH-17.3 {Tcl_FileObjCmd: isdirectory} {
file isd dir.file
} 1
# isfile
test cmdAH-18.1 {Tcl_FileObjCmd: isfile} {
list [catch {file isfile a b} msg] $msg
} {1 {wrong # args: should be "file isfile name"}}
test cmdAH-18.2 {Tcl_FileObjCmd: isfile} {file isfile gorp.file} 1
test cmdAH-18.3 {Tcl_FileObjCmd: isfile} {file isfile dir.file} 0
# lstat and readlink: don't run these tests everywhere, since not all
# sites will have symbolic links
catch {exec ln -s gorp.file link.file}
test cmdAH-19.1 {Tcl_FileObjCmd: lstat} {
list [catch {file lstat a} msg] $msg
} {1 {wrong # args: should be "file lstat name varName"}}
test cmdAH-19.2 {Tcl_FileObjCmd: lstat} {
list [catch {file lstat a b c} msg] $msg
} {1 {wrong # args: should be "file lstat name varName"}}
test cmdAH-19.3 {Tcl_FileObjCmd: lstat} {unixOnly nonPortable} {
catch {unset stat}
file lstat link.file stat
lsort [array names stat]
} {atime ctime dev gid ino mode mtime nlink size type uid}
test cmdAH-19.4 {Tcl_FileObjCmd: lstat} {unixOnly nonPortable} {
catch {unset stat}
file lstat link.file stat
list $stat(nlink) [expr $stat(mode)&0777] $stat(type)
} {1 511 link}
test cmdAH-19.5 {Tcl_FileObjCmd: lstat errors} {nonPortable} {
string tolower [list [catch {file lstat _bogus_ stat} msg] \
$msg $errorCode]
} {1 {couldn't lstat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
test cmdAH-19.6 {Tcl_FileObjCmd: lstat errors} {
catch {unset x}
set x 44
list [catch {file lstat gorp.file x} msg] $msg $errorCode
} {1 {can't set "x(dev)": variable isn't array} NONE}
catch {unset stat}
# mtime
test cmdAH-20.1 {Tcl_FileObjCmd: mtime} {
list [catch {file mtime a b} msg] $msg
} {1 {wrong # args: should be "file mtime name"}}
test cmdAH-20.2 {Tcl_FileObjCmd: mtime} {
set old [file mtime gorp.file]
after 2000
set f [open gorp.file w]
puts $f "More text"
close $f
set new [file mtime gorp.file]
expr {($new > $old) && ($new <= ($old+5))}
} {1}
test cmdAH-20.3 {Tcl_FileObjCmd: mtime} {
catch {unset stat}
file stat gorp.file stat
list [expr {[file mtime gorp.file] == $stat(mtime)}] \
[expr {[file atime gorp.file] == $stat(atime)}]
} {1 1}
test cmdAH-20.4 {Tcl_FileObjCmd: mtime} {
string tolower [list [catch {file mtime _bogus_} msg] $msg \
$errorCode]
} {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
test cmdAH-20.5 {Tcl_FileObjCmd: mtime} {
# Under Unix, use a file in /tmp to avoid clock skew due to NFS.
# On other platforms, just use a file in the local directory.
if {$tcl_platform(platform) == "unix"} {
set name /tmp/tcl.test
} else {
set name tf
}
# Borland file times were off by timezone. Make sure that a new file's
# time is correct. 10 seconds variance is allowed used due to slow
# networks or clock skew on a network drive.
file delete -force $name
close [open $name w]
set a [expr abs([clock seconds]-[file mtime $name])<10]
file delete $name
set a
} {1}
# owned
test cmdAH-21.1 {Tcl_FileObjCmd: owned} {
list [catch {file owned a b} msg] $msg
} {1 {wrong # args: should be "file owned name"}}
test cmdAH-21.2 {Tcl_FileObjCmd: owned} {
file owned gorp.file
} 1
test cmdAH-21.3 {Tcl_FileObjCmd: owned} {unixOnly && !root} {
file owned /
} 0
# readlink
test cmdAH-22.1 {Tcl_FileObjCmd: readlink} {
list [catch {file readlink a b} msg] $msg
} {1 {wrong # args: should be "file readlink name"}}
test cmdAH-22.2 {Tcl_FileObjCmd: readlink} {unixOnly nonPortable} {
file readlink link.file
} gorp.file
test cmdAH-22.3 {Tcl_FileObjCmd: readlink errors} {unixOnly nonPortable} {
list [catch {file readlink _bogus_} msg] [string tolower $msg] \
[string tolower $errorCode]
} {1 {couldn't readlink "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
test cmdAH-22.4 {Tcl_FileObjCmd: readlink errors} {macOnly nonPortable} {
list [catch {file readlink _bogus_} msg] [string tolower $msg] \
[string tolower $errorCode]
} {1 {couldn't readlink "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
test cmdAH-22.5 {Tcl_FileObjCmd: readlink errors} {pcOnly nonPortable} {
list [catch {file readlink _bogus_} msg] [string tolower $msg] \
[string tolower $errorCode]
} {1 {couldn't readlink "_bogus_": invalid argument} {posix einval {invalid argument}}}
# size
test cmdAH-23.1 {Tcl_FileObjCmd: size} {
list [catch {file size a b} msg] $msg
} {1 {wrong # args: should be "file size name"}}
test cmdAH-23.2 {Tcl_FileObjCmd: size} {
set oldsize [file size gorp.file]
set f [open gorp.file a]
fconfigure $f -translation lf -eofchar {}
puts $f "More text"
close $f
expr {[file size gorp.file] - $oldsize}
} {10}
test cmdAH-23.3 {Tcl_FileObjCmd: size} {
string tolower [list [catch {file size _bogus_} msg] $msg \
$errorCode]
} {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
# stat
catch {testsetplatform $platform}
makeFile "Test string" gorp.file
catch {exec chmod 765 gorp.file}
test cmdAH-24.1 {Tcl_FileObjCmd: stat} {
list [catch {file stat _bogus_} msg] $msg $errorCode
} {1 {wrong # args: should be "file stat name varName"} NONE}
test cmdAH-24.2 {Tcl_FileObjCmd: stat} {
list [catch {file stat _bogus_ a b} msg] $msg $errorCode
} {1 {wrong # args: should be "file stat name varName"} NONE}
test cmdAH-24.3 {Tcl_FileObjCmd: stat} {
catch {unset stat}
file stat gorp.file stat
lsort [array names stat]
} {atime ctime dev gid ino mode mtime nlink size type uid}
test cmdAH-24.4 {Tcl_FileObjCmd: stat} {
catch {unset stat}
file stat gorp.file stat
list $stat(nlink) $stat(size) $stat(type)
} {1 12 file}
test cmdAH-24.5 {Tcl_FileObjCmd: stat} {unix} {
catch {unset stat}
file stat gorp.file stat
expr $stat(mode)&0777
} {501}
test cmdAH-24.6 {Tcl_FileObjCmd: stat} {
string tolower [list [catch {file stat _bogus_ stat} msg] \
$msg $errorCode]
} {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
test cmdAH-24.7 {Tcl_FileObjCmd: stat} {
catch {unset x}
set x 44
list [catch {file stat gorp.file x} msg] $msg $errorCode
} {1 {can't set "x(dev)": variable isn't array} NONE}
catch {unset stat}
# type
file delete link.file
test cmdAH-25.1 {Tcl_FileObjCmd: type} {
list [catch {file size a b} msg] $msg
} {1 {wrong # args: should be "file size name"}}
test cmdAH-25.2 {Tcl_FileObjCmd: type} {
file type dir.file
} directory
test cmdAH-25.3 {Tcl_FileObjCmd: type} {
file type gorp.file
} file
test cmdAH-25.4 {Tcl_FileObjCmd: type} {unixOnly nonPortable} {
exec ln -s a/b/c link.file
set result [file type link.file]
file delete link.file
set result
} link
test cmdAH-25.5 {Tcl_FileObjCmd: type} {
string tolower [list [catch {file type _bogus_} msg] $msg $errorCode]
} {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
# Error conditions
test cmdAH-26.1 {error conditions} {
list [catch {file gorp x} msg] $msg
} {1 {bad option "gorp": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-26.2 {error conditions} {
list [catch {file ex x} msg] $msg
} {1 {ambiguous option "ex": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-26.3 {error conditions} {
list [catch {file is x} msg] $msg
} {1 {ambiguous option "is": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-26.4 {error conditions} {
list [catch {file z x} msg] $msg
} {1 {bad option "z": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-26.5 {error conditions} {
list [catch {file read x} msg] $msg
} {1 {ambiguous option "read": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-26.6 {error conditions} {
list [catch {file s x} msg] $msg
} {1 {ambiguous option "s": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-26.7 {error conditions} {
list [catch {file t x} msg] $msg
} {1 {ambiguous option "t": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
test cmdAH-26.8 {error conditions} {
list [catch {file dirname ~woohgy} msg] $msg
} {1 {user "woohgy" doesn't exist}}
catch {testsetplatform $platform}
catch {unset platform}
catch {exec chmod 777 dir.file}
file delete -force dir.file
file delete gorp.file
file delete link.file
concat ""
|