forked from pjcj/Devel--Cover
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manage Devel::Cover coverage reporting errors.
Devel::Cover errors in _report() would end the process. That wouldn't normally matter since Devel::Cover tries very hard to be the last thing to be run anyway. But it is important just before an exec(). When Devel::Cover sees an exec() call it first calls report() then calls the exec(). In this case it is important that any errors in report() do not prevent the exec() from running. We go belt and braces here: put an eval {} around the _report() and try to nicely report the problem, and add G_EVAL to call_pv(). Also add a test for this. This problem was found by Daisuke Maki. He also diagnosed it, provided the test case and suggested the solution.
- Loading branch information
Showing
4 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Reading database from ... | ||
|
||
|
||
------------------------------------------ ------ ------ ------ ------ ------ | ||
File stmt bran cond sub total | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
tests/exec_die 50.0 50.0 n/a 0.0 44.4 | ||
Total 50.0 50.0 n/a 0.0 44.4 | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
|
||
|
||
Run: ... | ||
Perl version: ... | ||
OS: ... | ||
Start: ... | ||
Finish: ... | ||
|
||
tests/exec_die | ||
|
||
line err stmt bran cond sub code | ||
1 #!/usr/bin/perl | ||
2 | ||
3 # Copyright 2007-2011, Paul Johnson (pjcj@cpan.org) | ||
4 | ||
5 # This software is free. It is licensed under the same terms as Perl itself. | ||
6 | ||
7 # The latest version of this software should be available from my homepage: | ||
8 # http://www.pjcj.net | ||
9 | ||
10 1 my $pid = fork; | ||
11 | ||
12 *** 1 50 if ($pid) | ||
13 { | ||
14 1 wait; | ||
15 } | ||
16 else | ||
17 { | ||
18 *** 0 0 local *Devel::Cover::_report = sub { die "Badness happened!" }; | ||
*** 0 | ||
19 *** 0 exec "echo We want to be able to see this."; | ||
20 } | ||
|
||
|
||
Branches | ||
-------- | ||
|
||
line err % true false branch | ||
----- --- ------ ------ ------ ------ | ||
12 *** 50 1 0 if ($pid) { } | ||
|
||
|
||
Uncovered Subroutines | ||
--------------------- | ||
|
||
Subroutine Count Location | ||
---------- ----- ----------------- | ||
__ANON__ 0 tests/exec_die:18 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/perl | ||
|
||
# Copyright 2007-2011, Paul Johnson (pjcj@cpan.org) | ||
|
||
# This software is free. It is licensed under the same terms as Perl itself. | ||
|
||
# The latest version of this software should be available from my homepage: | ||
# http://www.pjcj.net | ||
|
||
my $pid = fork; | ||
|
||
if ($pid) | ||
{ | ||
wait; | ||
} | ||
else | ||
{ | ||
local *Devel::Cover::_report = sub { die "Badness happened!" }; | ||
exec "echo We want to be able to see this."; | ||
} |