]> git.imager.perl.org - imager.git/commitdiff
clean up test files by default for some more test scripts
authorTony Cook <tony@develop-help.com>
Mon, 23 May 2011 12:22:23 +0000 (22:22 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 23 May 2011 12:22:23 +0000 (22:22 +1000)
t/t020masked.t
t/t021sixteen.t
t/t022double.t
t/t023palette.t
t/t05error.t
t/t07iolayer.t
t/t1000files.t
t/t101nojpeg.t
t/t103raw.t
t/t104ppm.t
t/t107bmp.t

index b10bb416d0f1897253e77e2a43cb20871da1d18d..3f59f83f62c87c3e0aa480bb37f0005417096d69 100644 (file)
@@ -6,7 +6,7 @@ use Imager::Test qw(is_color3 is_fcolor3);
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t020masked.log", 1);
+Imager->open_log(log => "testout/t020masked.log");
 
 my $base_rgb = Imager::ImgRaw::new(100, 100, 3);
 # put something in there
@@ -529,3 +529,9 @@ $mask->box(fill => { hatch => "check1x1" }, ymin => 40, xmax => 39);
        2, "write over right side");
   }
 }
+
+Imager->close_log();
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t020masked.log";
+}
index 14f713b70725856357b4bd80cb58b2803493ab53..a49e53fc096e67b8585bf117aa8c176aefa0230b 100644 (file)
@@ -6,7 +6,7 @@ BEGIN { use_ok(Imager=>qw(:all :handy)) }
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t021sixteen.log", 1);
+Imager->open_log(log => "testout/t021sixteen.log");
 
 use Imager::Color::Float;
 use Imager::Test qw(test_image is_image image_bounds_checks test_colorf_gpix
@@ -230,3 +230,9 @@ cmp_ok(Imager->errstr, '=~', qr/channels must be between 1 and 4/,
     or print "# ", $im->errstr, "\n";
   is_deeply(\@wr_samples, \@samples, "check it matches");
 }
+
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t021sixteen.log";
+}
index 1def3807cf22ed2a58233a500397af7c127f987f..79aee302045f5d150daabd40b0f3703a66c88b2a 100644 (file)
@@ -7,7 +7,7 @@ use Imager::Test qw(test_image is_image);
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t022double.log", 1);
+Imager->open_log(log => "testout/t022double.log");
 
 use Imager::Test qw(image_bounds_checks test_colorf_gpix test_colorf_glin mask_tests);
 
@@ -168,3 +168,9 @@ cmp_ok(Imager->errstr, '=~', qr/channels must be between 1 and 4/,
   ok(!$im->to_rgb_double, "convert empty image to double");
   is($im->errstr, "empty input image", "check message");
 }
+
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t022double.log";
+}
index 3e3f3336279de7e4e716fb1ac06b83f0977194d0..2f50f29e91da44bebd3e10bb6712fae01d1e60bc 100644 (file)
@@ -6,6 +6,8 @@ BEGIN { use_ok("Imager"); }
 
 use Imager::Test qw(image_bounds_checks test_image is_color3);
 
+Imager->open_log(log => "testout/t023palette.log");
+
 sub isbin($$$);
 
 my $img = Imager->new(xsize=>50, ysize=>50, type=>'paletted');
@@ -343,6 +345,12 @@ cmp_ok(Imager->errstr, '=~', qr/Channels must be positive and <= 4/,
   is_color3($colors[8], 0, 0x33, 0x66, "9th should be 003366");
 }
 
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t023palette.log"
+}
+
 sub iscolor {
   my ($c1, $c2, $msg) = @_;
 
index 9ec40fa7e183fceffbdcc237ecbd3e4a78b6069c..e3ac15a5154fea9619fbc4c2c2342767b385364c 100644 (file)
@@ -5,7 +5,7 @@ BEGIN { use_ok("Imager", ":all") }
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t05error.log", 1);
+Imager->open_log(log => "testout/t05error.log");
 
 # try to read an invalid pnm file
 open FH, "< testimg/junk.ppm"
@@ -36,3 +36,8 @@ SKIP:{
   }
 }
 
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t05error.log";
+}
index 111fac63cfe01351647ebf17e4f78107c42c4068..83a3e9b97a69e658207043efe5c60b724cfd5a60 100644 (file)
@@ -8,7 +8,7 @@ BEGIN { use_ok(Imager => ':all') };
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t07iolayer.log", 1);
+Imager->open_log(log => "testout/t07iolayer.log");
 
 undef($/);
 # start by testing io buffer
@@ -252,6 +252,12 @@ SKIP:
   is($io->close, 0, "close");
 }
 
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t07.ppm", "testout/t07iolayer.log";
+}
+
 sub eof_read {
   my ($max_len) = @_;
 
index 2cf0a7c0ee75545a0efd3847a7651d68c4083668..f28c62297e2982ae8b8f3064bacc640d6b6466f7 100644 (file)
@@ -9,7 +9,7 @@ use Imager;
 
 -d "testout" or mkdir "testout";
 
-Imager::init_log("testout/t1000files.log", 1);
+Imager->open_log(log => "testout/t1000files.log");
 
 SKIP:
 {
@@ -186,6 +186,12 @@ probe_ok(<<JPEG2K, "jp2", "JPEG 2000");
 00 6A 70 32 63 FF 4F FF 51 00 2F 00 00 00 00 01
 JPEG2K
 
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t1000files.log";
+}
+
 sub probe_ok {
   my ($packed, $exp_type, $name) = @_;
 
index 5f47a80ac61884907a2c12f8b3ce8fb9359331ff..582d5bfdb4079f369eed3eb9dfda77b7e72a9a0c 100644 (file)
@@ -5,7 +5,7 @@ use Imager qw(:all);
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t101jpeg.log",1);
+Imager->open_log(log => "testout/t101jpeg.log");
 
 $Imager::formats{"jpeg"}
   and plan skip_all => "have jpeg support - this tests the lack of it";
@@ -20,3 +20,9 @@ ok(!$im->write(file=>"testout/nojpeg.jpg"), "should fail to write jpeg");
 cmp_ok($im->errstr, '=~', qr/format 'jpeg' not supported/, "check no jpeg message");
 ok(!grep($_ eq 'jpeg', Imager->read_types), "check jpeg not in read types");
 ok(!grep($_ eq 'jpeg', Imager->write_types), "check jpeg not in write types");
+
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t101jpeg.log";
+}
index 440c546e1c30f511b5c8de51cb412dd10f722b91..316ce271f89d1e6ffad625a8d8776f55ce4e255c 100644 (file)
@@ -6,7 +6,7 @@ use Imager::Test qw/is_color3 is_color4/;
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t103raw.log",1);
+Imager->open_log(log => "testout/t103raw.log");
 
 $| = 1;
 
@@ -270,9 +270,13 @@ SKIP:
            "check last channel zeroed");
 }
 
-unlink(qw(testout/t103_base.raw testout/t103_3to4.raw
-          testout/t103_line_int.raw testout/t103_img_int.raw))
-  unless $ENV{IMAGER_KEEP_FILES};
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t103raw.log";
+  unlink(qw(testout/t103_base.raw testout/t103_3to4.raw
+           testout/t103_line_int.raw testout/t103_img_int.raw))
+}
 
 sub read_test {
   my ($in, $xsize, $ysize, $data, $store, $intrl, $base) = @_;
index 0f9d8581a81032513c9324e5699f4d27fd684ebc..2cb3ac9f5ceebc3c75356597d7f3406e8ec7731a 100644 (file)
@@ -6,15 +6,18 @@ use Imager::Test qw(test_image_raw test_image_16 is_color3 is_color1 is_image);
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t104ppm.log",1);
+Imager->open_log(log => "testout/t104ppm.log");
 
 my $green = i_color_new(0,255,0,255);
 my $blue  = i_color_new(0,0,255,255);
 my $red   = i_color_new(255,0,0,255);
 
+my @files;
+
 my $img    = test_image_raw();
 
 my $fh = openimage(">testout/t104.ppm");
+push @files, "t104.ppm";
 my $IO = Imager::io_new_fd(fileno($fh));
 ok(i_writeppm_wiol($img, $IO), "write pnm low")
   or die "Cannot write testout/t104.ppm\n";
@@ -46,6 +49,7 @@ i_box_filled($gimg, 20, 20, 130, 130, $gray);
 i_box_filled($gimg, 40, 40, 110, 110, $dgray);
 i_arc($gimg, 75, 75, 30, 0, 361, $white);
 
+push @files, "t104_gray.pgm";
 open FH, "> testout/t104_gray.pgm" or die "Cannot create testout/t104_gray.pgm: $!\n";
 binmode FH;
 $IO = Imager::io_new_fd(fileno(FH));
@@ -225,6 +229,7 @@ is($ooim->tags(name=>'pnm_type'), 1, "check pnm_type tag");
   $im->box(filled => 1, xmin => 8, color => '#FFE0C0');
   $im->box(filled => 1, color => NC(0, 192, 192, 128),
           ymin => 8, xmax => 7);
+  push @files, "t104_alpha.ppm";
   ok($im->write(file=>"testout/t104_alpha.ppm", type=>'pnm'),
      "should succeed writing 4 channel image");
   my $imread = Imager->new;
@@ -254,6 +259,7 @@ is($ooim->tags(name=>'pnm_type'), 1, "check pnm_type tag");
   $im->box(filled => 1, xmin => 8, color => '#FFE0C0');
   $im->box(filled => 1, color => NC(0, 192, 192, 128),
           ymin => 8, xmax => 7);
+  push @files, "t104_alp16.ppm";
   ok($im->write(file=>"testout/t104_alp16.ppm", type=>'pnm', 
                pnm_write_wide_data => 1),
      "should succeed writing 4 channel image");
@@ -493,6 +499,7 @@ print "# check error handling\n";
   $im->box(filled => 1, xmax => 4, color => '#000000');
   $im->box(filled => 1, xmin => 5, color => '#FFFFFF');
   is($im->type, 'paletted', 'mono still paletted');
+  push @files, "t104_mono.pbm";
   ok($im->write(file => 'testout/t104_mono.pbm', type => 'pnm'),
      "save as pbm");
 
@@ -514,6 +521,7 @@ print "# check error handling\n";
   $im->box(filled => 1, xmax => 4, color => '#000000');
   $im->box(filled => 1, xmin => 5, color => '#FFFFFF');
   is($im->type, 'paletted', 'mono still paletted');
+  push @files, "t104_mono2.pbm";
   ok($im->write(file => 'testout/t104_mono2.pbm', type => 'pnm'),
      "save as pbm");
 
@@ -545,10 +553,12 @@ print "# check error handling\n";
   $data = '';
   ok($im->write(data => \$data, type => 'pnm'),
      "write 16-bit image as 16-bit/sample ppm");
+  push @files, "t104_16.ppm";
   $im->write(file=>'testout/t104_16.ppm');
   my $im16 = Imager->new;
   ok($im16->read(data => $data), "read it back");
   is($im16->tags(name => 'pnm_maxval'), 65535, "check maxval");
+  push @files, "t104_16b.ppm";
   $im16->write(file=>'testout/t104_16b.ppm');
   is_image($im, $im16, "check image matches");
 }
@@ -584,6 +594,13 @@ print "# check error handling\n";
   }
 }
 
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink "testout/t104ppm.log";
+  unlink map "testout/$_", @files;
+}
+
 sub openimage {
   my $fname = shift;
   local(*FH);
index 73fae3f790ddd9c200917d2250f83d9a4023d090..85e3f9bac771f4cafa98ec6daf30a85249ff1c2f 100644 (file)
@@ -6,8 +6,9 @@ use Imager::Test qw(test_image_raw is_image is_color3 test_image);
 
 -d "testout" or mkdir "testout";
 
-init_log("testout/t107bmp.log",1);
+Imager->open_log(log => "testout/t107bmp.log");
 
+my @files;
 my $debug_writes = 0;
 
 my $base_diff = 0;
@@ -21,10 +22,12 @@ my $img = test_image_raw();
 Imager::i_tags_add($img, 'i_xres', 0, '300', 0);
 Imager::i_tags_add($img, 'i_yres', 0, undef, 300);
 write_test($img, "testout/t107_24bit.bmp");
+push @files, "t107_24bit.bmp";
 # 'webmap' is noticably faster than the default
 my $im8 = Imager::i_img_to_pal($img, { make_colors=>'webmap', 
                                       translate=>'errdiff'});
 write_test($im8, "testout/t107_8bit.bmp");
+push @files, "t107_8bit.bmp";
 # use a fixed palette so we get reproducible results for the compressed
 # version
 my @pal16 = map { NC($_) } 
@@ -32,9 +35,11 @@ my @pal16 = map { NC($_) }
      2ead1b 0000f8 004b01 fd0000 0e1695 000002);
 my $im4 = Imager::i_img_to_pal($img, { colors=>\@pal16, make_colors=>'none' });
 write_test($im4, "testout/t107_4bit.bmp");
+push @files, "t107_4bit.bmp";
 my $im1 = Imager::i_img_to_pal($img, { colors=>[ NC(0, 0, 0), NC(176, 160, 144) ],
                               make_colors=>'none', translate=>'errdiff' });
 write_test($im1, "testout/t107_1bit.bmp");
+push @files, "t107_1bit.bmp";
 my $bi_rgb = 0;
 my $bi_rle8 = 1;
 my $bi_rle4 = 2;
@@ -62,6 +67,7 @@ ok($imoo->read(file=>'testout/t107_24bit.bmp'), "read via OO")
 
 ok($imoo->write(file=>'testout/t107_oo.bmp'), "write via OO")
   or print "# ",$imoo->errstr,"\n";
+push @files, "t107_oo.bmp";
 
 # various invalid format tests
 # we have so many different test images to try to detect all the possible
@@ -629,6 +635,7 @@ for my $comp (@comp) {
           ymin => 8, xmax => 7);
   ok($im->write(file=>"testout/t107_alpha.bmp", type=>'bmp'),
      "should succeed writing 4 channel image");
+  push @files, "t107_alpha.bmp";
   my $imread = Imager->new;
   ok($imread->read(file => 'testout/t107_alpha.bmp'), "read it back");
   is_color3($imread->getpixel('x' => 0, 'y' => 0), 0, 0, 0, 
@@ -658,6 +665,13 @@ for my $comp (@comp) {
   is($size, 67800, "check data size");
 }
 
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+  unlink map "testout/$_", @files;
+  unlink "testout/t107bmp.log";
+}
+
 sub write_test {
   my ($im, $filename) = @_;
   local *FH;