Apache-Test
view release on metacpan or search on metacpan
lib/Apache/TestReport.pm view on Meta::CPAN
$template =~ s{\@(\w+)\@} {
my $method = lc $1;
eval { $self->$method() } || $self->{$1} || '';
}eg;
$template;
}
sub run {
my $self = shift;
print $self->replace($self->template);
}
sub config { Apache::TestConfig::as_string() }
sub report_to { 'test-dev@httpd.apache.org' }
sub postit_note {
my $self = shift;
my($to, $where) = split '@', $self->report_to;
return <<EOF;
Note: Complete the rest of the details and post this bug report to
$to <at> $where. To subscribe to the list send an empty
email to $to-subscribe\@$where.
EOF
}
sub executable { $0 }
my $core_dump;
sub core_dump {
my $self = shift;
$core_dump = "";
if (eval { require Devel::GDB }) {
find(\&dump_core_file, 't')
}
$core_dump || ' [CORE TRACE COMES HERE]';
}
sub dump_core_file {
return unless /^core(\.\d+)?$/;
my $core = $_;
my $gdb = new Devel::GDB ();
my $test_config = Apache::TestConfig->new({thaw=>1});
my $httpd = $test_config->{vars}->{httpd};
return unless defined $httpd;
$core_dump .= join '',
$gdb->get("file $httpd"),
$gdb->get('sharedlibrary'),
$gdb->get("core $core"),
$gdb->get('info threads'),
$gdb->get('thread apply all bt');
}
sub date { scalar gmtime() . " GMT" }
sub template {
<<'EOI'
-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:
[DESCRIBE THE PROBLEM HERE]
2. Used Components and their Configuration:
@CONFIG@
3. This is the core dump trace: (if you get a core dump):
@CORE_DUMP@
This report was generated by @EXECUTABLE@ on @DATE@.
-------------8<---------- End Bug Report --------------8<----------
@POSTIT_NOTE@
EOI
}
1;
__END__
=head1 NAME
Apache::TestReport - A parent class for generating bug/success reports
=head1 Synopsis
use Apache::TestReport;
Apache::TestReport->new(@ARGV)->run;
=head1 Description
This class is used to generate a bug or a success report, providing
information about the system the code was running on.
=head1 Overridable Methods
=head2 config
return the information about user's system
=head2 report_to
return a string containing the email address the report should be sent
to
=head2 postit_note
return a string to close the report with, e.g.:
( run in 0.509 second using v1.01-cache-2.11-cpan-df04353d9ac )