perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guy Albertelli II <...@albertelli.com>
Subject 'error-notes' has no value on errordocument redirect (patch and tests attached)
Date Mon, 21 Aug 2006 18:40:22 GMT
Hi,

I noticed the call for tests. I think I have generated the tests
correctly.

- the first test is for genrating a new 'error-notes' entry, and
  currently fails with apt_table_mergen()
- the second one tests the case when 'error-notes' already has a value
  (succeeds with either apr_table_merge() or apr_table_mergen(), but
  fails with the past revision when apr_table_add() had been used)



Index: src/modules/perl/modperl_callback.c
===================================================================
--- src/modules/perl/modperl_callback.c	(revision 433312)
+++ src/modules/perl/modperl_callback.c	(working copy)
@@ -130,7 +130,7 @@
 
     if (status == HTTP_INTERNAL_SERVER_ERROR) {
         if (r && r->notes) {
-            apr_table_mergen(r->notes, "error-notes", SvPV_nolen(ERRSV));
+            apr_table_merge(r->notes, "error-notes", SvPV_nolen(ERRSV));
         }
     }
 
--- /dev/null	2006-08-16 05:24:17.504895000 -0400
+++ t/hooks/error.t	2006-08-21 14:15:45.000000000 -0400
@@ -0,0 +1,32 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest;
+
+plan tests => 2;
+
+{
+open(my $fh,'>/tmp/test');
+print $fh ("start\n");
+close($fh);
+    # this registers and performs cleanups, but we test whether the
+    # cleanup was run only in the next sub-test
+    my $location = "/TestHooks__error";
+    my $expected = qr/^Error: Undefined subroutine/;
+    my $received = GET_BODY $location;
+    ok t_cmp($received, $expected, "error-notes set on ErrorDocument");
+}
+
+{
+    # this registers and performs cleanups, but we test whether the
+    # cleanup was run only in the next sub-test
+    my $error_seed_text = 'seed_text';
+    my $location = "/TestHooks__error?$error_seed_text";
+    my $expected = qr/^Error: \Q$error_seed_text\E, Undefined subroutine/;
+    my $received = GET_BODY $location;
+    ok t_cmp($received, $expected, "seeded error-notes set on ErrorDocument");
+}
+
+
--- /dev/null	2006-08-16 05:24:17.504895000 -0400
+++ t/hooks/TestHooks/error.pm	2006-08-21 14:16:00.000000000 -0400
@@ -0,0 +1,44 @@
+package TestHooks::error;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+
+use Apache2::Const -compile => 'OK';
+
+use APR::Table ();
+
+sub handler {
+    my $r = shift;
+    my $args = $r->args();
+    if (defined($args) && $args ne '') {
+        $r->notes->set('error-notes' => $args);
+    }
+    &bomb();
+    Apache2::Const::OK;
+}
+
+sub fail {
+    my $r = shift;
+    $r->print('Error: '.$r->prev->notes->get('error-notes'));
+    Apache2::Const::OK;
+}
+
+1;
+__DATA__
+<NoAutoConfig>
+  <Location /TestHooks__error>
+      SetHandler modperl
+      PerlResponseHandler TestHooks::error
+      ErrorDocument 500 /TestHooks__error__fail
+  </Location>
+  <Location /TestHooks__error__fail>
+      SetHandler modperl
+      PerlResponseHandler TestHooks::error::fail
+  </Location>
+</NoAutoConfig>
+

-- 
guy@albertelli.com   0-7-1-6-27,137

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message