summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-04-25 03:16:38 +0200
committerGuillem Jover <guillem@debian.org>2014-04-26 18:24:45 +0200
commit8dcb3372f43444dd08095ec55c0e82bf84974719 (patch)
treecf7fbe892ebdc8b628465cdae8abc0b2f69b5c6e /doc
parent54c36750fefd670885d161716b08f2cf1a662e61 (diff)
downloaddpkg-8dcb3372f43444dd08095ec55c0e82bf84974719.tar.gz
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.
Diffstat (limited to 'doc')
-rw-r--r--doc/lcov-epilog8
-rwxr-xr-xdoc/lcov-inject70
2 files changed, 70 insertions, 8 deletions
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 @@
- <table width="100%" border=0 cellspacing=0 cellpadding=0>
- <tr>
- <td class="coverFile"><a href="scripts/coverage.html">scripts</a></td>
- </tr>
- </table>
- <br />
-</body>
-</html>
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 <guillem@debian.org>
+#
+# 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 <https://www.gnu.org/licenses/>.
+#
+
+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 '
+ <td class="coverFile"><a href="%s">%s</a></td>
+ <td class="coverBar" align="center">
+ <table border=0 cellspacing=0 cellpadding=1>
+ <tr><td class="coverBarOutline">
+ <img src="ruby.png" width=%.0f height=10 alt="%.1f"><img src="snow.png" width=%.0f height=10 alt="%.1f">
+ </td></tr>
+ </table>
+ </td>
+ <td class="coverPerLo">%.1f&nbsp;%%</td>
+ <td class="coverNumLo">%d / %d</td>
+ <td class="coverPerLo">%.1f&nbsp;%%</td>
+ <td class="coverNumLo">%d / %d</td>
+ <td class="coverPerLo">%.1f&nbsp;%%</td>
+ <td class="coverNumLo">%d / %d</td>
+ </tr>
+ <tr>
+', "$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/^(.*<td .*href="src\/index\.html">.*)$/$tmpl$1/;
+ print;
+}
+
+1;