]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - t/img.t
Added a comment: Fixed... by upgrading!
[git.ikiwiki.info.git] / t / img.t
diff --git a/t/img.t b/t/img.t
index 05a91aff696b1ee51a5e7354c0c92b72ed9a4028..6049042c2311b8055e10c87c104ac7d797bad40f 100755 (executable)
--- a/t/img.t
+++ b/t/img.t
@@ -13,6 +13,7 @@ package IkiWiki;
 
 use warnings;
 use strict;
+use Cwd qw(getcwd);
 use Test::More;
 plan(skip_all => "Image::Magick not available")
        unless eval q{use Image::Magick; 1};
@@ -27,10 +28,10 @@ if ($installed) {
 }
 else {
        ok(! system("make -s ikiwiki.out"));
-       @command = qw(perl -I. ./ikiwiki.out
+       @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
                --underlaydir=underlays/basewiki
                --set underlaydirbase=underlays
-               --templatedir=templates);
+               --templatedir=templates));
 }
 
 push @command, qw(--set usedirs=0 --plugin img t/tmp/in t/tmp/out --verbose);
@@ -106,7 +107,7 @@ sub size($) {
        my $filename = shift;
        my $im = Image::Magick->new();
        my $r = $im->Read(":$filename");
-       return "no image" if $r;
+       return "no image: $r" if $r;
        my $w = $im->Get("width");
        my $h = $im->Get("height");
        return "${w}x${h}";
@@ -154,6 +155,19 @@ ok(! -e "$outpath/666x-really-pdf.jpg");
 like($outhtml, qr/${quot}really-pdf\.png${quot} does not seem to be a valid png file/);
 ok(! -e "$outpath/666x-really-pdf.png");
 
+# resize is deterministic when deterministic=1
+ok(utime(333333333, 333333333, "t/tmp/in/redsquare.png"));
+ok(! system("rm $outpath/10x-redsquare.png"));
+ok(! system(@command, '--set-yaml', 'img_allowed_formats=[JPEG, PNG, svg, pdf]', '--set', 'deterministic=1', "--rebuild"));
+ok(! system("cp $outpath/10x-redsquare.png $outpath/10x-redsquare.png.orig"));
+ok(utime(444444444, 444444444, "t/tmp/in/redsquare.png"));
+ok(! system("rm $outpath/10x-redsquare.png"));
+ok(! system(@command, '--set-yaml', 'img_allowed_formats=[JPEG, PNG, svg, pdf]', '--set', 'deterministic=1', "--rebuild"));
+ok(
+       ! system("cmp $outpath/10x-redsquare.png $outpath/10x-redsquare.png.orig"),
+       "resize is deterministic when configured with deterministic=1"
+);
+
 # disable support for uncommon formats and try again
 ok(! system(@command, "--rebuild"));
 ok(! -e "$outpath/10x-bluesquare.png");