Test::Without::GD - pretend GD is without some file formats
# command line perl -MTest::Without::GD=-gif,-png myprog.pl ... # or in script use Test::Without::GD '-jpeg'; # or by method use Test::Without::GD; Test::Without::GD->without_png();
This module mangles the GD module to pretend that some of its file formats are not available, as can happen if libgd was built without some of its supporting libraries, or configs set in the GD module, etc.
GD
This can be used for testing to check how module code etc behaves without some of GD's things, or to exercise .t scripts to see that they skip checks for features not available.
The mangling is done by deleting or replacing selected GD::Image methods. Deleting uses Sub::Delete (perhaps that will change). There's an experimental no Test::Without::GD which tries to restore GD::Image back to normal operation. Is there any value in that? Usually the fakery will be for the duration of a script etc.
GD::Image
Sub::Delete
no Test::Without::GD
The module import recognises the following options
-png -jpeg -gif -gifanim -xpm
They correspond to the without_png() etc functions below. So for example to run a program pretending PNG is not available,
without_png()
perl -MTest::Without::GD=-png myprog.pl ...
Or when using the usual ExtUtils::MakeMaker test harness,
ExtUtils::MakeMaker
HARNESS_PERL_SWITCHES="-MTest::Without::GD=-png" make test
The options can be applied from a script too (or the functions below used),
use Test::Without::GD '-png';
Test::Without::GD->without_png()
Test::Without::GD->without_jpeg()
Test::Without::GD->without_gif()
Pretend that PNG, JPEG or GIF format is not available. This means removing the respective GD::Image methods,
_newFromPng() newFromPngData() png() _newFromJpeg() newFromJpegData() jpeg() _newFromGif() newFromGifData() gif()
as is the case when GD is built without HAVE_PNG, HAVE_JPEG or HAVE_GIF.
HAVE_PNG
HAVE_JPEG
HAVE_GIF
The documented entrypoints newFromPng(), newFromJpeg() and newFromGif() in fact remain, but their underlying _newFromPng() etc are removed causing them to die.
newFromPng()
newFromJpeg()
newFromGif()
_newFromPng()
Test::Without::GD->without_gifanim()
Pretend that animated GIF support is not available. This means replacing GD::Image methods
gifanimbegin(), gifanimadd(), gifanimend()
with instead
sub { die "libgd 2.0.33 or higher required for animated GIF support"; }
as is the case when GD is built without HAVE_ANIMGIF.
HAVE_ANIMGIF
Test::Without::GD->without_xpm()
Pretend that XPM format is not available. This means replacing GD::Image method
newFromXpm()
sub { $@ = "libgd was not built with xpm support\n"; return; }
as is the case when GD is built without HAVE_XPM.
HAVE_XPM
GD, Sub::Delete
http://user42.tuxfamily.org/test-variousbits/index.html
Copyright 2011, 2012, 2015 Kevin Ryde
Test-VariousBits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Test-VariousBits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Test-VariousBits. If not, see http://www.gnu.org/licenses/.
To install Test::VariousBits, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::VariousBits
CPAN shell
perl -MCPAN -e shell install Test::VariousBits
For more information on module installation, please visit the detailed CPAN module installation guide.