4 use ExtUtils::Manifest 'maniread';
12 GetOptions("t|test=s" => \@tests,
18 my $make = $Config{make};
19 # if there's a way to make with profiling for a recursive build like
20 # Imager I don't see how
25 run("perl Makefile.PL --coverage @ARGV")
26 and die "Makefile.PL failed\n";
27 run("$make $make_opts 'OTHERLDFLAGS=-ftest-coverage -fprofile-arcs'")
28 and die "build failed\n";
31 local $ENV{DEVEL_COVER_OPTIONS} = "-db," . getcwd() . "/cover_db,-coverage,statement,branch,condition,subroutine";
32 my $makecmd = "$make test TEST_VERBOSE=1";
33 $makecmd .= " HARNESS_PERL_SWITCHES=-MDevel::Cover" unless $nodc;
35 $makecmd .= " TEST_FILES='@tests'";
38 and die "Test failed\n";
42 my $mani = maniread();
45 for my $filename (keys %$mani) {
46 next unless $filename =~ /\.(xs|c|im)$/;
47 (my $gcda = $filename) =~ s/\.\w+$/.gcda/;
49 if ($filename =~ m!^(\w+)/(\w+\.\w+)$!) {
50 push @{$paths{$1}}, $2;
53 push @{$paths{''}}, $filename;
55 if ($filename =~ s/\.(xs|im)$/.c/) {
56 if ($filename =~ m!^(\w+)/(\w+\.\w+)$!) {
57 push @{$paths{$1}}, $2;
60 push @{$paths{''}}, $filename;
65 for my $path (keys %paths) {
67 run("cd $path ; gcov -abc @{$paths{$path}} ; cd ..");
70 run("gcov -abc @{$paths{$path}}");
72 my $dir = $path ? $path : '.';
73 for my $file (@{$paths{$path}}) {
74 run("gcov2perl $dir/$file.gcov");
78 my @dbs = "cover_db", map "$_/cover_db", grep $_, keys %paths;
80 run("cover -nogcov -ignore_re '^t/'");
85 print "Running: $cmd\n" if $verbose;