[Please let's decide where we discuss Apache-Test and send patches, the docs say [email protected], but in fact it's spread across the two lists. It seems that test-dev will eventually take over, since that's where people report problems.]

People already start complaining because they don't know why this or that test gets skipped, but they are techy enough to look at the code to figure out. Once we release Apache-Test, many people won't know to figure out why some tests are skipped. Therefore I've tried to solve this, so if I require have_module Chatbot::Eliza1 I get:

 exec ./t/TEST protocol/eliza
protocol/eliza....skipped: missing Chatbot::Eliza1
All tests successful, 1 test skipped.

The extension of Test::plan is already somewhat tricky, so in order to preserve the trick we have to make sure that our extension always returns a zero or one value. Since CODE and ARRAY refs were already taken I've used the available HASH ref. Now have module returns a reason for its failure, the CODE and ARRAY refs do or can do the same, here is how it works (this is incomplete, just to see if you like it):


Index: Apache-Test/lib/Apache/Test.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/Test.pm,v
retrieving revision 1.26
diff -u -r1.26 Test.pm
--- Apache-Test/lib/Apache/Test.pm 2001/10/16 20:30:57 1.26
+++ Apache-Test/lib/Apache/Test.pm 2001/10/18 03:31:12
@@ -81,6 +81,7 @@
my $condition = pop @_;
my $ref = ref $condition;
my $meets_condition = 0;
+ my $reason = '';
if ($ref) {
if ($ref eq 'CODE') {
#plan tests $n, \&has_lwp
@@ -88,16 +89,17 @@
}
elsif ($ref eq 'ARRAY') {
#plan tests $n, [qw(php4 rewrite)];
- $meets_condition = have_module($condition);
+ ($meets_condition, $reason) = %{ have_module($condition) }
}
- }
- else {
- # we have the verdict already: true/false
- $meets_condition = $condition ? 1 : 0;
+ elsif ($ref eq 'HASH') {
+ # we have the verdict already: true/false
+ ($meets_condition, $reason) = %$condition;
+ $meets_condition = $meets_condition ? 1 : 0;
+ }
}


         unless ($meets_condition) {
-            print "1..0\n";
+            print "1..0 # skipped: $reason \n";
             exit; #XXX: Apache->exit
         }
     }
@@ -119,10 +121,10 @@
         die "bogus module name $_" unless /^[\w:.]+$/;
         eval "require $_";
         #print $@ if $@;
-        return 0 if $@;
+        return {0 => "missing $_"} if $@;
     }

-    return 1;
+    return {1 => undef};
 }

 sub have_cgi {


_____________________________________________________________________ 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