From 6134be699c724d4da6883d9bd002117aa2fa51a3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 14 Apr 2019 12:02:05 +0200 Subject: Print test coverage summary --- extras/autowaf.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'extras') diff --git a/extras/autowaf.py b/extras/autowaf.py index dcc8b25..f31c594 100644 --- a/extras/autowaf.py +++ b/extras/autowaf.py @@ -1029,7 +1029,7 @@ class TestContext(Build.BuildContext): self.gen_coverage() if os.path.exists('coverage/index.html'): - self.log_good('COVERAGE', '', + self.log_good('REPORT', '', os.path.abspath('coverage/index.html')) successes = scope.n_total - scope.n_failed @@ -1101,6 +1101,19 @@ class TestContext(Build.BuildContext): 'cov.lcov'], stdout=log, stderr=log) + summary = subprocess.check_output( + ['lcov', '--summary', + '--rc', 'lcov_branch_coverage=1', + 'cov.lcov'], + stderr=subprocess.STDOUT).decode('ascii') + + import re + lines = re.search('lines\.*: (.*)%.*', summary).group(1) + functions = re.search('functions\.*: (.*)%.*', summary).group(1) + branches = re.search('branches\.*: (.*)%.*', summary).group(1) + self.log_good('COVERAGE', '%s%% lines, %s%% functions, %s%% branches', + lines, functions, branches) + except Exception: Logs.warn('Failed to run lcov to generate coverage report') -- cgit v1.2.1