Skip to content

Commit

Permalink
Restore "Test.pm - Allow output handles to be queried and modified"
Browse files Browse the repository at this point in the history
We must delay initializing Test handles until runtime
  • Loading branch information
hoelzro committed Sep 10, 2014
1 parent d315ab7 commit 78f60a3
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ my $time_before;
my $time_after;

# 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;
my $output;
my $failure_output;
my $todo_output;

INIT {
$output = $PROCESS::OUT;
$failure_output = $PROCESS::ERR;
$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 All @@ -37,6 +43,18 @@ _init_vars();

## test functions

our sub output is rw {
$output
}

our sub failure_output is rw {
$failure_output
}

our sub todo_output is rw {
$todo_output
}

# you can call die_on_fail; to turn it on and die_on_fail(0) to turn it off
sub die_on_fail($fail=1) {
$die_on_fail = $fail;
Expand Down

0 comments on commit 78f60a3

Please sign in to comment.