Having released a few versions of DBD::ODBC to CPAN lately I noticed an
increasing number of failures being logged that were caused by a) not
having DBI installed b) not having an ODBC driver manager installed.
After consultation with the cpan-testers on and off the cpan-testers
mailing list it appears they have made some changes to the way tests are
performed and reported and this has caused the new failure reports. The
advice I have received and implemented in DBD::ODBC is:
1. do not "use DBI" or "use DBI::DBD" because this will cause an
immediate failure if DBI is not installed and now be reported as a failure.
This caused me some headaches as I need the dbd_dbi_arch_dir method to
find the DBI header files and this dir is injected into
ExtUtils::MakeMaker INC before writeMakefile can be called. I also need
the DBI postamble but this is not an issue since postamble is already
called after writeMakefile is called.
I managed to solve this problem using ExtUtils::MakeMaker CONFIGURE
option like this:
$opts{CONFIGURE} = sub {
use DBI::DBD;
my $dbi_arch_dir = dbd_dbi_arch_dir();
if (exists($opts{INC})) {
return {INC => "$opts{INC} -I$dbi_arch_dir"};
} else {
return {INC => "-I$dbi_arch_dir"};
}
};
and this seems to be acceptable to cpan-testers. cpan-testers also
requested that build_requires and the new configure_requires is set in
the META.yml as new CPAN modules understand this e.g.,
build_requires:
DBI: 1.21
configure_requires:
DBI: 1.21
2. Ensure (if you are using ExtUtils::MakeMaker) that PREREQ_PM is set
to include DBI (and version).
e.g.,
PREREQ_PM => {"DBI" => 1.21 }
This ensures that if DBI is not installed then cpan-testers will not
flag this as an error.
3. If you are testing for an external library and that library is not
found then do not die, but issue an error message and exit 0 (success)
BEFORE creating the Makefile. The cpan-test code will spot the Makefile
is missing and that will stop an error being reported.
Hope this is useful to you. If I hear/learn more I will report back here.
Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com