This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #64772] make the read-only-sync test a bit more portable
authorTony Cook <tony@develop-help.com>
Sat, 23 Jun 2012 03:41:19 +0000 (13:41 +1000)
committerTony Cook <tony@develop-help.com>
Sun, 24 Jun 2012 01:39:39 +0000 (11:39 +1000)
- Win32 simply doesn't support fsync, and %Config reflects that

- sync() on a file seems more portable to me than on a directory, and
  the first is enough to test the code path we want to test.

- AIX is documented to fail fsync() on a read-only handle, so skip
  there

dist/IO/t/io_xs.t

index 968b3f5..85fbc56 100644 (file)
@@ -40,10 +40,12 @@ $x->setpos(undef);
 ok($!, "setpos(undef) makes errno non-zero");
 
 SKIP:
-{
-    $^O eq "MSWin32"
-       and skip "directory sync doesn't apply to MSWin32", 1;
-    open my $dh, "<", "."
-       or skip "Cannot open the cwd", 1;
-    ok($dh->sync, "sync to a read only directory handle");
+{ # [perl #64772] IO::Handle->sync fails on an O_RDONLY descriptor
+    $Config{d_fsync}
+       or skip "No fsync", 1;
+    $^O eq 'aix'
+      and skip "fsync() documented to fail on non-writable handles on AIX", 1;
+    open my $fh, "<", "t/io_xs.t"
+       or skip "Cannot open t/io_xs.t read-only: $!", 1;
+    ok($fh->sync, "sync to a read only handle");
 }