This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #112272] test link()'s error returns (TODO)
authorTony Cook <tony@develop-help.com>
Mon, 7 May 2012 12:23:42 +0000 (22:23 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 28 May 2012 09:45:52 +0000 (19:45 +1000)
MANIFEST
t/win32/fs.t [new file with mode: 0644]

index 55622d7..ac56b4d 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5501,6 +5501,7 @@ t/uni/tr_utf8.t                   See if Unicode tr/// in utf8 works
 t/uni/universal.t              See if Unicode in calls to UNIVERSAL works
 t/uni/upper.t                  See if Unicode casing works
 t/uni/write.t                  See if Unicode formats work
+t/win32/fs.t                   Test Win32 link for compatibility
 t/win32/runenv.t               Test if Win* perl honors its env variables
 t/win32/system.t               See if system works in Win*
 t/win32/system_tests           Test runner for system.t
diff --git a/t/win32/fs.t b/t/win32/fs.t
new file mode 100644 (file)
index 0000000..0369f41
--- /dev/null
@@ -0,0 +1,41 @@
+#!./perl
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require "./test.pl";
+    eval 'use Errno';
+    die $@ if $@ and !is_miniperl();
+}
+
+use Config;
+
+plan tests => 4;
+
+my $tmpfile1 = tempfile();
+my $tmpfile2 = tempfile();
+
+SKIP: {
+    # RT #112272
+    -e $tmpfile1 || -e $tmpfile2
+        and skip("somehow, the files exist", 4);
+    ok(!link($tmpfile1, $tmpfile2),
+       "Cannot link to unknown file");
+    warn $!;
+    is(0+$!, &Errno::ENOENT, "check errno is ENOENT");
+    open my $fh, ">", $tmpfile1
+       or skip("Cannot create test link src", 2);
+    close $fh;
+    open my $fh, ">", $tmpfile2
+       or skip("Cannot create test link target", 2);
+    close $fh;
+    ok(!link($tmpfile1, $tmpfile2),
+       "Cannot link to existing file");
+    warn $!;
+    local $TODO = "not yet implemented";
+    is(0+$!, &Errno::EEXIST, "check for EEXIST");
+}
+
+END {
+    unlink($tmpfile1, $tmpfile2);
+}