Thanks again.  MakeMaker::Awesome is the right tool.  I released a
version with the changes, which seems to do what I expect.  At least, no
bogus FAILs after several days and a couple of hundred test reports.

To close this out:

I did catch the requirement for [|Prereqs / ConfigureRequires] for the
modules I use.

Would be nice to have a macro or defaulting scheme so I only have to
update the
version in one place.  (Now same in ConfigureRequires + RuntimeRequires).
|
I used the "header_file =" directive, as it makes the code cleaner,
testable by itself - and emacs can do syntax highlighting.

After that, we're into folklore which I thought I should document.

Here's what I've found from cpan-testers-discuss and digging into some
other modules and CPAN::Reporter.

Some modules die, others exit(0);

CPAN::Reporter uses a lot of heuristics to grade tests.

Output from Makefile.PL is scanned for various key phrases that modify
the test result.
The more interesting ones are listed below (by priority, high to low).

exit(0) from Makefile.PL is ambigous; pass unless modified.
exit( !0 ) from Makefile.PL is ambiguous; unknown unless modified.

If the exit value indicates a signal, the result is 'discard'
If the output includes "No support for OS" or "OS unspported" (/i), the
result is 'na'
If a prereq isn't met, the result is 'na'
If neither a Makefile nor a Build exists, the result is 'discard'

'discard' - no report will be sent, test is invalid
'na' - not expected to work on platform/perl version
'unknown' - couldn't run Makefile.PL and make or has no tests
'pass' - continue to make
'fail' - report failure

So if a build is (re)tried in a directory that has a (leftover?)
Makefile/Build, but my test fails,
the make will proceed and the test will count.  So on failure I unlink
these to be sure that
they don't interfere.

|Sigh.  Documentation by folklore is fun. 

I appreciate all the help.



|On 11-Oct-16 17:38, Karen Etheridge wrote:
> Ok, so since you're not actually adding prereqs here, but merely
> checking if resources (OpenSSL) are available and bailing out
> otherwise, you don't want DynamicPrereqs -- that's why it always sets
> dynamic_config => 1.
> You can use [MakeMaker::Awesome] to do the check (hopefully this does
> not render badly -- apologies if it is html-only):
>
> [MakeMaker::Awesome]
> :version = 0.26
> delimiter = |
> header = |my $ok = eval {
> header = |    require Crypt::OpenSSL::DSA;
> header = |    my $key = Crypt::OpenSSL::DSA->read_pub_key_str(
> <<'_long_mess_' ) or die "Can't read public key";
> header = |     ...
> header = |_long_mess_
> header = |    $ok = $key->verify( pack('H*', "Another long mess"),
> pack('H*', "Still more mess") ) or
> header = |         die "Can't verify";
> header = |};
> header = |if ($@ || !$ok) {
> header = |    warn "You probably need to upgrade OpenSSL\n";
> header = |    warn " - $@ \n" if $@;
> header = |    warn 'Insufficient environment -- will not install';
> header = |    exit 0;
> header = |}
> Note that since Crypt::OpenSSL::DSA is required in the Makefile.PL, it
> should be declared as a Configure-phase prerequisite (i.e. [Prereqs /
> ConfigureRequires] \n Crypt::OpenSSL::DSA = someversion).
>
>
> On Tue, Oct 11, 2016 at 1:05 PM, tlhackque <tlhack...@yahoo.com
> <mailto:tlhack...@yahoo.com>> wrote:
>
>     On 11-Oct-16 14:09, Karen Etheridge wrote:
>>     If I'm understanding correctly, you need to declare a prereq on
>>     an external library -- check out [CheckLib] for that, which
>>     inserts code into your Makefile.PL that calls Devel::CheckLib.
>>
>>     For OS-specific prereqs, you can use [OSPrereqs]; if you need to
>>     do something fancy or with custom code, [DynamicPrereqs] can make
>>     that easy.
>>
>>     And if none of these provide the level of nuance that you need,
>>     you can fall back to [MakeMaker::Awesome], which lets you
>>     customize Makefile.PL in even more custom ways.
>>
>>
>>     good luck! feel free to follow up with more questions, or hit me
>>     up on irc.perl.org <http://irc.perl.org> #distzilla.
>>
>     Karen,
>
>     Thanks - helpful as usual!  I think I'm almost there.  Still some
>     questions.
>
>     FYI: Small divot (things build OK after the usual dozen
>     dependencies...):
>>     cpan install Dist::Zilla::Plugin::{DynamicPrereqs,CheckLib,OSPrereqs}
>>     ...
>>     CPAN: Module::CoreList loaded ok (v2.54)
>>     Configuring
>>     E/ET/ETHER/Dist-Zilla-Plugin-DynamicPrereqs-0.032.tar.gz with
>>     Makefile.PL
>>     Dist::Zilla already exists in PREREQ_PM -- need to do a sane
>>     metamerge! at Makefile.PL line 140.
>>     Dist::Zilla already exists in FallbackPrereqs -- need to do a
>>     sane metamerge! at Makefile.PL line 144.
>>     Checking if your kit is complete...
>
>     After following your pointers, it sounds as though
>     [DynamicPrereqs] is closest to what I need.
>
>     Unfortunately, I can't use CheckLib due to the bizarre packaging
>     of OpenSSL.  Plus, the OpenSSL dependency belongs to the modules I
>     depend on/call; I can't become their nanny.
>
>     I need do something on the order of
>     |   my $ok = eval {||
>     ||    ||require Crypt::OpenSSL::DSA;||
>     ||    my $key = Crypt::OpenSSL::DSA->read_pub_key_str(
>     <<'_long_mess_' ) or die "Can't read public key";
>          ...
>     _long_mess_  
>     ||||    $ok = $key->verify( pack('H*', "Another long mess"),
>     pack('H*', "Still more mess") ) or
>              die "Can't verify";||
>     ||   };||
>        if( $@ || !$ok ) {
>          printf STDERR "You probably need to upgrade OpenSSL\n";
>          printf STDERR " - $@" if( $@ );
>     ||     <tell CPAN_Testing "Insufficient Environment & rate 'NA'">
>     # << What goes here?
>         }||
>     |
>     I gather I can put this in a file, then in dist.ini:
>     |[Prereqs / ConfigureRequires]
>      Crypt::OpenSSL::RSA = 0
>      |||Crypt::OpenSSL::DSA = 0
>      |CryptX = 0.44
>     [DynamicPrereqs]||
>     ||-raw_from_file = myfile.pl <http://myfile.pl>||
>     |
>     Perhaps these are obvious, but I'm neither a MakeMaker nor a
>     CPANTS person, and testing by releasing to cpan is expensive (and
>     slightly embarrassing):
>
>       * What's the proper magic at "# << "?
>           o  die?
>           o exit non-zero?
>           o Unlink Makefile and exit 0? (Is this portable?)
>           o Call some function that's provided in the Makefile?
>       * You set 'dynamic_config', which implies that installers don't
>         know enough to load my dependencies.
>         In this case, actually they do.  I'm not adding a prereq, just
>         applying a more stringent test to the environment.
>
>         So can/should I delete $WriteMakefileArgs{dynamic_config} &
>         delete $FallbackPrereqs{dynamic_config}?
>         Or should there be a "not_really_dynamic = 1" for your plugin :-)
>
>     I appreciate your patience...
>
>
>     On Tue, Oct 11, 2016 at 10:57 AM, tlhackque via Dist::Zilla
>     <distzilla+re...@lists.codesimply.com
>     <mailto:distzilla+re...@lists.codesimply.com>> wrote:
>>
>>         I have encountered a situation where my module depends on another
>>         module, which depends on a system library (OpenSSL) being at a
>>         reasonably current version.
>>
>>         Failure to be at a reasonably current version still allows my
>>         dependency
>>         to install/be satisfied.  But my tests (correctly) fail. 
>>         This gets
>>         counted against me on CPAN's automated testers, which I don't
>>         like :-(
>>
>>         I'd be OK if CPAN testers rated those out-of-date systems
>>         "NA" rather
>>         than fail.
>>
>>         The advice I've gotten is to come up with a test and abort
>>         the Makefile.PL
>>
>>         But I don't write the Makefile.PL; Dist::Zilla does.
>>
>>         I can write a test as a stand-alone script, or simply a Perl
>>         function.
>>           For the sake of an example:
>>              sub someComplexFunction { return int(rand(4)) == 2; }
>>             $^O ne 'MacOS' && someComplexFunction() or ( printf STDERR
>>         ("Environment requires..."), return/exit/die... );
>>
>>         My question:  How do I get Dist::Zilla to introduce code to
>>         run my test,
>>         and how should it exit to tell CPANTS to rate NA?
>>
>>         I presume I need to include the test's dependencies with
>>         something like:
>>
>>         [Prereqs / ConfigureRequires]
>>          Crypt::OpenSSL::RSA = 0
>>          CryptX = 0.44
>>
>>         But how do I package the code?  In the simplest way?
>>
>>         My dist.ini's relevant sections are:
>>         [MetaConfig]
>>         [MetaProvides::Package]
>>         [MinimumPerl]
>>         perl = 5.008008
>>         [MetaYAML]
>>         [MetaJSON]
>>         [MakeMaker]
>>         static_attribution = 1
>>         [AutoPrereqs]
>>         [Prereqs]
>>          ...
>>         [Prereqs / DevelopRequires]
>>         Sort::Versions = 1.62
>>         Pod::Readme = 1.1.2
>>         [Test::ReportPrereqs]
>>
>>         Many thanks!
>>
>



-------------------------------------------
Dist::Zilla
Archives: https://www.listbox.com/member/archive/139292/=now
RSS Feed: https://www.listbox.com/member/archive/rss/139292/21080831-4b8afa6a
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=21080831&id_secret=21080831-2b0ee212
Powered by Listbox: http://www.listbox.com

Reply via email to