Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get the @INC directories from perl itself.

At build time we put the @INC directories in @Devel::Cover::Inc::Inc so that
we will be able to ignore them by default at runtime.  That works well
normally, but sometimes the build environment differs which can result in
default coverage of core modules.

The solution is to shell out to perl and ask it what its @INC is.  Of course
it's not quite that easy.

When the new V module for introspection is in place we can use that instead.

This is a risky commit.
  • Loading branch information...
commit f650a3510bb445b7f1eeeab996fa09162f683a14 1 parent f1f4481
@pjcj authored
Showing with 17 additions and 1 deletion.
  1. +17 −1 lib/Devel/Cover.pm
View
18 lib/Devel/Cover.pm
@@ -105,7 +105,23 @@ BEGIN
($ENV{PERL5OPT} || "") =~ /Devel::Cover/;
*OUT = $ENV{DEVEL_COVER_DEBUG} ? *STDERR : *STDOUT;
- @Inc = @Devel::Cover::Inc::Inc;
+ eval
+ {
+ local %ENV = %ENV;
+ /perl/i and delete $ENV{$_} for keys %ENV;
+ my $inc = `$^X -MData::Dumper -e 'print Dumper \\\@INC'`;
+ my $VAR1;
+ eval $inc;
+ @Inc = @$VAR1;
+ };
+ if ($@)
+ {
+ print STDERR __PACKAGE__, ": Error getting \@INC: $@\n",
+ "Reverting to default value for Inc.\n";
+ @Inc = @Devel::Cover::Inc::Inc;
+ }
+ @Inc = map { -d $_ ? ($_ eq "." ? $_ : Cwd::abs_path($_)) : () } @Inc;
+
@Ignore = ("/Devel/Cover[./]") unless $Self_cover = $ENV{DEVEL_COVER_SELF};
# $^P = 0x004 | 0x010 | 0x100 | 0x200;
# $^P = 0x004 | 0x100 | 0x200;
Please sign in to comment.
Something went wrong with that request. Please try again.