Author: dagolden
Date: Sun Jun 21 06:00:19 2009
New Revision: 12872
Modified:
Module-Build/trunk/Changes
Module-Build/trunk/lib/Module/Build/Base.pm
Module-Build/trunk/t/PL_files.t
Log:
Run PL files that don't generate any file (RT#39365)
Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes (original)
+++ Module-Build/trunk/Changes Sun Jun 21 06:00:19 2009
@@ -9,6 +9,7 @@
- Module::Build::Compat handling of INSTALL*LIB (RT#43827)
- Module::Build::Compat and recursive test files (RT#39171)
- Fixed bug linking non-standard XS names on Windows (RT#38065)
+ - Run PL files that don't generate any file (RT#39365)
Other
- On MSWin32, bumped File::Spec prereq to 3.30 for a variety of fixes
Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Sun Jun 21 06:00:19 2009
@@ -4527,7 +4527,8 @@
$source = [$source] unless ref $source;
$derived = [$derived] unless ref $derived;
- return 0 if grep {not -e} @$derived;
+ # empty $derived means $source should always run
+ return 0 if @$source && !@$derived || grep {not -e} @$derived;
my $most_recent_source = time / (24*60*60);
foreach my $file (@$source) {
Modified: Module-Build/trunk/t/PL_files.t
==============================================================================
--- Module-Build/trunk/t/PL_files.t (original)
+++ Module-Build/trunk/t/PL_files.t Sun Jun 21 06:00:19 2009
@@ -2,13 +2,13 @@
use strict;
use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
-use MBTest tests => 6;
+use MBTest tests => 8;
use DistGen;
use Module::Build;
-
-# Set up a distribution for testing
my $dist;
+
+# Test that PL files don't get installed even in bin or lib
{
$dist = DistGen->new( dir => MBTest->tmpdir );
$dist->regen;
@@ -34,11 +34,7 @@
END
$dist->regen;
-}
-
-# Test that PL files don't get installed even in bin or lib
-{
my $mb = Module::Build->new_from_context( install_base => "test_install" );
$mb->dispatch("install");
@@ -50,4 +46,41 @@
is slurp("test_install/bin/foo"), "foo\n", "Generated bin contains correct content";
is slurp("test_install/lib/perl5/Bar.pm"), "bar\n", " so does the lib";
+
+ $dist->chdir_original if $dist->did_chdir;
+}
+
+# Test an empty PL target list runs the PL but doesn't
+# add it to MANIFEST or cleanup
+{
+ $dist = DistGen->new( dir => MBTest->tmpdir );
+ $dist->regen;
+ $dist->chdir_in;
+
+ my $distname = $dist->name;
+ $dist->change_build_pl({
+ module_name => $distname,
+ PL_files => {
+ 'Special.PL' => [],
+ },
+ });
+
+ $dist->add_file("Special.PL", <<'END');
+open my $fh, ">", "foo" or die $!;
+print $fh "foo\n";
+END
+
+ $dist->regen;
+
+ my $mb = Module::Build->new_from_context();
+ $mb->dispatch("code");
+
+ ok( -f "foo", "special PL file ran" );
+
+ my $cleanup = $mb->cleanup;
+
+ my %cleanup = map { $_ => 1 } $mb->cleanup;
+ is($cleanup{foo}, undef, "generated special file not added to cleanup");
+
+
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.