]> git.imager.perl.org - imager.git/commitdiff
add some extra error reporting to I/O layer tests
authorTony Cook <tony@develop-help.com>
Wed, 23 Mar 2016 09:29:42 +0000 (20:29 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 23 Mar 2016 09:29:42 +0000 (20:29 +1100)
This might catch a failure seen on Win32.

http://cpantesters.org/cpan/report/99781689-6bf5-1014-897a-75cb4eee1325

t/200-file/010-iolayer.t

index 9f01a0458634c4485fd0a2209c0281cd748dcfe4..440a0f35d6f40a8a0b1e8b16d0a59d33e34773f8 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 288;
+use Test::More tests => 291;
 use Imager::Test qw(is_image);
 # for SEEK_SET etc, Fcntl doesn't provide these in 5.005_03
 use IO::Seekable;
@@ -852,7 +852,7 @@ SKIP:
 SKIP:
 {
   $Config{useperlio}
-    or skip "PerlIO::scalar requires perlio", 13;
+    or skip "PerlIO::scalar requires perlio", 16;
 
   my $foo;
   open my $fh, "+<", \$foo;
@@ -879,10 +879,32 @@ SKIP:
     or print "# ", $im->errstr, "\n";
 
   close $fh2;
+  my $tmp = $foo;
   open my $fh3, "<", \$foo;
   my $im2 = Imager->new(fh => $fh3);
-  ok($im2, "read image from a scalar fh");
-  is_image($im, $im2, "check they match");
+ SKIP:
+  {
+    unless (ok($im2, "read image from a scalar fh")) {
+      diag "read image from a scalar fh :".Imager->errstr;
+      diag "layer: $_" for PerlIO::get_layers($fh3);
+      skip "Couldn't read the image", 1;
+    }
+    is_image($im, $im2, "check they match");
+  }
+  close $fh3;
+  open my $fh4, "<", \$foo;
+  my $im3 = Imager->new;
+ SKIP:
+  {
+    unless (ok($im3->read(fh => $fh4),
+              "read image from a scalar fh (second try)")) {
+      diag "read image from a scalar fh :".$im3->errstr;
+      diag "layer: $_" for PerlIO::get_layers($fh4);
+      skip "Couldn't read the image", 1;
+    }
+    is_image($im, $im3, "check they match");
+  }
+  is($foo, $tmp, "check \$foo not modified");
 }
 
 {