diff options
author | Henk van der Laan <opensource@henkvdlaan.com> | 2018-02-05 19:48:30 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-02-08 00:39:37 +0200 |
commit | 0e07f1a8963c75b57bbe445821c7291f81d1e10b (patch) | |
tree | 5d785d9cc8e39fe80e2716a7f5ccbc28c4b4ed41 /mesonbuild/scripts/coverage.py | |
parent | 7bfcf68777f5bee3cab95685acf3c4177f6b6498 (diff) | |
download | meson-0e07f1a8963c75b57bbe445821c7291f81d1e10b.zip meson-0e07f1a8963c75b57bbe445821c7291f81d1e10b.tar.gz meson-0e07f1a8963c75b57bbe445821c7291f81d1e10b.tar.bz2 |
Remove all files outside the source directory from the coverage report
Cuurently, a set of directories is filtered out from the output based on
the location of system includes on most common linux distro's. This
commit does away with the blacklist and implements a whitelist approach:
only the files inside the source root are shown.
Diffstat (limited to 'mesonbuild/scripts/coverage.py')
-rw-r--r-- | mesonbuild/scripts/coverage.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py index d1fad11..47f4cda 100644 --- a/mesonbuild/scripts/coverage.py +++ b/mesonbuild/scripts/coverage.py @@ -16,11 +16,6 @@ from mesonbuild import environment import sys, os, subprocess, pathlib -def remove_dir_from_trace(lcov_command, covfile, dirname): - tmpfile = covfile + '.tmp' - subprocess.check_call([lcov_command, '--remove', covfile, dirname, '-o', tmpfile]) - os.replace(tmpfile, covfile) - def coverage(source_root, build_root, log_dir): (gcovr_exe, lcov_exe, genhtml_exe) = environment.find_coverage_tools() if gcovr_exe: @@ -38,6 +33,7 @@ def coverage(source_root, build_root, log_dir): covinfo = os.path.join(log_dir, 'coverage.info') initial_tracefile = covinfo + '.initial' run_tracefile = covinfo + '.run' + raw_tracefile = covinfo + '.raw' subprocess.check_call([lcov_exe, '--directory', build_root, '--capture', @@ -55,11 +51,12 @@ def coverage(source_root, build_root, log_dir): subprocess.check_call([lcov_exe, '-a', initial_tracefile, '-a', run_tracefile, - '-o', covinfo]) - remove_dir_from_trace(lcov_exe, covinfo, '/usr/include/*') - remove_dir_from_trace(lcov_exe, covinfo, '/usr/local/include/*') - remove_dir_from_trace(lcov_exe, covinfo, '/usr/src/*') - remove_dir_from_trace(lcov_exe, covinfo, '/usr/lib/llvm-*/include/*') + '-o', raw_tracefile]) + # Remove all directories outside the source_root from the covinfo + subprocess.check_call([lcov_exe, + '--extract', raw_tracefile, + os.path.join(source_root, '*'), + '--output-file', covinfo]) subprocess.check_call([genhtml_exe, '--prefix', build_root, '--output-directory', htmloutdir, |