You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Guy Albertelli II <gu...@albertelli.com> on 2006/08/21 20:40:22 UTC
'error-notes' has no value on errordocument redirect (patch and tests
attached)
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
Re: 'error-notes' has no value on errordocument redirect (patch and
tests attached)
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Guy Albertelli II wrote:
> +open(my $fh,'>/tmp/test');
That should be File::tmpdir() / catfile() functions
to build that path.
> + &bomb();
Don't need the &
> + Apache2::Const::OK;
> +}
> +
> +sub fail {
> + my $r = shift;
Needs a line break here to match our style guide.
I'll get around to running this in a bit, but from an eyeball perspective, it looks good.
Thanks Guy.
--
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F 6A47 D55A 7172 A799 97F
"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ /
/ /|_/ / // /\ \/ /_/ / /__
/_/ /_/\_, /___/\___\_\___/
<___/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: 'error-notes' has no value on errordocument redirect (patch and
tests attached)
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Mon, 21 Aug 2006, Guy Albertelli II wrote:
> Hi,
>
> I noticed the call for tests. I think I have generated the tests
> correctly.
Thanks, Guy - this has been committed as revision 436617.
--
best regards,
Randy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: 'error-notes' has no value on errordocument redirect (patch and
tests attached)
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Mon, 21 Aug 2006, Guy Albertelli II wrote:
> 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)
I confirmed this behaviour on Win32 (Apache/2.2); unless
someone sees something amiss, I could commit this within
the next couple of days.
--
best regards,
Randy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org