4 use ExtUtils::Manifest 'maniread';
11 GetOptions("t|test=s" => \@tests,
16 my $make = $Config{make};
17 # if there's a way to make with profiling for a recursive build like
18 # Imager I don't see how
23 run("perl Makefile.PL --coverage @ARGV")
25 run("$make 'OTHERLDFLAGS=-ftest-coverage -fprofile-arcs'")
29 local $ENV{DEVEL_COVER_OPTIONS} = "-db," . getcwd() . "/cover_db,-coverage,statement,branch,condition,subroutine";
30 my $makecmd = "$make test TEST_VERBOSE=1";
31 $makecmd .= " HARNESS_PERL_SWITCHES=-MDevel::Cover" unless $nodc;
33 $makecmd .= " TEST_FILES='@tests'";
39 my $mani = maniread();
42 for my $filename (keys %$mani) {
43 next unless $filename =~ /\.(xs|c|im)$/;
44 (my $gcda = $filename) =~ s/\.\w+$/.gcda/;
46 if ($filename =~ m!^(\w+)/(\w+\.\w+)$!) {
47 push @{$paths{$1}}, $2;
50 push @{$paths{''}}, $filename;
54 for my $path (keys %paths) {
56 run("cd $path ; gcov -abc @{$paths{$path}} ; cd ..");
59 run("gcov -abc @{$paths{$path}}");
61 my $dir = $path ? $path : '.';
62 for my $file (@{$paths{$path}}) {
63 run("gcov2perl $dir/$file.gcov");
67 my @dbs = "cover_db", map "$_/cover_db", grep $_, keys %paths;
69 run("cover -nogcov -ignore_re '^t/'");
74 print "Running: $cmd\n" if $verbose;