Subject: | [PATCH] Autodetect file type support in Makefile.PL to prevent test failures |
Makefile.PL assumes that ImageMagick has been compiled to support a
number of file types that may not in fact be supported. This causes the
test suite to fail. The attached patch adds file type detection using
the same mechanism used to detect include and library paths, by calling
ImageMagick binaries and parsing the output.
Subject: | PerlMagick-6.59-Makefile.PL.patch |
--- ../orig/PerlMagick-6.59/Makefile.PL 2010-02-04 06:47:02.000000000 -0800
+++ Makefile.PL 2010-10-08 08:20:58.000000000 -0700
@@ -121,19 +121,35 @@
return ($inc, $lib);
}
-
+sub AutodetectDelegates {
+ #try to get configuration info via identify or convert utilities
+ my $conf = `identify -list format 2>$devnull` || `convert -list format 2>$devnull`;
+ foreach my $line (split '\n', $conf) {
+ next unless $line =~ /^DELEGATES\s+/;
+ my (undef, @delegates) = split /\s+/, $line;
+ last;
+ };
+ return @delegates;
+}
+
# Compute test specification
my $delegate_tests='t/*.t';
-my $delegate;
-foreach $delegate (qw/bzlib djvu fftw fontconfig freetype jpeg jng jp2 lcms mpeg png rsvg tiff x11 xml wmf zlib/) {
- if ( -d "t/$delegate" ) {
- if ( defined($ENV{'DISPLAY'}) && ($^O ne 'MSWin32') ) {
- if ( defined $ENV{'DISPLAY'} ) {
- $delegate_tests .= " t/$delegate/*.t";
+my @tested_delegates = qw/bzlib djvu fftw fontconfig freetype jpeg jng jp2 lcms mpeg png rsvg tiff x11 xml wmf zlib/;
+my @supported_delegates = AutodetectDelegates();
+# find the intersection of tested and suppored delegates to build the delegate test directory list
+my %seen_delegates = ();
+$seen_delegates{$_}++ for @supported_delegates;
+foreach my $delegate (@tested_delegates) {
+ if ( $seen_delegates{$_} ) {
+ if ( -d "t/$delegate" ) {
+ if ( defined($ENV{'DISPLAY'}) && ($^O ne 'MSWin32') ) {
+ if ( defined $ENV{'DISPLAY'} ) {
+ $delegate_tests .= " t/$delegate/*.t";
+ }
+ next;
}
- next;
+ $delegate_tests .= " t/$delegate/*.t";
}
- $delegate_tests .= " t/$delegate/*.t";
}
}