From 8dcb3372f43444dd08095ec55c0e82bf84974719 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 25 Apr 2014 03:16:38 +0200 Subject: build: Inject a Perl coverage index entry into the lcov report Add correct summary values, create a percentage bar, and remove the lcov-epilog template, which was being inserted in every and each generated lcov html file, not just the indices. The injection should be considered fragile, as it depends on the input report not changing its structure. But this is no worse than using the local prolog and epilog html templates. --- doc/lcov-epilog | 8 ------- doc/lcov-inject | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 8 deletions(-) delete mode 100644 doc/lcov-epilog create mode 100755 doc/lcov-inject (limited to 'doc') diff --git a/doc/lcov-epilog b/doc/lcov-epilog deleted file mode 100644 index 8bc660c1a..000000000 --- a/doc/lcov-epilog +++ /dev/null @@ -1,8 +0,0 @@ - - - - -
scripts
-
- - diff --git a/doc/lcov-inject b/doc/lcov-inject new file mode 100755 index 000000000..0875bd29c --- /dev/null +++ b/doc/lcov-inject @@ -0,0 +1,70 @@ +#!/usr/bin/perl +# +# lcov-inject +# +# Copyright © 2014 Guillem Jover +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +use strict; +use warnings; + +use Cwd; +use Devel::Cover::DB; + +my $dir = $ARGV[0] // 'scripts'; +my $cwd = cwd(); + +chdir $dir or die "cannot switch to $dir\n"; + +my $db = Devel::Cover::DB->new(db => 'cover_db'); +$db = $db->merge_runs(); +$db->calculate_summary(map { $_ => 1 } $db->collected()); + +chdir $cwd or die "cannot switch to $cwd\n"; + +my $s = $db->{summary}{Total}; + +my $tmpl = sprintf ' + %s + + + +
+ %.1f%.1f +
+ + %.1f %% + %d / %d + %.1f %% + %d / %d + %.1f %% + %d / %d + + +', "$dir/coverage.html", $dir, + $s->{total}{percentage}, $s->{total}{percentage}, + 100 - $s->{total}{percentage}, $s->{total}{percentage}, + $s->{total}{percentage}, $s->{total}{covered}, $s->{total}{total}, + $s->{subroutine}{percentage}, + $s->{subroutine}{covered}, $s->{subroutine}{total}, + $s->{branch}{percentage}, $s->{branch}{covered}, $s->{branch}{total}; + +while (<>) { + s/^(.*.*)$/$tmpl$1/; + print; +} + +1; -- cgit v1.2.3