Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 72 lines (63 sloc) 1.492 kB
1ef586b simpler creation of coverage reports
Tony Cook authored
1 #!perl -w
2 use strict;
3 use Config;
4 use ExtUtils::Manifest 'maniread';
86c50c4 @tonycoz try to generate all coverage into the one cover_db
authored
5 use Cwd;
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
6 use Getopt::Long;
7
8 my @tests;
9 my $verbose;
10 GetOptions("t|test=s" => \@tests,
11 "v" => \$verbose)
12 or die;
1ef586b simpler creation of coverage reports
Tony Cook authored
13
14 my $make = $Config{make};
15 # if there's a way to make with profiling for a recursive build like
16 # Imager I don't see how
17 if (-f 'Makefile') {
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
18 run("$make clean");
1ef586b simpler creation of coverage reports
Tony Cook authored
19 }
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
20 run("cover -delete");
21 run("perl Makefile.PL --coverage")
1ef586b simpler creation of coverage reports
Tony Cook authored
22 and die;
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
23 run("$make 'OTHERLDFLAGS=-ftest-coverage -fprofile-arcs'")
1ef586b simpler creation of coverage reports
Tony Cook authored
24 and die;
25
86c50c4 @tonycoz try to generate all coverage into the one cover_db
authored
26 {
27 local $ENV{DEVEL_COVER_OPTIONS} = "-db," . getcwd() . "/cover_db";
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
28 my $makecmd = "$make test TEST_VERBOSE=1 HARNESS_PERL_SWITCHES=-MDevel::Cover";
29 if (@tests) {
30 $makecmd .= " TEST_FILES='@tests'";
31 }
32 run($makecmd);
86c50c4 @tonycoz try to generate all coverage into the one cover_db
authored
33 }
1ef586b simpler creation of coverage reports
Tony Cook authored
34
35 # build gcov files
36 my $mani = maniread();
37 # split by directory
38 my %paths;
39 for my $filename (keys %$mani) {
40 next unless $filename =~ /\.(xs|c|im)$/;
41 if ($filename =~ m!^(\w+)/(\w+\.\w+)$!) {
42 push @{$paths{$1}}, $2;
43 }
44 else {
45 push @{$paths{''}}, $filename;
46 }
47 }
48
49 for my $path (keys %paths) {
50 if ($path) {
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
51 run("cd $path ; gcov -abc @{$paths{$path}} ; cd ..");
1ef586b simpler creation of coverage reports
Tony Cook authored
52 }
53 else {
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
54 run("gcov -abc @{$paths{$path}}");
1ef586b simpler creation of coverage reports
Tony Cook authored
55 }
56 my $dir = $path ? $path : '.';
57 for my $file (@{$paths{$path}}) {
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
58 run("gcov2perl $dir/$file.gcov");
1ef586b simpler creation of coverage reports
Tony Cook authored
59 }
60 }
61
62 my @dbs = "cover_db", map "$_/cover_db", grep $_, keys %paths;
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
63 # we already ran gcov
64 run("cover -nogcov -ignore_re '^t/'");
1ef586b simpler creation of coverage reports
Tony Cook authored
65
7fcc2ea @tonycoz allow imcover.perl to specify a subset of tests to run
authored
66 sub run {
67 my $cmd = shift;
68
69 print "Running: $cmd\n" if $verbose;
70 return system $cmd;
71 }
Something went wrong with that request. Please try again.