diff --git a/build/Makefile.am b/build/Makefile.am index 8c902377b..96b39e1ba 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -1 +1,3 @@ SUBDIRS = autotools + +EXTRA_DIST = gen-gcov.pl diff --git a/build/autotools/Makefile.am.gcov b/build/autotools/Makefile.am.gcov index a16edbd76..1e2cb924e 100644 --- a/build/autotools/Makefile.am.gcov +++ b/build/autotools/Makefile.am.gcov @@ -11,7 +11,7 @@ gcov-report.txt: gcov-clean covered=$$((actual - uncovered)); \ total_covered=$$((total_covered + covered)); \ total_actual=$$((total_actual + actual)); \ - echo -e "$$file: \t$$covered / $$actual\t($$((($$covered * 100) / $$actual))%)"; \ + perl $(top_builddir)/build/gen-gcov.pl $$file.gcov; \ fi \ done >> $@; \ cd $(abs_srcdir); \ diff --git a/build/gen-gcov.pl b/build/gen-gcov.pl new file mode 100755 index 000000000..b4b06b1d8 --- /dev/null +++ b/build/gen-gcov.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +our $gcov_file = $ARGV[0] or undef; + +open my $g, '<', $gcov_file + or die("Unable to open '$gcov_file': $!"); + +my ($actual, $covered, $uncovered, $percent) = (0, 0, 0, 0); + +while (<$g>) { + my $report_line = $_; + + chomp($report_line); + + $actual += 1; + $actual -= 1 if $report_line =~ / -:/; + + $uncovered += 1 if $report_line =~ /#####:/; +} + +close($g); + +$covered = $actual - $uncovered; +$percent = int(($covered * 100) / $actual); + +$gcov_file =~ s/^\.\///g; +$gcov_file =~ s/\.gcov$//g; + +my $cover_file = "$gcov_file:"; +my $cover_literal = "$covered / $actual"; +my $cover_percent = "$percent%"; + +format ReportLine = +@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>> @>>>>> +$cover_file, $cover_literal, $cover_percent +. + +$~ = 'ReportLine'; +write; + +0;