Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): format coverage summary as a table



details:   https://anonhg.NetBSD.org/src/rev/8b4eb7a6431c
branches:  trunk
changeset: 957553:8b4eb7a6431c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Dec 03 18:43:02 2020 +0000

description:
make(1): format coverage summary as a table

This is only used interactively, not in the official builds, therefore
the additional dependency on Perl doesn't matter.  The same result could
have been achieved in any other programming language, but probably not
as concisely.

diffstat:

 usr.bin/make/Makefile |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 87a3a4da95b7 -r 8b4eb7a6431c usr.bin/make/Makefile
--- a/usr.bin/make/Makefile     Thu Dec 03 10:23:45 2020 +0000
+++ b/usr.bin/make/Makefile     Thu Dec 03 18:43:02 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.106 2020/10/25 13:25:19 rillig Exp $
+#      $NetBSD: Makefile,v 1.107 2020/12/03 18:43:02 rillig Exp $
 #      @(#)Makefile    5.2 (Berkeley) 12/28/90
 
 PROG=  make
@@ -43,6 +43,13 @@
 .if ${USE_COVERAGE} == "yes"
 GCOV?=         gcov
 COPTS+=                --coverage -O0 -ggdb
+GCOV_PERL=     if (/^File '(\S+)'/) {
+GCOV_PERL+=            $$file = $$1; $$func = "";
+GCOV_PERL+=    } elsif (/^Function '(\S+)'/) {
+GCOV_PERL+=            $$func = $$1;
+GCOV_PERL+=    } elsif (/^Lines executed:(\d+\.\d+)% of (\d+)/) {
+GCOV_PERL+=            printf("%6.2f  %5d   %s%s\n", $$1, $$2, $$file, $$func);
+GCOV_PERL+=    }
 LDADD+=                --coverage
 .endif
 CLEANFILES+=   *.gcda *.gcno *.gcov
@@ -170,8 +177,8 @@
        cd ${.CURDIR}/unit-tests \
        && MAKEFLAGS= ${TEST_MAKE} -r -m / TEST_MAKE=${TEST_MAKE} ${TESTS:DTESTS=${TESTS:Q}} ${.TARGET}
 .if ${USE_COVERAGE} == yes
-       ${GCOV} ${GCOV_OPTS} ${SRCS}
-       sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov
+       @${GCOV} ${GCOV_OPTS} ${SRCS} | perl -ne ${GCOV_PERL:Q} | sort -nr
+       @sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov
 .endif
 
 accept sync-mi: .MAKE



Home | Main Index | Thread Index | Old Index