]> git.imager.perl.org - imager.git/blame - imcover.perl
make it so we can release sub-dists from the Imager git tree
[imager.git] / imcover.perl
CommitLineData
1ef586b1
TC
1#!perl -w
2use strict;
3use Config;
4use ExtUtils::Manifest 'maniread';
86c50c46 5use Cwd;
1ef586b1
TC
6
7my $make = $Config{make};
8# if there's a way to make with profiling for a recursive build like
9# Imager I don't see how
10if (-f 'Makefile') {
11 system "$make clean";
12}
13system "cover -delete";
14system "perl Makefile.PL --coverage"
15 and die;
16system "$make 'OTHERLDFLAGS=-ftest-coverage -fprofile-arcs'"
17 and die;
18
86c50c46
TC
19{
20 local $ENV{DEVEL_COVER_OPTIONS} = "-db," . getcwd() . "/cover_db";
21 system "$make test TEST_VERBOSE=1 HARNESS_PERL_SWITCHES=-MDevel::Cover";
22}
1ef586b1
TC
23
24# build gcov files
25my $mani = maniread();
26# split by directory
27my %paths;
28for my $filename (keys %$mani) {
29 next unless $filename =~ /\.(xs|c|im)$/;
30 if ($filename =~ m!^(\w+)/(\w+\.\w+)$!) {
31 push @{$paths{$1}}, $2;
32 }
33 else {
34 push @{$paths{''}}, $filename;
35 }
36}
37
38for my $path (keys %paths) {
39 if ($path) {
40 system "cd $path ; gcov @{$paths{$path}} ; cd ..";
41 }
42 else {
43 system "gcov @{$paths{$path}}";
44 }
45 my $dir = $path ? $path : '.';
46 for my $file (@{$paths{$path}}) {
47 system "gcov2perl $dir/$file.gcov";
48 }
49}
50
51my @dbs = "cover_db", map "$_/cover_db", grep $_, keys %paths;
86c50c46 52system "cover -ignore_re '^t/'";
1ef586b1 53