diff options
author | chrysn <chrysn@fsfe.org> | 2014-07-04 15:04:22 +0200 |
---|---|---|
committer | chrysn <chrysn@fsfe.org> | 2014-07-04 15:16:07 +0200 |
commit | 4bd25423acabd6bdf65676c6d33c069a39ab5004 (patch) | |
tree | 8bd6f60443c48fd30dabc0d15b2d555d2c1e2066 /t | |
parent | bcc209eb5acd26e3751c5869cd5c1ebe66b0bf03 (diff) | |
download | ikiwiki-4bd25423acabd6bdf65676c6d33c069a39ab5004.tar ikiwiki-4bd25423acabd6bdf65676c6d33c069a39ab5004.tar.gz |
add unittests for img
this focuses on the features introduced in
http://ikiwiki.info/bugs/svg_and_pdf_conversion_fails/
Diffstat (limited to 't')
-rwxr-xr-x | t/img.t | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/t/img.t b/t/img.t new file mode 100755 index 000000000..b42db26cf --- /dev/null +++ b/t/img.t @@ -0,0 +1,60 @@ +#!/usr/bin/perl +# +# unit test that creates test images (png, svg, multi-page pdf), runs ikiwiki +# on them, checks the resulting images for plausibility based on their image +# sizes, and checks if they vanish when not required in the build process any +# more +# +package IkiWiki; + +use warnings; +use strict; +use Test::More; + +BEGIN { use_ok("IkiWiki"); } + +ok(! system("rm -rf t/tmp; mkdir -p t/tmp/in")); + +ok(! system("convert canvas:red -scale 20x20 t/tmp/in/simple.png")); +ok(! system("convert t/tmp/in/simple.png -extent 20x10 t/tmp/in/long.png")); +ok(! system("convert t/tmp/in/simple.png t/tmp/in/simple-svg.svg")); +# using different image sizes for different pages, so the pagenumber selection can be tested easily +ok(! system("convert t/tmp/in/simple.png t/tmp/in/long.png t/tmp/in/simple-pdf.pdf")); + +writefile("imgconversions.mdwn", "t/tmp/in", <<EOF +[[!img simple.png]] +[[!img simple.png size=10x]] +[[!img simple-svg.svg size=10x]] +[[!img simple-pdf.pdf size=10x]] +[[!img simple-pdf.pdf size=10x pagenumber=1]] +EOF +); + +ok(! system("make -s ikiwiki.out")); + +my $command = "perl -I. ./ikiwiki.out -set usedirs=0 -plugin img t/tmp/in t/tmp/out -verbose"; + +ok(! system($command)); + +my $outpath = "t/tmp/out/imgconversions"; +ok(`identify $outpath/10x-simple.png` =~ "PNG 10x10 "); +ok(`identify $outpath/10x-simple-svg.png` =~ "PNG 10x10 "); +ok(`identify $outpath/10x-simple-pdf.png` =~ "PNG 10x10 "); +ok(`identify $outpath/10x-p1-simple-pdf.png` =~ "PNG 10x5 "); + +# now let's remove them again + +writefile("imgconversions.mdwn", "t/tmp/in", "nothing to see here"); + +ok(! system("$command --refresh")); + +ok(! -e "$outpath/10x-simple.png"); +ok(! -e "$outpath/10x-simple-svg.png"); +ok(! -e "$outpath/10x-simple-pdf.png"); +ok(! -e "$outpath/10x-p1-simple-pdf.png"); + +# cleanup +ok(! system("rm -rf t/tmp")); +done_testing; + +1; |