dougm 01/04/03 21:37:03 Modified: Apache-Test/lib/Apache Test.pm TestRequest.pm Apache-Test/t request.t t/apache post.t t/filter lc.t t/hooks authen.t Log: make test work without lwp installed Revision Changes Path 1.2 +13 -4 modperl-2.0/Apache-Test/lib/Apache/Test.pm Index: Test.pm =================================================================== RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/Test.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Test.pm 2001/04/02 08:53:05 1.1 +++ Test.pm 2001/04/04 04:36:57 1.2 @@ -7,7 +7,7 @@ use Exporter (); our @ISA = qw(Exporter); -our @EXPORT = qw(ok plan); +our @EXPORT = qw(ok plan have_lwp); our $VERSION = '0.01'; #so Perl's Test.pm can be run inside mod_perl @@ -36,9 +36,18 @@ 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 + if ($condition) { + unless (defined &have_lwp) { + #XXX figure out a better set this up + #dont want to require Apache::TestRequest/lwp + #on the server side + require Apache::TestRequest; + *have_lwp = \&Apache::TestRequest::has_lwp; + } + unless ($condition->()) { + print "1..0\n"; + exit; #XXX: Apache->exit + } } Test::plan(@_); 1.2 +6 -0 modperl-2.0/Apache-Test/lib/Apache/TestRequest.pm Index: TestRequest.pm =================================================================== RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/TestRequest.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestRequest.pm 2001/04/02 08:55:42 1.1 +++ TestRequest.pm 2001/04/04 04:36:58 1.2 @@ -12,6 +12,12 @@ sub has_lwp { $have_lwp } +unless ($have_lwp) { + #need to define the shortcuts even though the wont be used + #so Perl can parse test scripts + @HTTP::Request::Common::EXPORT = qw(GET HEAD POST PUT); +} + require Exporter; *import = \&Exporter::import; our @EXPORT = @HTTP::Request::Common::EXPORT; 1.2 +1 -1 modperl-2.0/Apache-Test/t/request.t Index: request.t =================================================================== RCS file: /home/cvs/modperl-2.0/Apache-Test/t/request.t,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- request.t 2001/04/02 09:01:24 1.1 +++ request.t 2001/04/04 04:36:59 1.2 @@ -4,7 +4,7 @@ use Apache::Test; use Apache::TestRequest; -plan tests => 9, \&Apache::TestRequest::has_lwp; +plan tests => 9, \&have_lwp; my $url = '/'; 1.2 +2 -2 modperl-2.0/t/apache/post.t Index: post.t =================================================================== RCS file: /home/cvs/modperl-2.0/t/apache/post.t,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- post.t 2001/04/02 09:08:40 1.1 +++ post.t 2001/04/04 04:37:00 1.2 @@ -1,10 +1,10 @@ use strict; use warnings FATAL => 'all'; -use Test; +use Apache::Test; use Apache::TestRequest; -plan tests => 2; +plan tests => 2, \&have_lwp; my $location = "/TestApache::post"; my $str; 1.2 +2 -2 modperl-2.0/t/filter/lc.t Index: lc.t =================================================================== RCS file: /home/cvs/modperl-2.0/t/filter/lc.t,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- lc.t 2001/04/03 00:28:26 1.1 +++ lc.t 2001/04/04 04:37:01 1.2 @@ -1,10 +1,10 @@ use strict; use warnings FATAL => 'all'; -use Test; +use Apache::Test; use Apache::TestRequest; -plan tests => 1; +plan tests => 1, \&have_lwp; my $location = "/pod/modperl_2.0.pod"; 1.3 +2 -2 modperl-2.0/t/hooks/authen.t Index: authen.t =================================================================== RCS file: /home/cvs/modperl-2.0/t/hooks/authen.t,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- authen.t 2001/04/02 19:30:22 1.2 +++ authen.t 2001/04/04 04:37:02 1.3 @@ -1,10 +1,10 @@ use strict; use warnings FATAL => 'all'; -use Test; +use Apache::Test; use Apache::TestRequest; -plan tests => 4; +plan tests => 4, \&have_lwp; my $location = "/TestHooks::authen";