[libcgi-test-perl] 01/03: $ENV{TEMP} is now forced for CGI scripts
Axel Beckert
abe at deuxchevaux.org
Mon Jan 11 00:38:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to annotated tag 1.110
in repository libcgi-test-perl.
commit 6be0caa2e3d8812de04009e42682f0ca1af8198b
Author: Alex Tokarev <nohuhu at nohuhu.org>
Date: Thu Apr 30 22:27:22 2015 -0700
$ENV{TEMP} is now forced for CGI scripts
---
lib/CGI/Test.pm | 6 ++++++
t/01_env.t | 14 ++++++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/CGI/Test.pm b/lib/CGI/Test.pm
index 9bf5e76..99d97e6 100644
--- a/lib/CGI/Test.pm
+++ b/lib/CGI/Test.pm
@@ -648,6 +648,12 @@ sub _run_cgi
$ENV{PERL5LIB} = join($path_sep, map {-e $_ ? abs_path($_) : $_} @INC);
+ # Also make sure that temp directory is available for the script,
+ # else older CGI.pm may choke and default to some not-quite-sane
+ # values that do not work in Windows
+
+ $ENV{TMPDIR} = $this->tmp_dir;
+
#
# Now run the script, changing the current directory to the location
# of the script, as a web server would.
diff --git a/t/01_env.t b/t/01_env.t
index fd6ea3f..83f54a9 100644
--- a/t/01_env.t
+++ b/t/01_env.t
@@ -2,7 +2,8 @@ use strict;
use warnings;
use Config;
-use Test::More tests => 16;
+use File::Temp ();
+use Test::More tests => 18;
use CGI::Test;
@@ -52,18 +53,22 @@ cmp_ok $V{PATH_INFO}, 'eq', "/$PATH_INFO", "PATH_INFO";
cmp_ok $V{QUERY_STRING}, 'eq', $QUERY, "QUERY_STRING";
cmp_ok $V{REMOTE_USER}, 'eq', $USER, "REMOTE_USER";
cmp_ok $V{HTTP_USER_AGENT}, 'eq', "CGI::Test", "HTTP_USER_AGENT";
+cmp_ok $V{TMPDIR}, 'eq', $ct->tmp_dir, "TMPDIR default";
my $AGENT = "LWP::UserAgent";
my $EXTRA = "is set";
$page->delete;
+my $tmpdir = File::Temp->newdir();
+
my $ct2 = CGI::Test->new(
-base_url => $BASE,
+ -tmp_dir => $tmpdir->dirname,
-cgi_dir => "t/cgi",
-cgi_env => {
- EXTRA_IMPORTANT_VARIABLE => $EXTRA,
- HTTP_USER_AGENT => $AGENT,
- SCRIPT_FILENAME => "foo",
+ EXTRA_IMPORTANT_VARIABLE => $EXTRA,
+ HTTP_USER_AGENT => $AGENT,
+ SCRIPT_FILENAME => "foo",
},
);
@@ -73,6 +78,7 @@ parse_content(\%V, $page->raw_content_ref);
cmp_ok $V{SCRIPT_NAME}, 'eq', "/cgi-bin/$SCRIPT", "SCRIPT_NAME";
cmp_ok $V{HTTP_USER_AGENT}, 'eq', $AGENT, "HTTP_USER_AGENT";
cmp_ok $V{EXTRA_IMPORTANT_VARIABLE}, 'eq', $EXTRA, "EXTRA_IMPORTANT_VARIABLE";
+cmp_ok $V{TMPDIR}, 'eq', $tmpdir->dirname, "TMPDIR custom";
ok !exists $V{REMOTE_USER}, "REMOTE_USER not set";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcgi-test-perl.git
More information about the Pkg-perl-cvs-commits
mailing list