dougm 02/05/14 20:12:54
Modified: perl-framework/Apache-Test/lib/Apache TestReport.pm
TestReportPerl.pm
Log:
make TestReport easier to extend/understand
Revision Changes Path
1.6 +30 -27
httpd-test/perl-framework/Apache-Test/lib/Apache/TestReport.pm
Index: TestReport.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestReport.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestReport.pm 15 May 2002 02:50:37 -0000 1.5
+++ TestReport.pm 15 May 2002 03:12:54 -0000 1.6
@@ -8,6 +8,11 @@
use File::Spec::Functions qw(catfile);
+sub new {
+ my $class = shift;
+ bless { @_ }, $class;
+}
+
# generate t/REPORT script (or a different filename) which will drive
# Apache::TestReport
sub generate_script {
@@ -15,23 +20,32 @@
$file ||= catfile 't', 'REPORT';
- local $/;
- my $content = <DATA>;
+ my $header = Apache::TestConfig->perlscript_header;
- my %replace = (
- class => $class,
- header => Apache::TestConfig->perlscript_header,
- );
-
- while (my($key, $val) = each %replace) {
- $content =~ s/__\U${key}__/$replace{$key}/g;
- }
+ my $content = join "\n",
+ $header, "use $class;", "$class->new([EMAIL PROTECTED])->run;";
Apache::Test::config()->write_perlscript($file, $content);
+}
+
+sub replace {
+ my($self, $template) = @_;
+
+ $template =~ s{\@(\w+)[EMAIL PROTECTED] {
+ my $method = lc $1;
+ eval { $self->$method() } || $self->{$1} || '';
+ }eg;
+
+ $template;
+}
+sub run {
+ my $self = shift;
+
+ print $self->replace($self->template);
}
-sub build_config_as_string { Apache::TestConfig::as_string() }
+sub config { Apache::TestConfig::as_string() }
sub report_to { '[EMAIL PROTECTED]' }
@@ -47,28 +61,17 @@
EOF
}
-1;
-__DATA__
+sub executable { $0 }
-__HEADER__
+sub date { scalar gmtime() . " GMT" }
-use __CLASS__ ();
-
-my %map = (
- CONFIG => __CLASS__->build_config_as_string,
- EXECUTABLE => $0,
- DATE => scalar gmtime() . " GMT",
- POSTIT_NOTE => __CLASS__->postit_note,
-);
-{
+sub template {
local $/ = undef;
- my $template = <DATA>;
- $template =~ s/\@(\w+)\@/$map{$1}||''/eg;
- print $template;
+ <DATA>;
}
+1;
__DATA__
-
-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:
1.5 +2 -2
httpd-test/perl-framework/Apache-Test/lib/Apache/TestReportPerl.pm
Index: TestReportPerl.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestReportPerl.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestReportPerl.pm 15 May 2002 02:50:37 -0000 1.4
+++ TestReportPerl.pm 15 May 2002 03:12:54 -0000 1.5
@@ -10,11 +10,11 @@
use vars qw(@ISA);
@ISA = qw(Apache::TestReport);
-sub build_config_as_string {
+sub config {
ModPerl::Config::as_string();
}
-sub report_to { '[EMAIL PROTECTED]' }
+sub report_to { '[email protected]' }
1;
__END__