Skip to content

Commit

Permalink
Munge both Makefile.PL and Build.PL if specified.
Browse files Browse the repository at this point in the history
dagolden#4

Thanks to @karenetheridge for the report.

----

I hereby disclaim any implicit or explicit ownership of my changes in this
changeset, and put them under a multiple licence consisting of your choice of
one of more of:

- The CC0 / Public Domain - https://creativecommons.org/choose/zero/ .

- The MIT / Expat license - https://en.wikipedia.org/wiki/MIT_License

- The default licence of your project

- The https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License - version
2.1 or higher

- The https://en.wikipedia.org/wiki/GNU_General_Public_License - version 2 or
higher

- Any licence in the 2018-Aug-27 popular licenses list of
https://opensource.org/licenses

- The https://en.wikipedia.org/wiki/Apache_License version 2.0 or later

- The https://en.wikipedia.org/wiki/Artistic_License version 2.0 or later

- The https://en.wikipedia.org/wiki/ISC_license

- The https://opensource.org/licenses/BSD-2-Clause

Crediting me will be nice, but not mandatory, and you can change the licence
of the project without needing my permission.
  • Loading branch information
shlomif committed Mar 7, 2020
1 parent a3f719e commit 703da65
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
15 changes: 15 additions & 0 deletions corpus/DZ6/dist.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name = DZ3
version = 0.001
author = E. Xavier Ample <[email protected]>
license = Perl_5
copyright_holder = E. Xavier Ample

[@Filter]
bundle = @FakeClassic
remove = ConfirmRelease
remove = FakeRelease

[ModuleBuild]
[OSPrereqs / MSWin32]
Win32API::File = 0.11

10 changes: 10 additions & 0 deletions corpus/DZ6/lib/DZ3.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use strict;
use warnings;
package DZ1;
# ABSTRACT: this is a sample package for testing Dist::Zilla;

sub main {
return 1;
}

1;
2 changes: 1 addition & 1 deletion lib/Dist/Zilla/Plugin/OSPrereqs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ sub munge_files {
$content =~ s/(?=$reg)/$prereq_str/
or $self->log_fatal("Failed to insert conditional prereq for $os");

return $build_script->content($content);
$build_script->content($content);
}

return 1;
Expand Down
36 changes: 36 additions & 0 deletions t/osprereqs_mb_and_eumm.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use strict;
use warnings;

use lib 't/lib';

use Test::More 0.88;

use Test::DZil;

my $tzil = Builder->from_config( { dist_root => 'corpus/DZ6' }, );

$tzil->build;

my $contents = $tzil->slurp_file('build/Build.PL');

my $conditional = q|if ( $^O eq 'MSWin32' ) {|;
my $prereq = q|$module_build_args{requires}{'Win32API::File'} = '0.11'|;

like(
$contents,
qr/\Q$conditional\E.*?\Q$prereq\E.*?^\}/ms,
"saw MSWin32 conditional in Build.PL"
);

my $meta = $tzil->slurp_file('build/META.yml');
like( $meta, qr/dynamic_config: +1/, "dynamic_config is true in META.yml" );

$contents = $tzil->slurp_file('build/Makefile.PL');
like(
$contents,
qr/\Q$conditional\E/ms,
"saw MSWin32 conditional in Makefile.PL too"
);

done_testing;

0 comments on commit 703da65

Please sign in to comment.