Skip to content

Commit 79fab52

Browse files
authored
update to lcov-1.15 and update to less brittle python script (#325)
1 parent 96bfcd6 commit 79fab52

File tree

3 files changed

+70
-48
lines changed

3 files changed

+70
-48
lines changed

.github/workflows/cov.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
paths-ignore:
99
- 'doc/**'
1010
- 'examples/**'
11-
- 'tools/**'
1211
- '*.md'
1312

1413
env:
@@ -55,7 +54,7 @@ jobs:
5554
- name: Process coverage data
5655
run: |
5756
cd libs/histogram
58-
GCOV=gcov-8 tools/cov.sh
57+
GCOV=gcov-8 tools/cov.py
5958
6059
- uses: coverallsapp/[email protected]
6160
with:

tools/cov.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright Hans Dembinski 2018-2019
4+
# Distributed under the Boost Software License, Version 1.0.
5+
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
6+
7+
# script must be executed in project root folder
8+
9+
# NOTE: compute coverage with b2 toolset=gcc-8 cxxstd=latest coverage=on test//all
10+
# - computing coverage only works properly with gcc-8 right now
11+
# - gcc-9 and gcc-10 are extremely slow
12+
# - clang-10 works and is fast but misses a lot of unmissable lines
13+
14+
from subprocess import run
15+
from pathlib import Path
16+
import os
17+
import sys
18+
19+
LCOV_VERSION = "1.15"
20+
21+
gcov = os.environ.get("GCOV", "gcov-8")
22+
23+
gcov_version = gcov.split("-")[1] if "-" in gcov else None
24+
gcc_version = f"gcc-{gcov_version}" if gcov_version else "gcc"
25+
26+
lcov_dir = Path("tools") / f"lcov-{LCOV_VERSION}"
27+
28+
if not lcov_dir.exists():
29+
url = (
30+
"https://github.com/linux-test-project/lcov/releases/download/"
31+
+ f"v{LCOV_VERSION}/lcov-{LCOV_VERSION}.tar.gz"
32+
)
33+
run(f"curl -L {url} | tar zxf -", shell=True, cwd="tools")
34+
35+
# --rc lcov_branch_coverage=1 doesn't work on travis
36+
lcov = [
37+
f"{lcov_dir}/bin/lcov",
38+
f"--gcov-tool={gcov}",
39+
"--output-file",
40+
"coverage.info",
41+
]
42+
# get all directories with gcda files that match the gcov version
43+
cwd = Path().absolute()
44+
lcov_collect = lcov + ["--base-directory", cwd, "--capture"]
45+
for p in Path("../../bin.v2/libs/histogram/test").rglob("**/*.gcda"):
46+
if gcc_version not in str(p):
47+
continue
48+
lcov_collect.append("--directory")
49+
lcov_collect.append(p.parent)
50+
run(lcov_collect)
51+
52+
# remove uninteresting entries
53+
run(lcov + ["--extract", "coverage.info", "*/boost/histogram/*"])
54+
55+
args = sys.argv[1:]
56+
if args:
57+
# upload if token is passed as argument, you need to install cpp-coveralls
58+
run(["cpp-coveralls", "-l", "coverage.info", "-r", "../..", "-n", "-t", args[0]])
59+
else:
60+
# otherwise generate html report
61+
run(
62+
[
63+
f"{lcov_dir}/bin/genhtml",
64+
"coverage.info",
65+
"--demangle-cpp",
66+
"-o",
67+
"coverage-report",
68+
]
69+
)

tools/cov.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)