-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Update to gcovr=6.0 and remove bundled-version support (#2629)
Addresses and closes Issue #1211 ---------------------------------- The supposed problem was "Parallel processing of gcov data. ([#%s592](gcovr/gcovr#592))" in gcov 5.1. This was already fixed in 5.2. We need to add `--exclude-noncode-lines` due to a breaking change in gcovr 6.0, otherwise our coverage would change a lot (-0.33%): New [--exclude-noncode-lines](https://gcovr.com/en/stable/manpage.html#cmdoption-gcovr-exclude-noncode-lines) to exclude noncode lines. Noncode lines are not excluded by default anymore. ([#%s704](gcovr/gcovr#704), [#%s705](gcovr/gcovr#705)) Closes #1211 Update the gcovr-call ---------------------- - remove use of local bundled version (files were removed some years ago) - remove outdated exclude of folder `/Legacy/` - remind user to update gcovr to at least `v5.0` - assert if `v5.1` is used - black
- Loading branch information
Showing
3 changed files
with
88 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
import os | ||
import subprocess | ||
import argparse | ||
import multiprocessing as mp | ||
import re | ||
|
||
|
||
if not os.path.exists("CMakeCache.txt"): | ||
print("Not in CMake build dir. Not executing") | ||
sys.exit(1) | ||
|
||
|
||
def check_output(*args, **kwargs): | ||
p = subprocess.Popen( | ||
*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs | ||
) | ||
p.wait() | ||
stdout, stderr = p.communicate() | ||
stdout = stdout.decode("utf-8") | ||
return (p.returncode, stdout.strip()) | ||
|
||
|
||
# call helper function | ||
def call(cmd): | ||
print(" ".join(cmd)) | ||
try: | ||
subprocess.check_call(cmd) | ||
except subprocess.CalledProcessError as e: | ||
print("Failed, output: ", e.output) | ||
raise e | ||
|
||
|
||
p = argparse.ArgumentParser() | ||
p.add_argument("--gcov", default=check_output(["which", "gcov"])[1]) | ||
args = p.parse_args() | ||
|
||
ret, gcovr_exe = check_output(["which", "gcovr"]) | ||
assert ret == 0, "gcovr not installed. Use 'pip install gcovr'." | ||
|
||
ret, gcovr_version_text = check_output(["gcovr", "--version"]) | ||
gcovr_version = tuple( | ||
map(int, re.match("gcovr (\d+\.\d+)", gcovr_version_text).group(1).split(".")) | ||
) | ||
|
||
extra_flags = [] | ||
|
||
print(f"Found gcovr version {gcovr_version[0]}.{gcovr_version[1]}") | ||
if gcovr_version < (5,): | ||
print("Consider upgrading to a newer gcovr version.") | ||
elif gcovr_version == (5, 1): | ||
assert False and "Version 5.1 does not support parallel processing of gcov data" | ||
elif gcovr_version >= (6,): | ||
extra_flags += ["--exclude-noncode-lines"] | ||
|
||
gcovr = [gcovr_exe] | ||
|
||
script_dir = os.path.dirname(__file__) | ||
source_dir = os.path.abspath(os.path.join(script_dir, "..")) | ||
coverage_dir = os.path.abspath("coverage") | ||
|
||
if not os.path.exists(coverage_dir): | ||
os.makedirs(coverage_dir) | ||
|
||
excludes = ["-e", "../Tests/", "-e", ".*json\.hpp"] | ||
|
||
# create the html report | ||
call( | ||
gcovr | ||
+ ["-r", source_dir] | ||
+ ["--gcov-executable", args.gcov] | ||
+ ["-j", str(mp.cpu_count())] | ||
+ excludes | ||
+ extra_flags | ||
+ ["--xml", "-o", "coverage/cov.xml"] | ||
) | ||
|
||
call( | ||
gcovr | ||
+ ["-r", source_dir] | ||
+ ["-j", str(mp.cpu_count())] | ||
+ ["--gcov-executable", args.gcov] | ||
+ excludes | ||
+ extra_flags | ||
) |