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 [EMAIL PROTECTED] 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');
Cool.
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;
Foo->Bar;
EOI}
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 http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
