Skip to content

Commit 6d18824

Browse files
committed
Split coverage scripts into 2
1 parent 9fe1e8f commit 6d18824

2 files changed

Lines changed: 32 additions & 25 deletions

File tree

tools/ci/collectCoverageData.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
EXCLUSIONS=("$@")
6+
7+
# Install lcov if required
8+
LCOV_VERSION="1.15"
9+
if [[ ! "$(lcov --version 2> /dev/null || true)" =~ "version ${LCOV_VERSION}" ]]; then
10+
LCOV_ROOT="/tmp/lcov"
11+
LCOV_URL="https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz"
12+
mkdir -p "${LCOV_ROOT}"
13+
wget --quiet -O - "${LCOV_URL}" | tar --strip-components=1 -xz -C "${LCOV_ROOT}"
14+
export PATH="${LCOV_ROOT}/bin:${PATH}"
15+
fi
16+
17+
# Information
18+
"${GCOV}" --version
19+
lcov --version || true
20+
21+
# capture coverage info
22+
lcov --gcov-tool "${GCOV}" --directory build --capture --output-file coverage.info --rc lcov_branch_coverage=1 > /dev/null
23+
# Remove everything from /usr (unrelated), external folder (3rd party data), test code
24+
lcov --remove coverage.info '/usr/*' '*/.cache/*' --output-file coverage.info > /dev/null
25+
for excl in "${EXCLUSIONS[@]}"; do
26+
lcov --remove coverage.info "${excl}" --output-file coverage.info > /dev/null
27+
done
28+
29+
# Debug output
30+
lcov --list coverage.info

tools/ci/uploadCoverageData.sh

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,9 @@
22

33
set -euo pipefail
44

5-
EXCLUSIONS=("$@")
6-
7-
# Install lcov if required
8-
LCOV_VERSION="1.15"
9-
if [[ ! "$(lcov --version 2> /dev/null || true)" =~ "version ${LCOV_VERSION}" ]]; then
10-
LCOV_ROOT="/tmp/lcov"
11-
LCOV_URL="https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz"
12-
mkdir "${LCOV_ROOT}"
13-
wget --quiet -O - "${LCOV_URL}" | tar --strip-components=1 -xz -C "${LCOV_ROOT}"
14-
export PATH="${LCOV_ROOT}/bin:${PATH}"
5+
if ! [ -f coverage.info ]; then
6+
"$(basename "$0")/collectCoverageData.sh" "$@"
157
fi
168

17-
# Information
18-
"${GCOV}" --version
19-
lcov --version || true
20-
21-
# capture coverage info
22-
lcov --gcov-tool "${GCOV}" --directory build --capture --output-file coverage.info --rc lcov_branch_coverage=1 > /dev/null
23-
# Remove everything from /usr (unrelated), external folder (3rd party data), test code
24-
lcov --remove coverage.info '/usr/*' '*/.cache/*' --output-file coverage.info > /dev/null
25-
for excl in "${EXCLUSIONS[@]}"; do
26-
lcov --remove coverage.info "${excl}" --output-file coverage.info > /dev/null
27-
done
28-
29-
# Debug output
30-
lcov --list coverage.info
31-
329
# Coverage.io
3310
bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports"

0 commit comments

Comments
 (0)