Exclude subprojects when doing coverage

Restore subproject exclusion for the html coverage report that existed
in the ninja backend legacy target.

Also exclude subprojects for the gcovr generated reports.
pull/3242/head
Joel Klinghed 7 years ago
parent 79bb1df04f
commit 8bad2d9827
  1. 2
      mesonbuild/backend/ninjabackend.py
  2. 14
      mesonbuild/scripts/coverage.py

@ -618,6 +618,8 @@ int dummy;
['--internal', 'coverage'] + ['--internal', 'coverage'] +
outputs + outputs +
[self.environment.get_source_dir(), [self.environment.get_source_dir(),
os.path.join(self.environment.get_source_dir(),
self.build.get_subproject_dir()),
self.environment.get_build_dir(), self.environment.get_build_dir(),
self.environment.get_log_dir()]) self.environment.get_log_dir()])

@ -16,7 +16,7 @@ from mesonbuild import environment
import argparse, sys, os, subprocess, pathlib import argparse, sys, os, subprocess, pathlib
def coverage(outputs, source_root, build_root, log_dir): def coverage(outputs, source_root, subproject_root, build_root, log_dir):
outfiles = [] outfiles = []
exitcode = 0 exitcode = 0
@ -33,6 +33,7 @@ def coverage(outputs, source_root, build_root, log_dir):
subprocess.check_call([gcovr_exe, subprocess.check_call([gcovr_exe,
'-x', '-x',
'-r', gcovr_rootdir, '-r', gcovr_rootdir,
'-e', subproject_root,
'-o', os.path.join(log_dir, 'coverage.xml'), '-o', os.path.join(log_dir, 'coverage.xml'),
]) ])
outfiles.append(('Xml', pathlib.Path(log_dir, 'coverage.xml'))) outfiles.append(('Xml', pathlib.Path(log_dir, 'coverage.xml')))
@ -44,6 +45,7 @@ def coverage(outputs, source_root, build_root, log_dir):
if gcovr_exe: if gcovr_exe:
subprocess.check_call([gcovr_exe, subprocess.check_call([gcovr_exe,
'-r', gcovr_rootdir, '-r', gcovr_rootdir,
'-e', subproject_root,
'-o', os.path.join(log_dir, 'coverage.txt'), '-o', os.path.join(log_dir, 'coverage.txt'),
]) ])
outfiles.append(('Text', pathlib.Path(log_dir, 'coverage.txt'))) outfiles.append(('Text', pathlib.Path(log_dir, 'coverage.txt')))
@ -81,6 +83,11 @@ def coverage(outputs, source_root, build_root, log_dir):
'--extract', raw_tracefile, '--extract', raw_tracefile,
os.path.join(source_root, '*'), os.path.join(source_root, '*'),
'--output-file', covinfo]) '--output-file', covinfo])
# Remove all directories inside subproject dir
subprocess.check_call([lcov_exe,
'--remove', covinfo,
os.path.join(subproject_root, '*'),
'--output-file', covinfo])
subprocess.check_call([genhtml_exe, subprocess.check_call([genhtml_exe,
'--prefix', build_root, '--prefix', build_root,
'--output-directory', htmloutdir, '--output-directory', htmloutdir,
@ -96,6 +103,7 @@ def coverage(outputs, source_root, build_root, log_dir):
'--html', '--html',
'--html-details', '--html-details',
'-r', build_root, '-r', build_root,
'-e', subproject_root,
'-o', os.path.join(htmloutdir, 'index.html'), '-o', os.path.join(htmloutdir, 'index.html'),
]) ])
outfiles.append(('Html', pathlib.Path(htmloutdir, 'index.html'))) outfiles.append(('Html', pathlib.Path(htmloutdir, 'index.html')))
@ -126,11 +134,13 @@ def run(args):
parser.add_argument('--html', dest='outputs', action='append_const', parser.add_argument('--html', dest='outputs', action='append_const',
const='html', help='generate Html report') const='html', help='generate Html report')
parser.add_argument('source_root') parser.add_argument('source_root')
parser.add_argument('subproject_root')
parser.add_argument('build_root') parser.add_argument('build_root')
parser.add_argument('log_dir') parser.add_argument('log_dir')
options = parser.parse_args(args) options = parser.parse_args(args)
return coverage(options.outputs, options.source_root, return coverage(options.outputs, options.source_root,
options.build_root, options.log_dir) options.subproject_root, options.build_root,
options.log_dir)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(run(sys.argv[1:])) sys.exit(run(sys.argv[1:]))

Loading…
Cancel
Save