perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0/t/filter in_bbs_body.t
Date Fri, 18 Apr 2003 08:06:19 GMT
stas        2003/04/18 01:06:19

  Modified:    .        Changes
               perl-framework/Apache-Test/lib/Apache TestConfigPerl.pm
                        TestRequest.pm
               t/directive perlloadmodule4.t perlloadmodule5.t
                        perlloadmodule6.t
               t/filter in_bbs_body.t
  Log:
  Apache::Test: provide a new request macro _BODY_ASSERT to replace
  _BODY in cases where the client part of the test directly prints to
  the output, in order to avoid skipped tests instead of reporting the
  failure of the server side. Use it in automatically generated
  tests.
  
  Revision  Changes    Path
  1.176     +6 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.175
  retrieving revision 1.176
  diff -u -r1.175 -r1.176
  --- Changes	18 Apr 2003 06:18:54 -0000	1.175
  +++ Changes	18 Apr 2003 08:06:18 -0000	1.176
  @@ -10,6 +10,12 @@
   
   =item 1.99_09-dev
   
  +Apache::Test: provide a new request macro _BODY_ASSERT to replace
  +_BODY in cases where the client part of the test directly prints to
  +the output, in order to avoid skipped tests instead of reporting the
  +failure of the server side. Use it in automatically generated
  +tests. [Stas]
  +
   httpd (1.3 && 2) / winFU have problems when the first path's segment
   includes ':' (security precaution which breaks the rfc) so we can't
   use /TestFoo::bar as path_info in Apache::Tests. Adjusting all tests
  
  
  
  1.70      +2 -9      httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm
  
  Index: TestConfigPerl.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- TestConfigPerl.pm	18 Apr 2003 06:18:54 -0000	1.69
  +++ TestConfigPerl.pm	18 Apr 2003 08:06:18 -0000	1.70
  @@ -105,15 +105,8 @@
       my $path = Apache::TestRequest::module2path($module);
   
       print $fh <<EOF;
  -use Apache::TestRequest 'GET';
  -my \$res = GET "/$path";
  -if (\$res->is_success) {
  -    print \$res->content;
  -}
  -else {
  -    die "server side has failed (response code: ", \$res->code, "),\\n",
  -        "see t/logs/error_log for more details\\n";
  -}
  +use Apache::TestRequest 'GET_BODY_ASSERT';
  +print GET_BODY_ASSERT "/$path";
   EOF
   
       close $fh or die "close $t: $!";
  
  
  
  1.77      +26 -2     httpd-test/perl-framework/Apache-Test/lib/Apache/TestRequest.pm
  
  Index: TestRequest.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRequest.pm,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- TestRequest.pm	18 Apr 2003 06:18:54 -0000	1.76
  +++ TestRequest.pm	18 Apr 2003 08:06:18 -0000	1.77
  @@ -8,6 +8,8 @@
   use Apache::Test ();
   use Apache::TestConfig ();
   
  +use Carp;
  +
   use constant TRY_TIMES => 50;
   use constant INTERP_KEY => 'X-PerlInterpreter';
   use constant UA_TIMEOUT => 60 * 10; #longer timeout for debugging
  @@ -132,6 +134,8 @@
   
   sub resolve_url {
       my $url = shift;
  +    Carp::croak("no url passed") unless defined $url;
  +
       return $url if $url =~ m,^(\w+):/,;
       $url = "/$url" unless $url =~ m,^/,;
   
  @@ -299,6 +303,10 @@
       UPLOAD(@_)->content;
   }
   
  +sub UPLOAD_BODY_ASSERT {
  +    content_assert(UPLOAD(@_));
  +}
  +
   #lwp only supports files
   sub upload_string {
       my($url, $data) = @_;
  @@ -428,7 +436,9 @@
                    OK   => sub { shift->is_success },
                    STR  => sub { shift->as_string },
                    HEAD => sub { lwp_as_string(shift, 0) },
  -                 BODY => sub { shift->content });
  +                 BODY => sub { shift->content },
  +                 BODY_ASSERT => sub { content_assert(shift) },
  +);
   
   for my $name (@EXPORT) {
       my $package = $have_lwp ?
  @@ -455,7 +465,7 @@
       push @EXPORT, map { join '_', $method, $_ } keys %shortcuts;
   }
   
  -push @EXPORT, qw(UPLOAD_BODY);
  +push @EXPORT, qw(UPLOAD_BODY UPLOAD_BODY_ASSERT);
   
   sub to_string {
       my $obj = shift;
  @@ -579,6 +589,20 @@
       my $fixup = $scheme_fixups{$scheme};
       return unless $fixup;
       $fixup->();
  +}
  +
  +# when the client side simply prints the response body which should
  +# include the test's output, we need to make sure that the request
  +# hasn't failed, or the test will be skipped instead of indicating the
  +# error.
  +sub content_assert {
  +    my $res = shift;
  +
  +    return $res->content if $res->is_success;
  +
  +    die join "\n", 
  +        "request has failed (the response code was: " . $res->code . ")",
  +        "see t/logs/error_log for more details\n";
   }
   
   1;
  
  
  
  1.3       +1 -1      modperl-2.0/t/directive/perlloadmodule4.t
  
  Index: perlloadmodule4.t
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/directive/perlloadmodule4.t,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- perlloadmodule4.t	18 Apr 2003 06:18:55 -0000	1.2
  +++ perlloadmodule4.t	18 Apr 2003 08:06:18 -0000	1.3
  @@ -10,4 +10,4 @@
   my $hostport = Apache::TestRequest::hostport($config);
   my $path = Apache::TestRequest::module2path($module);
   
  -print GET_BODY "http://$hostport/$path";
  +print GET_BODY_ASSERT "http://$hostport/$path";
  
  
  
  1.3       +1 -1      modperl-2.0/t/directive/perlloadmodule5.t
  
  Index: perlloadmodule5.t
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/directive/perlloadmodule5.t,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- perlloadmodule5.t	18 Apr 2003 06:18:55 -0000	1.2
  +++ perlloadmodule5.t	18 Apr 2003 08:06:18 -0000	1.3
  @@ -10,4 +10,4 @@
   my $hostport = Apache::TestRequest::hostport($config);
   my $path = Apache::TestRequest::module2path($module);
   
  -print GET_BODY "http://$hostport/$path";
  +print GET_BODY_ASSERT "http://$hostport/$path";
  
  
  
  1.3       +1 -1      modperl-2.0/t/directive/perlloadmodule6.t
  
  Index: perlloadmodule6.t
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/directive/perlloadmodule6.t,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- perlloadmodule6.t	18 Apr 2003 06:18:55 -0000	1.2
  +++ perlloadmodule6.t	18 Apr 2003 08:06:18 -0000	1.3
  @@ -10,4 +10,4 @@
   my $hostport = Apache::TestRequest::hostport($config);
   my $path = Apache::TestRequest::module2path($module);
   
  -print GET_BODY "http://$hostport/$path";
  +print GET_BODY_ASSERT "http://$hostport/$path";
  
  
  
  1.3       +1 -1      modperl-2.0/t/filter/in_bbs_body.t
  
  Index: in_bbs_body.t
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/filter/in_bbs_body.t,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- in_bbs_body.t	18 Apr 2003 06:18:56 -0000	1.2
  +++ in_bbs_body.t	18 Apr 2003 08:06:19 -0000	1.3
  @@ -10,5 +10,5 @@
   
   for my $x (1,2) {
       my $data = scalar reverse "ok $x\n";
  -    print POST_BODY $location, content => $data;
  +    print POST_BODY_ASSERT $location, content => $data;
   }
  
  
  

Mime
View raw message