From da017702613d718ac69ae213ee91358566f7b622 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 27 Feb 2018 21:41:48 +0100 Subject: Fix coverage-xml and coverage-text targets for gcovr >= 3.1 In gcovr 3.1 the -r/--rootdir argument changed meaning causing reports generated with gcovr 3.1 to not find the source files and look for *.gcda in the whole source tree rather than the build dir. So, detect gcovr version and if 3.1 give build_root to -r instead of source_root. --- mesonbuild/scripts/coverage.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'mesonbuild/scripts') diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py index 47f4cda29..4746134e0 100644 --- a/mesonbuild/scripts/coverage.py +++ b/mesonbuild/scripts/coverage.py @@ -17,15 +17,20 @@ from mesonbuild import environment import sys, os, subprocess, pathlib def coverage(source_root, build_root, log_dir): - (gcovr_exe, lcov_exe, genhtml_exe) = environment.find_coverage_tools() + (gcovr_exe, gcovr_3_1, lcov_exe, genhtml_exe) = environment.find_coverage_tools() if gcovr_exe: + # gcovr >= 3.1 interprets rootdir differently + if gcovr_3_1: + rootdir = build_root + else: + rootdir = source_root subprocess.check_call([gcovr_exe, '-x', - '-r', source_root, + '-r', rootdir, '-o', os.path.join(log_dir, 'coverage.xml'), ]) subprocess.check_call([gcovr_exe, - '-r', source_root, + '-r', rootdir, '-o', os.path.join(log_dir, 'coverage.txt'), ]) if lcov_exe and genhtml_exe: -- cgit v1.2.3