6 push @INC, "::lib:$MacPerl::Architecture" if $^O eq 'MacOS';
12 my $tests = $^O eq 'MacOS' ? 17 : 14;
13 printf "1..%d\n", $tests * scalar(@pass);
18 for my $pass (@pass) {
20 my $loopconst = $pass*$tests;
22 # First we create a file
23 open(F, ">file-$$") or die;
24 binmode F; # for DOSISH platforms, because test 3 copies to stdout
25 printf F "ok %d\n", 3 + $loopconst;
28 copy "file-$$", "copy-$$";
30 open(F, "copy-$$") or die;
34 print "not " if -s "file-$$" != -s "copy-$$";
35 printf "ok %d\n", 1 + $loopconst;
37 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
38 printf "ok %d\n", 2+$loopconst;
40 binmode STDOUT unless $^O eq 'VMS'; # Copy::copy works in binary mode
41 copy "copy-$$", \*STDOUT;
42 unlink "copy-$$" or die "unlink: $!";
46 open(R, "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
47 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
48 printf "ok %d\n", 4+$loopconst;
49 unlink "copy-$$" or die "unlink: $!";
52 close(F) or die "close: $!";
53 open(R, "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
54 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
55 printf "ok %d\n", 5+$loopconst;
56 unlink "copy-$$" or die "unlink: $!";
59 $fh = IO::File->new(">copy-$$") or die "Cannot open copy-$$:$!";
62 $fh->close or die "close: $!";
63 open(R, "copy-$$") or die; $foo = <R>; close(R);
64 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
65 printf "ok %d\n", 6+$loopconst;
66 unlink "copy-$$" or die "unlink: $!";
68 my $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
72 open(R, "copy-$$") or die; $foo = <R>; close(R);
73 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
74 printf "ok %d\n", 7+$loopconst;
75 unlink "file-$$" or die "unlink: $!";
77 print "# moved missing file.\nnot " if move("file-$$", "copy-$$");
78 print "# target disappeared.\nnot " if not -e "copy-$$";
79 printf "ok %d\n", 8+$loopconst;
81 move "copy-$$", "file-$$" or print "# move did not succeed.\n";
82 print "# not moved: $!\nnot " unless -e "file-$$" and not -e "copy-$$";
83 open(R, "file-$$") or die; $foo = <R>; close(R);
84 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
85 printf "ok %d\n", 9+$loopconst;
90 copy "file-$$", "lib";
91 open(R, ":lib:file-$$") or die; $foo = <R>; close(R);
92 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
93 printf "ok %d\n", 10+$loopconst;
94 unlink ":lib:file-$$" or die "unlink: $!";
96 copy "file-$$", ":lib";
97 open(R, ":lib:file-$$") or die; $foo = <R>; close(R);
98 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
99 printf "ok %d\n", 11+$loopconst;
100 unlink ":lib:file-$$" or die "unlink: $!";
102 copy "file-$$", ":lib:";
103 open(R, ":lib:file-$$") or die; $foo = <R>; close(R);
104 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
105 printf "ok %d\n", 12+$loopconst;
106 unlink ":lib:file-$$" or die "unlink: $!";
108 unless (-e 'lib:') { # make sure there's no volume called 'lib'
110 eval { (copy "file-$$", "lib:") || die "'lib:' is not a volume name"; };
112 print "not " unless ( $@ =~ m|'lib:' is not a volume name| );
114 printf "ok %d\n", 13+$loopconst;
116 move "file-$$", ":lib:";
117 open(R, ":lib:file-$$") or die "open :lib:file-$$: $!"; $foo = <R>; close(R);
118 print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst)
119 and not -e "file-$$";;
120 printf "ok %d\n", 14+$loopconst;
122 eval { copy("copy-$$", "copy-$$") };
123 printf "ok %d\n", 15+$loopconst
124 unless $@ =~ /are identical/ && -s "copy-$$";
126 unlink ":lib:file-$$" or die "unlink: $!";
131 copy "file-$$", "lib";
132 open(R, "lib/file-$$") or die; $foo = <R>; close(R);
133 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
134 printf "ok %d\n", 10+$loopconst;
135 unlink "lib/file-$$" or die "unlink: $!";
137 move "file-$$", "lib";
138 open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R);
139 print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst)
140 and not -e "file-$$";;
141 printf "ok %d\n", 11+$loopconst;
143 eval { copy("copy-$$", "copy-$$") };
144 printf "ok %d\n", 12+$loopconst
145 unless $@ =~ /are identical/ && -s "copy-$$";
147 unlink "lib/file-$$" or die "unlink: $!";
152 if ($Config{d_symlink}) {
153 open(F, ">file-$$") or die $!;
154 print F "dummy content\n";
156 symlink("file-$$", "symlink-$$") or die $!;
157 eval { copy("file-$$", "symlink-$$") };
158 print "not " if $@ !~ /are identical/ || -z "file-$$";
159 printf "ok %d\n", (++$test_i)+$loopconst;
163 printf "ok %d # Skipped: no symlinks on this platform\n", (++$test_i)+$loopconst;
166 if ($Config{d_link}) {
167 if ($^O ne 'MSWin32') {
168 open(F, ">file-$$") or die $!;
169 print F "dummy content\n";
171 link("file-$$", "hardlink-$$") or die $!;
172 eval { copy("file-$$", "hardlink-$$") };
173 print "not " if $@ !~ /are identical/ || -z "file-$$";
174 printf "ok %d\n", (++$test_i)+$loopconst;
175 unlink "hardlink-$$";
178 printf "ok %d # Skipped: can't test hardlinks on MSWin32\n", (++$test_i)+$loopconst;
181 printf "ok %d # Skipped: no hardlinks on this platform\n", (++$test_i)+$loopconst;
188 1 while unlink "file-$$";
189 if ($^O eq 'MacOS') {
190 1 while unlink ":lib:file-$$";
192 1 while unlink "lib/file-$$";