Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-Cover CPAN distribution.

Report information
The Basics
Id: 61515
Status: resolved
Priority: 0/
Queue: Devel-Cover

People
Owner: Nobody in particular
Requestors: o.trosien [...] epages.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments
0001-Return-to-starting-directory-when-_report-finishes.patch



Subject: Cover.pm messes with cwd
Download (untitled) / with headers
text/plain 258b
Devel::Cover should not alter the current working directory (Cover.pm line 298), as it causes tests to behave differently or fail. (e.g. as they rely on being called from the t-directory) If you REALLY need to chdir, there's File::chdir. Regards, Oliver
Download (untitled) / with headers
text/plain 486b
On Tue Sep 21 05:28:48 2010, o.trosien wrote: Show quoted text
> Devel::Cover should not alter the current working directory (Cover.pm > line 298), as it causes tests to behave differently or fail. (e.g. as > they rely on being called from the t-directory) > > If you REALLY need to chdir, there's File::chdir.
This bug throws our test code into deadlocks. We do alot of: fork() chdir("/some/path"); exec("./relative"); Simple patch that just returns to the starting directory in _report() attached.
Subject: 0001-Return-to-starting-directory-when-_report-finishes.patch
From b80aed963e0058022e88c67844af70eee61b96d2 Mon Sep 17 00:00:00 2001 From: John Lightsey <jd@cpanel.net> Date: Fri, 16 Sep 2011 14:13:18 -0500 Subject: [PATCH] Return to starting directory when _report() finishes. RT# 61515: The _report() function was changing the current directory without returning to the original starting directory. This caused exec() to unepectedly fail when the directory changed. --- lib/Devel/Cover.pm | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Devel/Cover.pm b/lib/Devel/Cover.pm index 9107ac0..ab56f18 100755 --- a/lib/Devel/Cover.pm +++ b/lib/Devel/Cover.pm @@ -656,12 +656,14 @@ sub _report "did you require instead of use Devel::Cover?\n" unless defined $Dir; - chdir $Dir or die __PACKAGE__ . ": Can't chdir $Dir: $!\n"; my @collected = get_coverage(); return unless @collected; set_coverage("none") unless $Self_cover; + my $starting_dir = $1 if Cwd::getcwd() =~ /(.*)/; + chdir $Dir or die __PACKAGE__ . ": Can't chdir $Dir: $!\n"; + $Run{collected} = \@collected; $Structure = Devel::Cover::DB::Structure->new(base => $DB); $Structure->read_all; @@ -738,10 +740,12 @@ sub _report $Digests->write; $cover->print_summary if $Summary && !$Silent; - return if !$Self_cover || $Self_cover_run; + if ( $Self_cover && !$Self_cover_run) { - $cover->delete; - delete $Run{vec}; + $cover->delete; + delete $Run{vec}; + } + chdir $starting_dir; } sub add_subroutine_cover -- 1.7.5
+1
Download (untitled) / with headers
text/plain 165b
Thanks very much to everyone involved for the report, feedback and patch, which I have now applied as 814a786 and which will be in the next release. Thanks again,


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.