mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
update to lcov-1.15 and update to less brittle python script (#325)
This commit is contained in:
parent
96bfcd620c
commit
79fab52b32
3
.github/workflows/cov.yml
vendored
3
.github/workflows/cov.yml
vendored
@ -8,7 +8,6 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'doc/**'
|
- 'doc/**'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
- 'tools/**'
|
|
||||||
- '*.md'
|
- '*.md'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@ -55,7 +54,7 @@ jobs:
|
|||||||
- name: Process coverage data
|
- name: Process coverage data
|
||||||
run: |
|
run: |
|
||||||
cd libs/histogram
|
cd libs/histogram
|
||||||
GCOV=gcov-8 tools/cov.sh
|
GCOV=gcov-8 tools/cov.py
|
||||||
|
|
||||||
- uses: coverallsapp/github-action@v1.1.2
|
- uses: coverallsapp/github-action@v1.1.2
|
||||||
with:
|
with:
|
||||||
|
69
tools/cov.py
Executable file
69
tools/cov.py
Executable file
@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright Hans Dembinski 2018-2019
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
# script must be executed in project root folder
|
||||||
|
|
||||||
|
# NOTE: compute coverage with b2 toolset=gcc-8 cxxstd=latest coverage=on test//all
|
||||||
|
# - computing coverage only works properly with gcc-8 right now
|
||||||
|
# - gcc-9 and gcc-10 are extremely slow
|
||||||
|
# - clang-10 works and is fast but misses a lot of unmissable lines
|
||||||
|
|
||||||
|
from subprocess import run
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
LCOV_VERSION = "1.15"
|
||||||
|
|
||||||
|
gcov = os.environ.get("GCOV", "gcov-8")
|
||||||
|
|
||||||
|
gcov_version = gcov.split("-")[1] if "-" in gcov else None
|
||||||
|
gcc_version = f"gcc-{gcov_version}" if gcov_version else "gcc"
|
||||||
|
|
||||||
|
lcov_dir = Path("tools") / f"lcov-{LCOV_VERSION}"
|
||||||
|
|
||||||
|
if not lcov_dir.exists():
|
||||||
|
url = (
|
||||||
|
"https://github.com/linux-test-project/lcov/releases/download/"
|
||||||
|
+ f"v{LCOV_VERSION}/lcov-{LCOV_VERSION}.tar.gz"
|
||||||
|
)
|
||||||
|
run(f"curl -L {url} | tar zxf -", shell=True, cwd="tools")
|
||||||
|
|
||||||
|
# --rc lcov_branch_coverage=1 doesn't work on travis
|
||||||
|
lcov = [
|
||||||
|
f"{lcov_dir}/bin/lcov",
|
||||||
|
f"--gcov-tool={gcov}",
|
||||||
|
"--output-file",
|
||||||
|
"coverage.info",
|
||||||
|
]
|
||||||
|
# get all directories with gcda files that match the gcov version
|
||||||
|
cwd = Path().absolute()
|
||||||
|
lcov_collect = lcov + ["--base-directory", cwd, "--capture"]
|
||||||
|
for p in Path("../../bin.v2/libs/histogram/test").rglob("**/*.gcda"):
|
||||||
|
if gcc_version not in str(p):
|
||||||
|
continue
|
||||||
|
lcov_collect.append("--directory")
|
||||||
|
lcov_collect.append(p.parent)
|
||||||
|
run(lcov_collect)
|
||||||
|
|
||||||
|
# remove uninteresting entries
|
||||||
|
run(lcov + ["--extract", "coverage.info", "*/boost/histogram/*"])
|
||||||
|
|
||||||
|
args = sys.argv[1:]
|
||||||
|
if args:
|
||||||
|
# upload if token is passed as argument, you need to install cpp-coveralls
|
||||||
|
run(["cpp-coveralls", "-l", "coverage.info", "-r", "../..", "-n", "-t", args[0]])
|
||||||
|
else:
|
||||||
|
# otherwise generate html report
|
||||||
|
run(
|
||||||
|
[
|
||||||
|
f"{lcov_dir}/bin/genhtml",
|
||||||
|
"coverage.info",
|
||||||
|
"--demangle-cpp",
|
||||||
|
"-o",
|
||||||
|
"coverage-report",
|
||||||
|
]
|
||||||
|
)
|
46
tools/cov.sh
46
tools/cov.sh
@ -1,46 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# must be executed in project root folder
|
|
||||||
|
|
||||||
# Copyright Hans Dembinski 2018-2019
|
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
|
||||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
|
|
||||||
if [ -z $GCOV ]; then
|
|
||||||
# gcov-10, gcov-9, gcov-7, gcov-6 do not work
|
|
||||||
for i in 8 5; do
|
|
||||||
if test $(which gcov-$i); then
|
|
||||||
GCOV=gcov-$i
|
|
||||||
break;
|
|
||||||
fi;
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
LCOV_VERSION="1.14"
|
|
||||||
LCOV_DIR="tools/lcov-${LCOV_VERSION}"
|
|
||||||
|
|
||||||
if [ ! -e $LCOV_DIR ]; then
|
|
||||||
cd tools
|
|
||||||
curl -L https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz | tar zxf -
|
|
||||||
cd ..
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --rc lcov_branch_coverage=1 doesn't work on travis
|
|
||||||
# LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV} --rc lcov_branch_coverage=1"
|
|
||||||
LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV}"
|
|
||||||
|
|
||||||
# collect raw data
|
|
||||||
$LCOV --base-directory `pwd` \
|
|
||||||
--directory `pwd`/../../bin.v2/libs/histogram/test \
|
|
||||||
--capture --output-file coverage.info
|
|
||||||
|
|
||||||
# remove uninteresting entries
|
|
||||||
$LCOV --extract coverage.info "*/boost/histogram/*" --output-file coverage.info
|
|
||||||
|
|
||||||
if [ $1 ]; then
|
|
||||||
# upload if on CI or when token is passed as argument
|
|
||||||
which cpp-coveralls || echo "Error: you need to install cpp-coveralls"
|
|
||||||
cpp-coveralls -l coverage.info -r ../.. -n -t $1
|
|
||||||
elif [ ! $CI ]; then
|
|
||||||
# otherwise generate html report
|
|
||||||
$LCOV_DIR/bin/genhtml coverage.info --demangle-cpp -o coverage-report
|
|
||||||
fi
|
|
Loading…
x
Reference in New Issue
Block a user