aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorRichard Kjerstadius <kjerstadius@gmail.com>2019-04-24 11:28:27 +0200
committerRichard Kjerstadius <kjerstadius@gmail.com>2019-04-24 20:05:21 +0200
commit48ee6a6148190cda71ab69f4417e2df0cc77596b (patch)
tree643bebd05e28b826128d65751085b35f6e550481 /mesonbuild/scripts
parentadd821db64b3c1fd7568736aaa67de53ad382eb4 (diff)
downloadmeson-48ee6a6148190cda71ab69f4417e2df0cc77596b.zip
meson-48ee6a6148190cda71ab69f4417e2df0cc77596b.tar.gz
meson-48ee6a6148190cda71ab69f4417e2df0cc77596b.tar.bz2
Add gcovr 4.2 support
The out-of-source build syntax for gcovr 4.2 is different compared to previous versions and therefore an update was needed. In researching the most appropriate solution it was found that any gcovr version older than 3.3 always resulted in 0% coverage. Because of this, rather than adding an additional layer of logic, some already existing logic was modified to ensure correct syntax for the new version, while versions older than 3.3 are flagged as not supported. Closes mesonbuild#5089.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/coverage.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py
index 0e203f9..4bd41fe 100644
--- a/mesonbuild/scripts/coverage.py
+++ b/mesonbuild/scripts/coverage.py
@@ -22,35 +22,33 @@ def coverage(outputs, source_root, subproject_root, build_root, log_dir):
(gcovr_exe, gcovr_new_rootdir, lcov_exe, genhtml_exe) = environment.find_coverage_tools()
- # gcovr >= 3.1 interprets rootdir differently
+ # gcovr >= 4.2 requires a different syntax for out of source builds
if gcovr_new_rootdir:
- gcovr_rootdir = build_root
+ gcovr_base_cmd = [gcovr_exe, '-r', source_root, build_root]
else:
- gcovr_rootdir = source_root
+ gcovr_base_cmd = [gcovr_exe, '-r', build_root]
if not outputs or 'xml' in outputs:
if gcovr_exe:
- subprocess.check_call([gcovr_exe,
- '-x',
- '-r', gcovr_rootdir,
+ subprocess.check_call(gcovr_base_cmd +
+ ['-x',
'-e', subproject_root,
'-o', os.path.join(log_dir, 'coverage.xml'),
])
outfiles.append(('Xml', pathlib.Path(log_dir, 'coverage.xml')))
elif outputs:
- print('gcovr needed to generate Xml coverage report')
+ print('gcovr >= 3.3 needed to generate Xml coverage report')
exitcode = 1
if not outputs or 'text' in outputs:
if gcovr_exe:
- subprocess.check_call([gcovr_exe,
- '-r', gcovr_rootdir,
- '-e', subproject_root,
+ subprocess.check_call(gcovr_base_cmd +
+ ['-e', subproject_root,
'-o', os.path.join(log_dir, 'coverage.txt'),
])
outfiles.append(('Text', pathlib.Path(log_dir, 'coverage.txt')))
elif outputs:
- print('gcovr needed to generate text coverage report')
+ print('gcovr >= 3.3 needed to generate text coverage report')
exitcode = 1
if not outputs or 'html' in outputs:
@@ -101,21 +99,20 @@ def coverage(outputs, source_root, subproject_root, build_root, log_dir):
'--branch-coverage',
covinfo])
outfiles.append(('Html', pathlib.Path(htmloutdir, 'index.html')))
- elif gcovr_exe and gcovr_new_rootdir:
+ elif gcovr_exe:
htmloutdir = os.path.join(log_dir, 'coveragereport')
if not os.path.isdir(htmloutdir):
os.mkdir(htmloutdir)
- subprocess.check_call([gcovr_exe,
- '--html',
+ subprocess.check_call(gcovr_base_cmd +
+ ['--html',
'--html-details',
'--print-summary',
- '-r', build_root,
'-e', subproject_root,
'-o', os.path.join(htmloutdir, 'index.html'),
])
outfiles.append(('Html', pathlib.Path(htmloutdir, 'index.html')))
elif outputs:
- print('lcov/genhtml or gcovr >= 3.2 needed to generate Html coverage report')
+ print('lcov/genhtml or gcovr >= 3.3 needed to generate Html coverage report')
exitcode = 1
if not outputs and not outfiles: