Skip to content

Commit e415c67

Browse files
authored
LCOV_VERSION 2.3 (#263)
1 parent 3f7d309 commit e415c67

File tree

1 file changed

+54
-11
lines changed

1 file changed

+54
-11
lines changed

ci/codecov.sh

+54-11
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,59 @@ elif [[ "$coverage_action" == "collect" ]] || [[ "$coverage_action" == "upload"
5454
GCOV=gcov-${ver}
5555
fi
5656

57-
# install the latest lcov we know works
58-
: "${LCOV_VERSION:=v1.15}"
57+
: "${LCOV_VERSION:=v2.3}" # Set default lcov version to install
58+
59+
: "${LCOV_BRANCH_COVERAGE:=1}" # Set default for branch coverage
60+
61+
: "${LCOV_IGNORE_ERRORS_LEVEL:="standard"}" # Set default error level. See below.
62+
63+
case $LCOV_IGNORE_ERRORS_LEVEL in
64+
off)
65+
# All errors are potentially fatal.
66+
lcov_errors_to_ignore="";;
67+
minimal)
68+
# A suggested minimum even when trying to catch errors.
69+
lcov_errors_to_ignore="unused";;
70+
all)
71+
# ignore all lcov errors
72+
lcov_errors_to_ignore="annotate,branch,callback,category,child,count,corrupt,deprecated,empty,excessive,fork,format,inconsistent,internal,mismatch,missing,negative,package,parallel,path,range,source,unmapped,unsupported,unused,usage,utility,version";;
73+
standard)
74+
# A recommended default.
75+
# The majority of boost libraries should pass.
76+
# Notes about this setting:
77+
# inconsistent - This error indicates that your coverage data is internally inconsistent: it makes two or more mutually exclusive claims.
78+
# mismatch - Incorrect or inconsistent information found in coverage data and/or source code - for example, the source code contains overlapping exclusion directives.
79+
# unused - The include/exclude/erase/substitute/omit pattern did not match any file pathnames.
80+
#
81+
lcov_errors_to_ignore="inconsistent,mismatch,unused";;
82+
*)
83+
echo "The value of LCOV_IGNORE_ERRORS_LEVEL ($LCOV_IGNORE_ERRORS_LEVEL) is not recognized."
84+
echo "Please correct this. Exiting."
85+
exit 1
86+
esac
87+
88+
if [ -n "${lcov_errors_to_ignore}" ]; then
89+
lcov_ignore_errors_flag="--ignore-errors ${lcov_errors_to_ignore}"
90+
else
91+
lcov_ignore_errors_flag=""
92+
fi
5993

60-
if [[ "$LCOV_VERSION" =~ ^v[2-9] ]]; then
61-
sudo apt-get -o Acquire::Retries="${NET_RETRY_COUNT:-3}" -y -q --no-install-suggests --no-install-recommends install libcapture-tiny-perl libdatetime-perl || true
62-
LCOV_OPTIONS="${LCOV_OPTIONS} --ignore-errors unused"
63-
LCOV_OPTIONS=$(echo ${LCOV_OPTIONS} | xargs echo)
94+
# The four LEVELs for error suppression above are meant to cover the most common cases.
95+
# You can still select a fully custom option by using $LCOV_OPTIONS (in which case you may set $LCOV_IGNORE_ERRORS_LEVEL=off).
96+
97+
if [[ "$LCOV_VERSION" =~ ^v1 ]]; then
98+
LCOV_OPTIONS="${LCOV_OPTIONS} --rc lcov_branch_coverage=${LCOV_BRANCH_COVERAGE}"
99+
100+
elif [[ "$LCOV_VERSION" =~ ^v[2-9] ]]; then
101+
sudo apt-get -o Acquire::Retries="${NET_RETRY_COUNT:-3}" -y -q --no-install-suggests --no-install-recommends install \
102+
libcapture-tiny-perl libdatetime-perl libjson-xs-perl || true
103+
# libcpanel-json-xs-perl
104+
LCOV_OPTIONS="${LCOV_OPTIONS} --rc branch_coverage=${LCOV_BRANCH_COVERAGE} ${lcov_ignore_errors_flag}"
64105
fi
65106

107+
# Remove extra whitespace
108+
LCOV_OPTIONS=$(echo ${LCOV_OPTIONS} | xargs echo)
109+
66110
rm -rf /tmp/lcov
67111
cd /tmp
68112
git clone --depth 1 -b "${LCOV_VERSION}" https://github.com/linux-test-project/lcov.git
@@ -72,26 +116,25 @@ elif [[ "$coverage_action" == "collect" ]] || [[ "$coverage_action" == "upload"
72116

73117
# switch back to the original source code directory
74118
cd "$BOOST_CI_SRC_FOLDER"
75-
: "${LCOV_BRANCH_COVERAGE:=1}" # Set default
76119

77120
# coverage files are in ../../b2 from this location
78-
lcov ${LCOV_OPTIONS} --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --gcov-tool="$GCOV" --directory "$BOOST_ROOT" --capture --output-file all.info
121+
lcov ${LCOV_OPTIONS} --gcov-tool="$GCOV" --directory "$BOOST_ROOT" --capture --output-file all.info
79122
# dump a summary on the console
80-
lcov --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --list all.info
123+
lcov ${LCOV_OPTIONS} --list all.info
81124

82125
# all.info contains all the coverage info for all projects - limit to ours
83126
# first we extract the interesting headers for our project then we use that list to extract the right things
84127
for f in $(for h in include/boost/*; do echo "$h"; done | cut -f2- -d/); do echo "*/$f*"; done > /tmp/interesting
85128
echo headers that matter:
86129
cat /tmp/interesting
87-
xargs --verbose -L 999999 -a /tmp/interesting lcov ${LCOV_OPTIONS} --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --extract all.info "*/libs/$SELF/*" --output-file coverage.info
130+
xargs --verbose -L 999999 -a /tmp/interesting lcov ${LCOV_OPTIONS} --extract all.info "*/libs/$SELF/*" --output-file coverage.info
88131

89132
# dump a summary on the console - helps us identify problems in pathing
90133
# note this has test file coverage in it - if you do not want to count test
91134
# files against your coverage numbers then use a .codecov.yml file which
92135
# must be checked into the default branch (it is not read or used from a
93136
# pull request)
94-
lcov --rc lcov_branch_coverage="${LCOV_BRANCH_COVERAGE}" --list coverage.info
137+
lcov ${LCOV_OPTIONS} --list coverage.info
95138

96139
if [[ "$coverage_action" == "upload" ]] && [[ "$BOOST_CI_CODECOV_IO_UPLOAD" != "skip" ]]; then
97140
#

0 commit comments

Comments
 (0)