diff options
author | Nicolas R <nicolas@atoomic.org> | 2020-08-27 12:40:51 -0500 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2020-11-05 00:07:41 +0000 |
commit | caf6f170e537c7fc6aa8802adde54d86ff2009a2 (patch) | |
tree | dd72188284d95d90461cf113cbdd31ace8943653 /ext/Devel-Peek | |
parent | a8733f32d9a42aca02e91931b2b4c2a5f8979ab5 (diff) | |
download | perl-caf6f170e537c7fc6aa8802adde54d86ff2009a2.tar.gz |
Catch errors earlier in Devel-Peek/t/Peek.t
When testing Devel-Peek we can run some tests
inside an eval and do not bother to check if it
succeeds or not.
As STDERR is redirected to a file, we do not even
notice the error message when an error occurs.
This commit postpones the redirection of STDERR
and 'die' if the eval quoted string from `do_test` fails.
Diffstat (limited to 'ext/Devel-Peek')
-rw-r--r-- | ext/Devel-Peek/t/Peek.t | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/Devel-Peek/t/Peek.t b/ext/Devel-Peek/t/Peek.t index ef41b62c5a..a8c68c80e6 100644 --- a/ext/Devel-Peek/t/Peek.t +++ b/ext/Devel-Peek/t/Peek.t @@ -38,9 +38,11 @@ sub do_test { my $pattern = $_[2]; my $do_eval = $_[5]; if (open(OUT,'>', "peek$$")) { - open(STDERR, ">&OUT") or die "Can't dup OUT: $!"; + my $setup_stderr = sub { open(STDERR, ">&OUT") or die "Can't dup OUT: $!" }; if ($do_eval) { my $sub = eval "sub { Dump $_[1] }"; + die $@ if $@; + $setup_stderr->(); $sub->(); print STDERR "*****\n"; # second dump to compare with the first to make sure nothing @@ -48,6 +50,7 @@ sub do_test { $sub->(); } else { + $setup_stderr->(); Dump($_[1]); print STDERR "*****\n"; # second dump to compare with the first to make sure nothing @@ -342,6 +345,8 @@ do_test('reference to named subroutine without prototype', \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$repeat_todo" \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$pattern" \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$do_eval" +\s+\\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$setup_stderr" +\s+\\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "&" \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$sub" \\d+\\. $ADDR<\\d+> FAKE "\\$DEBUG" flags=0x0 index=0 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$dump" |