Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Portably avoid overrides of $*OUT/$*ERR in Test.pm
This replaces an unportable attempt to do so. PROCESS is populated
with The Real Thing at startup, and any userland overrides will be
done with dynamic variables. Thus this achieves the desired effect
with much less code and without blowing up on Windows.
  • Loading branch information
jnthn committed Aug 17, 2014
1 parent f1d12b0 commit 3e0a909
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions lib/Test.pm
Expand Up @@ -22,22 +22,10 @@ my $die_on_fail;
my $time_before;
my $time_after;

# handles
my $output = $*OUT;
my $failure_output = $*ERR;
my $todo_output = $*OUT;

try {
# XXX do this with dup or an analogous cross-platform construct
# XXX these should probably have :autoflush
my $output_h = open('/dev/stdout', :w);
my $failure_output_h = open('/dev/stderr', :w);
my $todo_output_h = open('/dev/stdout', :w);

( $output, $failure_output, $todo_output ) = ( $output_h, $failure_output_h, $todo_output_h );

CATCH {}
}
# Output should always go to real stdout/stderr, not to any dynamic overrides.
my $output = $PROCESS::OUT;
my $failure_output = $PROCESS::ERR;
my $todo_output = $PROCESS::OUT;

## If done_testing hasn't been run when we hit our END block, we need to know
## so that it can be run. This allows compatibility with old tests that use
Expand Down

0 comments on commit 3e0a909

Please sign in to comment.