Stas Bekman wrote:
You probably have noticed that almost every time there is a bug report from a person who is doing this for the first time, we need to tell them: go to
http://perl.apache.org/bugs and follow the guidelines for a proper bug-report. I was thinking how can we save this wasteful cycle. For example we could adjust the failure message of 'make test' (in both mp1 and mp2) to provide that information.

Here it is. Now each project using Apache::Test can easily supply its own function to be executed on 't/TEST' failure. In the case of mod_perl we just print:


+--------------------------------------------------------+
| Please file a bug report: http://perl.apache.org/bugs/ |
+--------------------------------------------------------+

You need to nuke t/TEST

--- /dev/null   1969-12-31 16:00:00.000000000 -0800
+++ t/TEST.PL   2003-11-04 17:15:34.000000000 -0800
@@ -0,0 +1,25 @@
+use strict;
+use warnings FATAL => 'all';
+
+use FindBin;
+# test against the source lib for easier dev
+use lib "$FindBin::Bin/../lib";
+use lib "$FindBin::Bin/../Apache-Test/lib";
+
+MyTest->new->run(@ARGV);
+
+
+
+# sub-class Apache::TestRunPerl
+package MyTest;
+
+use base qw(Apache::TestRunPerl);
+
+sub bug_report {
+        print <<EOI;
++--------------------------------------------------------+
+| Please file a bug report: http://perl.apache.org/bugs/ |
++--------------------------------------------------------+
+EOI
+}
+
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.127
diff -u -r1.127 Makefile.PL
--- Makefile.PL 4 Nov 2003 20:27:22 -0000       1.127
+++ Makefile.PL 5 Nov 2003 01:23:31 -0000
@@ -32,6 +32,7 @@
 use Apache::Build ();
 use Apache::TestReportPerl ();
 use Apache::TestSmokePerl ();
+use Apache::TestMM;
 use Apache::TestTrace;
 use ModPerl::TestRun ();
 use ModPerl::Code ();
@@ -206,7 +207,7 @@
     #ModPerl::BuildMM will use Apache::BuildConfig in subdir/Makefile.PL's
     $build->save;

-    ModPerl::TestRun->generate_script;
+    Apache::TestMM::generate_script('t/TEST');
     Apache::TestSmokePerl->generate_script;
     Apache::TestReportPerl->generate_script;

@@ -297,7 +298,7 @@
     my $path = $code->path;

     return [EMAIL PROTECTED] $build->clean_files },
-            qw(lib/typemap),
+            qw(t/TEST lib/typemap),
             <xs/*.exp>, <xs/*.def>,
             map { "$path/$_"} @{ $code->clean_files }];
 }
@@ -522,11 +523,11 @@
 test_clean :
        $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) \
        t/TEST -clean
-       
+
 run_tests : test_clean
        $(PASSENV) \
        $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) \
-       t/TEST -verbose=$(TEST_VERBOSE) $(TEST_FILES)
+       t/TEST -bugreport -verbose=$(TEST_VERBOSE) $(TEST_FILES)
        cd ModPerl-Registry && $(MAKE) test

 test :: pure_all run_tests test_clean
Index: Apache-Test/lib/Apache/TestMM.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestMM.pm,v
retrieving revision 1.29
diff -u -r1.29 TestMM.pm
--- Apache-Test/lib/Apache/TestMM.pm    18 Jul 2003 18:50:34 -0000      1.29
+++ Apache-Test/lib/Apache/TestMM.pm    5 Nov 2003 01:23:31 -0000
@@ -54,7 +54,7 @@
 run_tests : test_clean
        $(PASSENV) \
        $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) \
-       t/TEST -verbose=$(TEST_VERBOSE) $(TEST_FILES)
+       t/TEST -bugreport -verbose=$(TEST_VERBOSE) $(TEST_FILES)

test :: pure_all run_tests test_clean

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.120
diff -u -r1.120 TestRun.pm
--- Apache-Test/lib/Apache/TestRun.pm   26 Oct 2003 20:35:01 -0000      1.120
+++ Apache-Test/lib/Apache/TestRun.pm   5 Nov 2003 01:23:32 -0000
@@ -24,7 +24,7 @@
 my %original_t_perms = ();

my @std_run = qw(start-httpd run-tests stop-httpd);
-my @others = qw(verbose configure clean help ssl http11);
+my @others = qw(verbose configure clean help ssl http11 bugreport);
my @flag_opts = (@std_run, @others);
my @string_opts = qw(order trace);
my @ostring_opts = qw(proxy ping);
@@ -46,6 +46,7 @@
'configure' => 'force regeneration of httpd.conf (tests will not be run)',
'clean' => 'remove all generated test files',
'help' => 'display this message',
+ 'bugreport' => 'print the hint how to report problems',
'preamble' => 'config to add at the beginning of httpd.conf',
'postamble' => 'config to add at the end of httpd.conf',
'ping[=block]' => 'test if server is running or port in use',
@@ -305,12 +306,25 @@


     eval 'END {
              return unless is_parent(); # because of fork
-             local $?; # preserve the exit status
-             eval {
-                Apache::TestRun->new(test_config =>
-                                     Apache::TestConfig->thaw)->scan_core;
-             };
+             $self ||=
+                 Apache::TestRun->new(test_config => Apache::TestConfig->thaw);
+             {
+                 local $?; # preserve the exit status
+                 eval {
+                    $self->scan_core;
+                 };
+             }
+             $self->try_bug_report();
          }';
+    die "failed: $@" if $@;
+
+}
+
+sub try_bug_report {
+    my $self = shift;
+    if ($? && $self->{opts}->{bugreport}) {
+        $self->bug_report if $self->can('bug_report');
+    }
 }

#throw away cached config and start fresh

__________________________________________________________________
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]



Reply via email to