Subject: | Possible side-effects if Test::NoWarnings is a PREREQ_PM in other Makefile.PL's |
If a distribution's Makefile.PL contains Test::NoWarnings in the
PREREQ_PM section, and if Test::NoWarnings is already installed, then
any other modules specified in PREREQ_PM which are lexically sorted
later do not appear when running Makefile.PL.
This can be easily be reproduced with the attached Makefile.PL.
Test::NoWarnings has to be installed yet. The output is:
Warning: prerequisite AAA::Module::Not::Installed 0 not found.
Writing Makefile for test
But the expected output is:
Warning: prerequisite AAA::Module::Not::Installed 0 not found.
Warning: prerequisite ZZZ::Module::Not::Installed 0 not found.
Writing Makefile for test
The problem is that Test::NoWarnings redefines $SIG{__WARN__} outside
all subroutines, so the definition is already executed if a module does
a "require Test::NoWarnings". This is roughly what ExtUtils::MakeMaker
is doing to determine if a module is available, and if the module's
version matches. Because of the redefined warn(), every subsequent
checked non-available module will remain invisible.
I attached a possible patch.
Regards,
Slaven
Subject: | Test-NoWarnings-0.84-SREZIC-01.patch |
diff --git a/lib/Test/NoWarnings.pm b/lib/Test/NoWarnings.pm
index f3eca9b..e879d59 100644
--- a/lib/Test/NoWarnings.pm
+++ b/lib/Test/NoWarnings.pm
@@ -27,14 +27,14 @@ require Exporter;
my @warnings;
-$SIG{__WARN__} = make_catcher(\@warnings);
-
$do_end_test = 0;
sub import
{
$do_end_test = 1;
+ $SIG{__WARN__} = make_catcher(\@warnings);
+
goto &Exporter::import;
}
Subject: | Makefile.PL |
use ExtUtils::MakeMaker;
WriteMakefile(NAME => "test",
PREREQ_PM => { 'AAA::Module::Not::Installed' => 0,
'Test::NoWarnings' => 0,
'ZZZ::Module::Not::Installed' => 0,
},
);