]> git.imager.perl.org - imager.git/blobdiff - t/t50basicoo.t
- fix a few compiler warnings
[imager.git] / t / t50basicoo.t
index 66f4537e35f15c9c2ce30987347e2a9d61f327e1..5138196ca6536b2e448d8b4b1e69ee509b459cdb 100644 (file)
@@ -9,6 +9,8 @@ use strict;
 use Imager;
 use IO::Seekable;
 
+my $buggy_giflib_file = "buggy_giflib.txt";
+
 Imager::init("log"=>"testout/t50basicoo.log");
 
 # single image/file types
@@ -40,9 +42,7 @@ my $img = Imager->new();
 my %files;
 @files{@types} = ({ file => "testout/t101.jpg"  },
                  { file => "testout/t102.png"  },
-                 { file => "testout/t103.raw", xsize=>150, ysize=>150
-                    #, type=>"raw" # TODO: was this there for a reason?
-                  },
+                 { file => "testout/t103.raw", xsize=>150, ysize=>150, type=>'raw'},
                  { file => "testout/t104.ppm"  },
                  { file => "testout/t105.gif"  },
                  { file => "testout/t106.tiff" },
@@ -65,32 +65,27 @@ for my $type (@types) {
 
   my %mopts = %opts;
   delete $mopts{file};
-  
+
   # read from a file handle
   my $fh = IO::File->new($opts{file}, "r");
   if (ok($fh, "opening $opts{file}")) {
     binmode $fh;
     my $fhimg = Imager->new;
-    my $fhrc = $fhimg->read(fh=>$fh, %mopts);
-    if (ok(!$fhrc, "check that type is required")) {
-      ok ($fhimg->errstr =~ /type parameter missing/, "check for no type error");
-    }
-    else {
-      skip("previous test failed");
-    }
-    if (ok($fhimg->read(fh=>$fh, %mopts, type=>$type), "read from fh")) {
-      ok(Imager::i_img_diff($img->{IMG}, $fhimg->{IMG}) == 0,
-         "image comparison after fh read");
-    }
-    else {
-      skip("no image to compare");
+    if (ok($fhimg->read(fh=>$fh, %mopts), "read from fh")) {
+      ok($fh->seek(0, SEEK_SET), "seek after read");
+      if (ok($fhimg->read(fh=>$fh, %mopts, type=>$type), "read from fh")) {
+       ok(Imager::i_img_diff($img->{IMG}, $fhimg->{IMG}) == 0,
+          "image comparison after fh read");
+      }
+      else {
+       skip("no image to compare");
+      }
+      ok($fh->seek(0, SEEK_SET), "seek after read");
     }
-    ok($fh->seek(0, SEEK_SET), "seek after read");
-    
+
     # read from a fd
     my $fdimg = Imager->new;
-    if (ok($fdimg->read(fd=>fileno($fh), %mopts, type=>$type), 
-           "read from fd")) {
+    if (ok($fdimg->read(fd=>fileno($fh), %mopts, type=>$type), "read from fd")) {
       ok(Imager::i_img_diff($img->{IMG}, $fdimg->{IMG}) == 0,
          "image comparistion after fd read");
     }
@@ -204,7 +199,8 @@ for my $type (@types) {
      "write to FH after writing $type");
   ok($fh->close, "closing FH after writing $type");
 
-  if ($type ne 'gif' || Imager::i_giflib_version() >= 4) {
+  if ($type ne 'gif' || 
+      (Imager::i_giflib_version() >= 4 && !-e $buggy_giflib_file)) {
     if (ok(open(DATA, "< $file"), "opening data source")) {
       binmode DATA;
       my $data = do { local $/; <DATA> };
@@ -297,7 +293,12 @@ for my $type (@types) {
     }
   }
   else {
-    skip("giflib < 4 doesn't support callbacks", 8);
+    if (-e $buggy_giflib_file) {
+      skip("see $buggy_giflib_file", 8);
+    }
+    else {
+      skip("giflib < 4 doesn't support callbacks", 8);
+    }
   }
 }
 
@@ -349,11 +350,12 @@ Imager::malloc_state();
 #print "ok 2\n";
 
 sub ok {
-  my ($ok, $msg, $img) = @_;
+  my ($ok, $msg, $img, $why, $skipcount) = @_;
 
   ++$test_num;
   if ($ok) {
     print "ok $test_num # $msg\n";
+    Imager::log_entry("ok $test_num # $msg\n", 0);
   }
   else {
     my $err;
@@ -362,8 +364,9 @@ sub ok {
     my $line = "not ok $test_num # line ".(caller)[2].": $msg";
     $line .= ": $err" if $err;
     print $line, "\n";
+    Imager::log_entry($line."\n", 0);
   }
-
+  skip($why, $skipcount) if defined $why;
   $ok;
 }