On Wed, 12 Dec 2001, Doug MacEachern wrote:

> On Tue, 11 Dec 2001, Stas Bekman wrote:
>
> nice.  but again, build/bugreport.pl would have to be copied for every
> project that uses Apache-Test.  would be better if there was an
> Apache::TestReport module and tiny generated t/REPORT script.
>
> i'm also thinking we should have:
>
> Apache::TestRun->generate_script that can be called from Makefile.PL
> that generates t/TEST rather than require each project to have a TEST.PL
> same for:
>
> Apache::TestRunPerl
> Apache::TestSmoke
> Apache::TestSmokePerl
> Apache::TestReport

This patch removes the need for t/TEST.PL, t/SMOKE.PL, build/bugreport.pl
and implements in each set of the classes used by these scripts a
generate_script() method, which generates these scripts.

Issues:
- should it generate t/REPORT or just as before build/bug_report.pl?
- If you look at ModPerl-Registry/t/TEST.PL, it cannot reuse
autogeneration, since it adds some more stuff
- If you try to generate t/SMOKE for ModPerl-Registry it'll need a
different 'use lib' adjustments.

So it's not than much re-usable after all. Are you sure that we really
want this to be done in the way this patch does and not just to stick with
.PL scripts? I really prefer a the .PL scripts because of their easy
customizability.

Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.55
diff -u -r1.55 Makefile.PL
--- Makefile.PL 2001/12/10 06:29:27     1.55
+++ Makefile.PL 2001/12/21 13:39:18
@@ -34,7 +34,12 @@
 my @remote_makefile_dirs = Apache::Build::is_win32() ? () :
                            qw(docs/src/api/mod_perl-2.0);

-my @scripts = qw(t/TEST t/SMOKE);
+my %scripts = (
+    't/REPORT' => 'Apache/TestReportPerl.pm',
+    't/SMOKE'  => 'Apache/TestSmokePerl.pm',
+    't/TEST'   => 'Apache/TestRunPerl.pm',
+);
+
 configure();

 ModPerl::MM::WriteMakefile(
@@ -103,8 +108,11 @@
     #ModPerl::MM will use Apache::BuildConfig in subdir/Makefile.PL's
     $build->save;

-    for (@scripts) {
-        Apache::TestMM::generate_script($_);
+    while (my($script, $package) = each %scripts ) {
+        require $package;
+        $package =~ s|/|::|g;
+        $package =~ s|\.pm$||;
+        $package->generate_script($script);
     }

     my $tables_dir = tables_dir($httpd_version);
@@ -167,7 +175,7 @@
 sub clean_files {
     my $path = $code->path;

-    return [EMAIL PROTECTED] $build->clean_files }, @scripts,
+    return [EMAIL PROTECTED] $build->clean_files },
             <xs/*.exp>, <xs/*.def>,
       map { "$path/$_"} @{ $code->clean_files }];
 }
Index: Apache-Test/lib/Apache/TestRun.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.75
diff -u -r1.75 TestRun.pm
--- Apache-Test/lib/Apache/TestRun.pm   2001/12/14 18:12:25     1.75
+++ Apache-Test/lib/Apache/TestRun.pm   2001/12/21 13:39:19
@@ -3,6 +3,7 @@
 use strict;
 use warnings FATAL => 'all';

+use Apache::Test ();
 use Apache::TestConfig ();
 use Apache::TestConfigC ();
 use Apache::TestRequest ();
@@ -720,5 +721,29 @@
     Apache::TestConfig->usage;
     1;
 }
+
+# generate t/TEST script (or a different filename) which will drive
+# Apache::TestRun
+sub generate_script {
+    my ($class, $file) = @_;
+
+    $file = 't/TEST' unless defined $file;
+
+    my $content = <<'EOM';
+use strict;
+use warnings FATAL => 'all';
+
+use FindBin;
+use lib "$FindBin::Bin/../Apache-Test/lib";
+
+use Apache::TestRun ();
+
+Apache::TestRun->new->run(@ARGV);
+EOM
+
+    Apache::Test::config()->write_perlscript($file, $content);
+
+}
+

 1;
Index: Apache-Test/lib/Apache/TestRunPerl.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRunPerl.pm,v
retrieving revision 1.3
diff -u -r1.3 TestRunPerl.pm
--- Apache-Test/lib/Apache/TestRunPerl.pm       2001/10/16 20:30:57     1.3
+++ Apache-Test/lib/Apache/TestRunPerl.pm       2001/12/21 13:39:19
@@ -37,4 +37,28 @@
     $self->configure_modperl;
 }

+# generate t/TEST script (or a different filename) which will drive
+# Apache::TestRunPerl
+sub generate_script {
+    my ($class, $file) = @_;
+
+    $file = 't/TEST' unless defined $file;
+
+    my $content = <<'EOM';
+use strict;
+use warnings FATAL => 'all';
+
+use FindBin;
+use lib "$FindBin::Bin/../Apache-Test/lib";
+
+use Apache::TestRunPerl ();
+
+Apache::TestRunPerl->new->run(@ARGV);
+EOM
+
+    Apache::Test::config()->write_perlscript($file, $content);
+
+}
+
+
 1;
Index: Apache-Test/lib/Apache/TestSmoke.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm,v
retrieving revision 1.4
diff -u -r1.4 TestSmoke.pm
--- Apache-Test/lib/Apache/TestSmoke.pm 2001/12/11 05:14:46     1.4
+++ Apache-Test/lib/Apache/TestSmoke.pm 2001/12/21 13:39:19
@@ -4,6 +4,7 @@
 use warnings FATAL => 'all';

 use Apache::TestTrace;
+use Apache::Test ();

 use Getopt::Long qw(GetOptions);
 use Digest::MD5 ();
@@ -410,6 +411,32 @@
     if 'tests' argument isn't provided all available tests will be run
 EOM
 }
+
+# generate t/SMOKE script (or a different filename) which will drive
+# Apache::TestSmoke
+sub generate_script {
+    my ($class, $file) = @_;
+
+    $file = 't/SMOKE' unless defined $file;
+
+    my $content = <<'EOM';
+use strict;
+use warnings FATAL => 'all';
+
+use FindBin;
+use lib "$FindBin::Bin/../Apache-Test/lib";
+use lib "$FindBin::Bin/../lib";
+
+use Apache::TestSmoke ();
+
+Apache::TestSmoke->new(@ARGV)->run;
+EOM
+
+    Apache::Test::config()->write_perlscript($file, $content);
+
+}
+
+

 1;
 __END__
Index: Apache-Test/lib/Apache/TestSmokePerl.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmokePerl.pm,v
retrieving revision 1.1
diff -u -r1.1 TestSmokePerl.pm
--- Apache-Test/lib/Apache/TestSmokePerl.pm     2001/12/11 05:12:28     1.1
+++ Apache-Test/lib/Apache/TestSmokePerl.pm     2001/12/21 13:39:19
@@ -3,12 +3,37 @@
 use strict;
 use warnings FATAL => 'all';

+use Apache::Test ();
 use Apache::TestSmoke ();
 use ModPerl::Config ();

 # a subclass of Apache::TestSmoke that configures mod_perlish things
 use vars qw(@ISA);
 @ISA = qw(Apache::TestSmoke);
+
+# generate t/SMOKE script (or a different filename) which will drive
+# Apache::TestSmokePerl
+sub generate_script {
+    my ($class, $file) = @_;
+
+    $file = 't/SMOKE' unless defined $file;
+
+    my $content = <<'EOM';
+use strict;
+use warnings FATAL => 'all';
+
+use FindBin;
+use lib "$FindBin::Bin/../Apache-Test/lib";
+use lib "$FindBin::Bin/../lib";
+
+use Apache::TestSmokePerl ();
+
+Apache::TestSmokePerl->new(@ARGV)->run;
+EOM
+
+    Apache::Test::config()->write_perlscript($file, $content);
+
+}

 sub build_config_as_string {
     my($self) = @_;

--- /dev/null   Thu Jan  1 07:30:00 1970
+++ Apache-Test/lib/Apache/TestReportPerl.pm    Fri Dec 21 21:36:59 2001
@@ -0,0 +1,61 @@
+package Apache::TestReportPerl;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test ();
+use Apache::TestReport ();
+
+# a subclass of Apache::TestReport that generates a bug report script
+use vars qw(@ISA);
[EMAIL PROTECTED] = qw(Apache::TestReport);
+
+# generate t/REPORT script (or a different filename) which will drive
+# Apache::TestReportPerl
+sub generate_script {
+    my ($class, $file) = @_;
+
+    $file = 't/REPORT' unless defined $file;
+
+    local $/;
+    my $content = <DATA>;
+    Apache::Test::config()->write_perlscript($file, $content);
+
+}
+
+1;
+__DATA__
+use strict;
+use FindBin qw($Bin);
+use lib "$Bin/../lib";
+
+use ModPerl::Config ();
+
+my $env = ModPerl::Config::as_string();
+{
+    local $/ = undef;
+    my $template = <DATA>;
+    $template =~ s/\[CONFIG\]/$env/;
+    print $template;
+}
+
+__DATA__
+
+-------------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 TRACE COMES HERE]
+
+-------------8<----------End Bug Report --------------8<----------
+
+Note: Complete the rest of the details and post this bug report to dev
+<at> perl.apache.org. To subscribe to the list send an empty email to
[EMAIL PROTECTED]

--- /dev/null   Thu Jan  1 07:30:00 1970
+++ Apache-Test/lib/Apache/TestReport.pm        Fri Dec 21 21:37:09 2001
@@ -0,0 +1,58 @@
+package Apache::TestReport;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test ();
+
+# generate t/REPORT script (or a different filename) which will drive
+# Apache::TestReport
+sub generate_script {
+    my ($class, $file) = @_;
+
+    $file = 't/REPORT' unless defined $file;
+
+    local $/;
+    my $content = <DATA>;
+    Apache::Test::config()->write_perlscript($file, $content);
+
+}
+
+1;
+__DATA__
+
+use strict;
+use FindBin qw($Bin);
+use lib "$Bin/../Apache-Test/lib";
+
+use Apache::TestConfig ();
+
+my $env = Apache::TestConfig::as_string();
+{
+    local $/ = undef;
+    my $template = <DATA>;
+    $template =~ s/\[CONFIG\]/$env/;
+    print $template;
+}
+
+__DATA__
+
+
+-------------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 TRACE COMES HERE]
+
+-------------8<----------End Bug Report --------------8<----------
+
+Note: Complete the rest of the details and post this bug report to
+test-dev <at> httpd.apache.org. To subscribe to the list send an empty
+email to [EMAIL PROTECTED]

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/

Reply via email to