perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: modperl-2.0/Apache-Test/lib/Apache Test.pm
Date Mon, 02 Apr 2001 08:53:06 GMT
dougm       01/04/02 01:53:06

  Added:       Apache-Test/lib/Apache Test.pm
  Log:
  Test.pm wrapper to run under mod_perl
  
  Revision  Changes    Path
  1.1                  modperl-2.0/Apache-Test/lib/Apache/Test.pm
  
  Index: Test.pm
  ===================================================================
  package Apache::Test;
  
  use strict;
  use warnings FATAL => 'all';
  
  use Test qw(ok);
  use Exporter ();
  
  our @ISA = qw(Exporter);
  our @EXPORT = qw(ok plan);
  our $VERSION = '0.01';
  
  #so Perl's Test.pm can be run inside mod_perl
  sub init_test_pm {
      my $r = shift;
  
      if (defined &Apache::RequestRec::puts) {
          package Apache::RequestRec;
          unless (defined &PRINT) {
              *PRINT = \&puts;
          }
          tie *STDOUT, __PACKAGE__, $r;
      }
      else {
          $r->send_http_header; #1.xx
      }
  
      $r->content_type('text/plain');
  
      $Test::TESTOUT = \*STDOUT;
      $Test::planned = 0;
      $Test::ntest = 1;
  }
  
  sub plan {
      init_test_pm(shift) if ref $_[0];
  
      my $condition = pop @_ if ref $_[-1];
      if ($condition and ! $condition->()) {
          print "0..1\n";
          exit; #XXX: Apache->exit
      }
  
      Test::plan(@_);
  }
  
  1;
  
  
  
  
  

Mime
View raw message