summaryrefslogtreecommitdiff
path: root/t/run
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-02-21 10:33:12 +0000
committerNicholas Clark <nick@ccl4.org>2011-02-21 10:33:12 +0000
commitb01f2fb210240eee556aff42c575e82a5ae3779b (patch)
tree4a68a837b5cacdd68dc70a35c3e5fecb04cad780 /t/run
parent1f0d8f98440c01382cb8734270b0c93d66cf2f4f (diff)
downloadperl-b01f2fb210240eee556aff42c575e82a5ae3779b.tar.gz
In runenv.t, inline runperl() into try(), its only caller.
d5226c4c8f9a2932e broke runperl_and_capture() out from runperl(), but didn't notice that there was only one caller for runperl(). Change try() to use is() for testing each of STDOUT and STDERR, instead of an explicit test, explicit diagnostics, and a summary to ok(). This increases the tests run, hence the plan needs changing. Also inline it_didnt_work() into runperl_and_capture(), and remove the END block that deletes the temporary files, which has been vestigial since 2d90ac9586ffb5c7 converted runenv.t to use test.pl's tmpfile().
Diffstat (limited to 't/run')
-rw-r--r--t/run/runenv.t42
1 files changed, 9 insertions, 33 deletions
diff --git a/t/run/runenv.t b/t/run/runenv.t
index 3628bd08a9..2d1ac1f9c5 100644
--- a/t/run/runenv.t
+++ b/t/run/runenv.t
@@ -15,7 +15,7 @@ BEGIN {
require './test.pl'
}
-plan tests => 78;
+plan tests => 98;
my $STDOUT = tempfile();
my $STDERR = tempfile();
@@ -27,6 +27,7 @@ delete $ENV{PERL5LIB};
delete $ENV{PERL5OPT};
+# Run perl with specified environment and arguments, return (STDOUT, STDERR)
sub runperl_and_capture {
local *F;
my ($env, $args) = @_;
@@ -54,39 +55,19 @@ sub runperl_and_capture {
$ENV{$k} = $env->{$k};
}
open STDOUT, "> $STDOUT" or exit $FAILURE_CODE;
- open STDERR, "> $STDERR" or it_didnt_work();
- { exec $PERL, @$args }
- it_didnt_work();
- }
-}
-
-# 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 {
+ open STDERR, "> $STDERR" and do { exec $PERL, @$args };
+ # it didn't_work:
print STDOUT "IWHCWJIHCI\cNHJWCJQWKJQJWCQW\n";
exit $FAILURE_CODE;
+ }
}
sub try {
- my ($success, $reason) = runperl(@_);
- $reason =~ s/\n/\\n/g if defined $reason;
+ my ($env, $args, $stdout, $stderr) = @_;
+ my ($actual_stdout, $actual_stderr) = runperl_and_capture($env, $args);
local $::Level = $::Level + 1;
- ok( $success, $reason );
+ is ($stdout, $actual_stdout);
+ is ($stderr, $actual_stderr);
}
# PERL5OPT Command-line options (switches). Switches in
@@ -260,8 +241,3 @@ foreach (['nothing', ''],
}
# PERL5LIB tests with included arch directories still missing
-
-END {
- 1 while unlink $STDOUT;
- 1 while unlink $STDERR;
-}