From 703da65d7b14ef4140407a234005bdcca3eb9846 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Sat, 7 Mar 2020 10:36:39 +0200 Subject: [PATCH] Munge both Makefile.PL and Build.PL if specified. https://github.com/dagolden/Dist-Zilla-Plugin-OSPrereqs/issues/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. --- corpus/DZ6/dist.ini | 15 +++++++++++++ corpus/DZ6/lib/DZ3.pm | 10 +++++++++ lib/Dist/Zilla/Plugin/OSPrereqs.pm | 2 +- t/osprereqs_mb_and_eumm.t | 36 ++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 corpus/DZ6/dist.ini create mode 100644 corpus/DZ6/lib/DZ3.pm create mode 100644 t/osprereqs_mb_and_eumm.t diff --git a/corpus/DZ6/dist.ini b/corpus/DZ6/dist.ini new file mode 100644 index 0000000..ac6655a --- /dev/null +++ b/corpus/DZ6/dist.ini @@ -0,0 +1,15 @@ +name = DZ3 +version = 0.001 +author = E. Xavier Ample +license = Perl_5 +copyright_holder = E. Xavier Ample + +[@Filter] +bundle = @FakeClassic +remove = ConfirmRelease +remove = FakeRelease + +[ModuleBuild] +[OSPrereqs / MSWin32] +Win32API::File = 0.11 + diff --git a/corpus/DZ6/lib/DZ3.pm b/corpus/DZ6/lib/DZ3.pm new file mode 100644 index 0000000..48f1f84 --- /dev/null +++ b/corpus/DZ6/lib/DZ3.pm @@ -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; diff --git a/lib/Dist/Zilla/Plugin/OSPrereqs.pm b/lib/Dist/Zilla/Plugin/OSPrereqs.pm index 73dc40f..3d29115 100644 --- a/lib/Dist/Zilla/Plugin/OSPrereqs.pm +++ b/lib/Dist/Zilla/Plugin/OSPrereqs.pm @@ -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; diff --git a/t/osprereqs_mb_and_eumm.t b/t/osprereqs_mb_and_eumm.t new file mode 100644 index 0000000..02b82ba --- /dev/null +++ b/t/osprereqs_mb_and_eumm.t @@ -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; +