You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2003/02/07 01:15:39 UTC
cvs commit: modperl-2.0/ModPerl-Registry/t/cgi-bin runtime_error_n_status_change.pl runtime_error_plus_body.pl runtime_error.pl
stas 2003/02/06 16:15:39
Modified: ModPerl-Registry/t .cvsignore 500.t
ModPerl-Registry/t/cgi-bin runtime_error.pl
Added: ModPerl-Registry/t/cgi-bin runtime_error_n_status_change.pl
runtime_error_plus_body.pl
Log:
add several more tests which explore various situations when runtime
errors happen
Revision Changes Path
1.3 +1 -0 modperl-2.0/ModPerl-Registry/t/.cvsignore
Index: .cvsignore
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore 18 Oct 2001 04:25:12 -0000 1.2
+++ .cvsignore 7 Feb 2003 00:15:39 -0000 1.3
@@ -1,3 +1,4 @@
logs
htdocs
TEST
+SMOKE
1.3 +44 -4 modperl-2.0/ModPerl-Registry/t/500.t
Index: 500.t
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/500.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- 500.t 23 Jan 2003 01:12:01 -0000 1.2
+++ 500.t 7 Feb 2003 00:15:39 -0000 1.3
@@ -5,7 +5,21 @@
use Apache::TestUtil;
use Apache::TestRequest qw(GET);
-plan tests => 3;
+plan tests => 6;
+
+{
+ # the script changes the status before the run-time error happens,
+ # this status change should be ignored
+ my $url = "/registry/runtime_error_n_status_change.pl";
+ my $res = GET($url);
+ #t_debug($res->content);
+ ok t_cmp(
+ 500,
+ $res->code,
+ "500 error on runtime error (when the script changes the status)",
+ );
+}
+
{
@@ -20,6 +34,21 @@
}
{
+ my $url = "/registry/missing_headers.pl";
+ my $res = GET($url);
+ #t_debug($res->content);
+ ok t_cmp(
+ 500,
+ $res->code,
+ "500 error on missing HTTP headers",
+ );
+}
+
+{
+ # since we have a runtime error before any body is sent, mod_perl
+ # has a chance to communicate the return status of the script to
+ # Apache before headers are sent, so we get the code 500 in the
+ # HTTP headers
my $url = "/registry/runtime_error.pl";
my $res = GET($url);
#t_debug($res->content);
@@ -31,12 +60,23 @@
}
{
- my $url = "/registry/missing_headers.pl";
+ # even though we have a runtime error here, the scripts succeeds
+ # to send some body before the error happens and since by that
+ # time Apache has already sent the headers, they will include
+ # 200 OK
+ my $url = "/registry/runtime_error_plus_body.pl";
my $res = GET($url);
#t_debug($res->content);
ok t_cmp(
- 500,
+ 200,
$res->code,
- "500 error on missing HTTP headers",
+ "200, followed by a runtime error",
+ );
+
+ # the error message is attached after the body
+ ok t_cmp(
+ qr/some body.*The server encountered an internal error/ms,
+ $res->content,
+ "200, followed by a runtime error",
);
}
1.2 +3 -0 modperl-2.0/ModPerl-Registry/t/cgi-bin/runtime_error.pl
Index: runtime_error.pl
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/cgi-bin/runtime_error.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- runtime_error.pl 23 Jan 2003 01:12:01 -0000 1.1
+++ runtime_error.pl 7 Feb 2003 00:15:39 -0000 1.2
@@ -1,2 +1,5 @@
+# this script sends no body at all, and since the error happens
+# the script will return 500
+
print "Content-type: text/plain\n\n";
print no_such_func();
1.1 modperl-2.0/ModPerl-Registry/t/cgi-bin/runtime_error_n_status_change.pl
Index: runtime_error_n_status_change.pl
===================================================================
my $r = shift;
$r->status(404);
$r->send_http_header('text/plain');
$r->print(no_such_func());
1.1 modperl-2.0/ModPerl-Registry/t/cgi-bin/runtime_error_plus_body.pl
Index: runtime_error_plus_body.pl
===================================================================
# this script sends some body before the error happens,
# so 200 OK is expected, followed by an error
print "Content-type: text/plain\n\n";
print "some body";
print no_such_func();