perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: cvs commit: modperl-2.0/lib/ModPerl
Date Sat, 08 Nov 2003 21:41:16 GMT
Geoffrey Young wrote:
>> the attached patch makes it possible to use -bugreport with the 
>> Apache::TestRun(Perl)->generate_script() form

You do: eval { $report->() } but don't check for $@. Better just drop eval {} 
and let it fail.

> sorry, I meant to include examples.  with this patch, you can use the 
> following formats in your Makefile.PL
> # scalars are printed in the post-error banner
> Apache::TestRun(Perl)->generate_script(bugreport => 'some message');
> # subroutines are eval'd when t/TEST is generated, so config-time
> # variables such as Apache::TestConfig::IS_MOD_PERL_2 can be used
> Apache::TestRun(Perl)->generate_script(bugreport => sub { 'some message' 
> });
> # continues to work as before (if anyone actually uses it)
> Apache::TestRun->generate_script('t/TEST');


Though I'm not sure about the CODEREF part. bugreport is a just a function to 
run if 'make test' fails. Though you hardcoded it to be a function to print 
something. Since eval of that CODEREF happens during generate_script() you 
could just do it and pass that return value to bugreport. i.e. it provides no 
added value.

The only useful way I can see we can benefit from passing a code ref is this:

sub gen_bugreport {
     print 'EOI';
require Foo;


Apache::TestRun(Perl)->generate_script(bugreport => \&gen_bugreport);

and in generate_script:

    if (my $report = $opts{bugreport}) {
         my $sub;
         if (UNIVERSAL::isa($report, 'CODE')) {
             my $code = $report->();
             $sub = "sub bug_report {\n    $code\n}\n";
         else {
             $sub = "sub bug_report {\n    print '$report'\n}\n";
         $body .= "\n\npackage $class;\n" . "$sub\n\n";

i.e. where we pass a CODEREF which when run returns an uncompiled body of the 
bug_report, which is then written to t/TEST.

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message