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 pg...@apache.org on 2006/07/13 05:41:59 UTC
svn commit: r421487 - in /perl/modperl/trunk/t: modperl/local_env.t
response/TestModperl/local_env.pm
Author: pgollucci
Date: Wed Jul 12 20:41:59 2006
New Revision: 421487
URL: http://svn.apache.org/viewvc?rev=421487&view=rev
Log:
flush out tests for local %ENV
well at least it works, but it does still break other tests....
Modified:
perl/modperl/trunk/t/modperl/local_env.t
perl/modperl/trunk/t/response/TestModperl/local_env.pm
Modified: perl/modperl/trunk/t/modperl/local_env.t
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/modperl/local_env.t?rev=421487&r1=421486&r2=421487&view=diff
==============================================================================
--- perl/modperl/trunk/t/modperl/local_env.t (original)
+++ perl/modperl/trunk/t/modperl/local_env.t Wed Jul 12 20:41:59 2006
@@ -2,6 +2,20 @@
use warnings FATAL => 'all';
use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest;
+
+my $module = 'TestModperl::local_env';
+my $url = Apache::TestRequest::module2url($module);
+
+t_debug "connecting to $url";
+print GET_BODY_ASSERT $url;
+
+__END__
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
use Apache::TestRequest qw(GET);
plan tests => 1;
Modified: perl/modperl/trunk/t/response/TestModperl/local_env.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/response/TestModperl/local_env.pm?rev=421487&r1=421486&r2=421487&view=diff
==============================================================================
--- perl/modperl/trunk/t/response/TestModperl/local_env.pm (original)
+++ perl/modperl/trunk/t/response/TestModperl/local_env.pm Wed Jul 12 20:41:59 2006
@@ -3,13 +3,47 @@
use strict;
use warnings FATAL => 'all';
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+use Apache2::RequestUtil ();
+
+use Apache::Test;
+use Apache::TestUtil;
+
use Apache2::Const -compile => 'OK';
+# local %ENV used to cause segfaults
+# Report: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
+# Fixed in: http://svn.apache.org/viewcvs.cgi?rev=357236&view=rev
sub handler {
- # This used to cause segfaults
- # Report: http://thread.gmane.org/gmane.comp.apache.mod-perl/22236
- # Fixed in: http://svn.apache.org/viewcvs.cgi?rev=357236&view=rev
- local %ENV;
+ my $r = shift;
+
+ plan $r, tests => 6;
+
+ my %copy_ENV = %ENV; ## this is not a deep copy;
+
+ ok t_cmp($ENV{MOD_PERL_API_VERSION}, 2,
+ "\$ENV{MOD_PERL_API_VERSION} is 2 before local \%ENV");
+
+ {
+ local %ENV;
+
+ ok t_cmp($ENV{MOD_PERL_API_VERSION}, undef,
+ "\$ENV{MOD_PERL_API_VERSION} is undef after local \%ENV");
+
+ ok t_cmp(scalar keys %ENV, 0,
+ "\%ENV has 0 keys after local");
+
+ $ENV{LOCAL} = 1;
+
+ ok t_cmp($ENV{LOCAL}, 1,
+ "can set value after local, but still in block");
+ }
+
+ ok t_cmp($ENV{LOCAL}, undef,
+ "valuee set in local {} block is gone after leaving scope");
+
+ ok t_cmp(\%copy_ENV, \%ENV, "\%ENV was restored correctly");
Apache2::Const::OK;
}