Skip Menu |

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 58990
Status: resolved
Priority: 0/
Queue: Module-Build

People
Owner: Nobody in particular
Requestors: APOCAL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Module::Build::Compat more informative error message about dotted-decimal prereqs
Hello, I've been using M::B::Compat for a while and saw this happen from time to time: Prereq '0.1.2' for 'File::Find::Object' is not supported by Module::Build::Compat I meant to patch it so the message is more helpful for us authors who get perplexed at first. Then, after some digging around the guts of M::B, I realized it could auto-convert the "common" dotted-decimal case to the proper format. 0.1.2 -> 0.001002 Here's the patch that adds the auto-conversion logic and some tests for it. However, I'm not entirely sure the conversion logic is ok, and one of my test blocks FAILs. ( patch applied against SVN r14210 ) I'm hoping this is a good building block for you to use and tweak until it's working :) P.S. Thanks goes to rindolf ( Shlomi Fish ), who reminded me of this issue and made me submit this :) -- ~Apocalypse
Subject: mb.patch
Index: t/compat.t =================================================================== --- t/compat.t (revision 14210) +++ t/compat.t (working copy) @@ -313,8 +313,61 @@ ok( ! exists $args->{TESTS}, 'Not using incorrect recursive tests key' ); } + 1 while unlink 'Makefile.PL'; + ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; } +{ + # make sure using prereq with '0.1.2' complains + $dist->change_build_pl({ + module_name => $distname, + license => 'perl', + requires => { + 'Foo::Frobnicate' => '0.1.2', + }, + }); + $dist->regen; + + my $mb; + stdout_stderr_of( sub { + $mb = Module::Build->new_from_context; + }); + + my $output = stdout_stderr_of( sub { Module::Build::Compat->create_makefile_pl( 'traditional', $mb ) } ); + ok -e 'Makefile.PL', "Makefile.PL created"; + like $output, qr/is not supported/, "Correctly complains and converts dotted-decimal"; + + my $file_contents = slurp 'Makefile.PL'; + like $file_contents, qr/Foo::Frobnicate.+0\.001002/, "Properly converted dotted-decimal"; + + 1 while unlink 'Makefile.PL'; + ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; +} + +{ + # make sure using invalid prereq blows up + $dist->change_build_pl({ + module_name => $distname, + license => 'perl', + requires => { + 'Foo::Frobnicate' => '3.5.2.7-TRIAL', + }, + }); + $dist->regen; + + my $mb; + stdout_stderr_of( sub { + $mb = Module::Build->new_from_context; + }); + + my $output = stdout_stderr_of( sub { Module::Build::Compat->create_makefile_pl( 'traditional', $mb ) } ); + ok ! -e 'Makefile.PL', "Makefile.PL NOT created"; + like $output, qr/is not supported/, "Correctly dies when it encounters invalid prereq"; + + 1 while unlink 'Makefile.PL'; + ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; +} + ######################################################### sub _merge_prereqs { Index: lib/Module/Build/Compat.pm =================================================================== --- lib/Module/Build/Compat.pm (revision 14210) +++ lib/Module/Build/Compat.pm (working copy) @@ -78,8 +78,20 @@ for my $p ( $req, $breq ) { for my $k (keys %$p) { next if $k eq 'perl'; - die "Prereq '$p->{$k}' for '$k' is not supported by Module::Build::Compat\n" - unless _simple_prereq($p->{$k}); + + if ( ! _simple_prereq( $p->{$k} ) ) { + # It seems like a lot of people trip over "0.1.2" stuff, so we help them here... + if ( $p->{$k} =~ /^[0-9_]+\.[0-9_]+\.[0-9_]+$/ ) { + my $proper_ver = eval { Module::Build::Version->new($p->{$k})->numify }; + if ( ! $@ ) { + warn "Using '$p->{$k}' for '$k' is not supported by Module::Build::Compat - converting it to '$proper_ver'\n"; + $p->{$k} = $proper_ver; + next; + } + } + + die "Prereq '$p->{$k}' for '$k' is not supported by Module::Build::Compat ( use a simpler version like '0.05' or '1.4.25' )\n"; + } } } # merge
Thanks. Applied to the repo.
Now that there has been a stable Module::Build release, I'm marking this "patched" issue as "resolved".