summaryrefslogtreecommitdiff
path: root/t/run
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-02-17 20:18:39 +0000
committerNicholas Clark <nick@ccl4.org>2009-02-17 23:27:06 +0000
commitd5226c4c8f9a293280b320d06c082073daeb75b1 (patch)
treedaa6a8b14303fb8871699e7537cd8cb2c712ac88 /t/run
parent104393a727efd8bd71ca6d7f9b0d20a5b92fde48 (diff)
downloadperl-d5226c4c8f9a293280b320d06c082073daeb75b1.tar.gz
In runenv.t, break apart running perl and testing the output into two functions.
Diffstat (limited to 't/run')
-rw-r--r--t/run/runenv.t36
1 files changed, 20 insertions, 16 deletions
diff --git a/t/run/runenv.t b/t/run/runenv.t
index 5012359792..9baf43cf24 100644
--- a/t/run/runenv.t
+++ b/t/run/runenv.t
@@ -26,18 +26,12 @@ delete $ENV{PERLLIB};
delete $ENV{PERL5LIB};
delete $ENV{PERL5OPT};
-# Run perl with specified environment and arguments returns a list.
-# First element is true if Perl's stdout and stderr match the
-# supplied $stdout and $stderr argument strings exactly.
-# second element is an explanation of the failure
-sub runperl {
- local *F;
- my ($env, $args, $stdout, $stderr) = @_;
+sub runperl_and_capture {
+ local *F;
+ my ($env, $args) = @_;
unshift @$args, '-I../lib';
- $stdout = '' unless defined $stdout;
- $stderr = '' unless defined $stderr;
local %ENV = %ENV;
delete $ENV{PERLLIB};
delete $ENV{PERL5LIB};
@@ -54,13 +48,7 @@ sub runperl {
open F, "< $STDERR" or return (0, "Couldn't read $STDERR file");
{ local $/; $actual_stderr = <F> }
- if ($actual_stdout ne $stdout) {
- return (0, "Stdout mismatch: expected [$stdout], saw [$actual_stdout]");
- } elsif ($actual_stderr ne $stderr) {
- return (0, "Stderr mismatch: expected [$stderr], saw [$actual_stderr]");
- } else {
- return 1; # success
- }
+ return ($actual_stdout, $actual_stderr);
} else { # child
for my $k (keys %$env) {
$ENV{$k} = $env->{$k};
@@ -72,6 +60,22 @@ sub runperl {
}
}
+# Run perl with specified environment and arguments returns a list.
+# First element is true if Perl's stdout and stderr match the
+# supplied $stdout and $stderr argument strings exactly.
+# second element is an explanation of the failure
+sub runperl {
+ local *F;
+ my ($env, $args, $stdout, $stderr) = @_;
+ my ($actual_stdout, $actual_stderr) = runperl_and_capture($env, $args);
+ if ($actual_stdout ne $stdout) {
+ return (0, "Stdout mismatch: expected [$stdout], saw [$actual_stdout]");
+ } elsif ($actual_stderr ne $stderr) {
+ return (0, "Stderr mismatch: expected [$stderr], saw [$actual_stderr]");
+ } else {
+ return 1; # success
+ }
+}
sub it_didnt_work {
print STDOUT "IWHCWJIHCI\cNHJWCJQWKJQJWCQW\n";