4 use ExtUtils::Manifest 'maniread';
13 GetOptions("t|test=s" => \@tests,
20 my $do_build = !$regen_only;
22 my $make = $Config{make};
23 # if there's a way to make with profiling for a recursive build like
24 # Imager I don't see how
29 run("perl Makefile.PL --coverage @ARGV")
30 and die "Makefile.PL failed\n";
31 run("$make $make_opts 'OTHERLDFLAGS=-ftest-coverage -fprofile-arcs'")
32 and die "build failed\n";
35 local $ENV{DEVEL_COVER_OPTIONS} = "-db," . getcwd() . "/cover_db,-coverage,statement,branch,condition,subroutine";
36 my $makecmd = "$make test";
37 $makecmd .= " TEST_VERBOSE=1" if $verbose;
38 $makecmd .= " HARNESS_PERL_SWITCHES=-MDevel::Cover" unless $nodc;
40 $makecmd .= " TEST_FILES='@tests'";
43 and die "Test failed\n";
48 my $mani = maniread();
51 for my $filename (keys %$mani) {
52 next unless $filename =~ /\.(xs|c|im)$/;
53 (my $gcda = $filename) =~ s/\.\w+$/.gcda/;
55 if ($filename =~ m!^(\w+)/(\w+\.\w+)$!) {
56 push @{$paths{$1}}, $2;
59 push @{$paths{''}}, $filename;
61 if ($filename =~ s/\.(xs|im)$/.c/) {
62 if ($filename =~ m!^(\w+)/(\w+\.\w+)$!) {
63 push @{$paths{$1}}, $2;
66 push @{$paths{''}}, $filename;
71 for my $path (keys %paths) {
73 run("cd $path ; gcov -abc @{$paths{$path}} ; cd ..");
76 run("gcov -abc @{$paths{$path}}");
78 my $dir = $path ? $path : '.';
79 for my $file (@{$paths{$path}}) {
80 run("gcov2perl $dir/$file.gcov");
84 my @dbs = "cover_db", map "$_/cover_db", grep $_, keys %paths;
86 run("cover -nogcov -ignore_re '^t/'");
91 print "Running: $cmd\n" if $verbose;
97 imcover.perl - perform C and perl coverage testing for Imager
101 perl imcover.perl [-m=...][-t=...][-n][-v][-r] -- ... Makefile.PL options
105 Builds Imager with the C< -ftest-coverage -fprofile-arcs > gcc options
106 and then runs perl's tests.