@@ -54,15 +54,59 @@ elif [[ "$coverage_action" == "collect" ]] || [[ "$coverage_action" == "upload"
54
54
GCOV=gcov-${ver}
55
55
fi
56
56
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
59
93
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} "
64
105
fi
65
106
107
+ # Remove extra whitespace
108
+ LCOV_OPTIONS=$( echo ${LCOV_OPTIONS} | xargs echo)
109
+
66
110
rm -rf /tmp/lcov
67
111
cd /tmp
68
112
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"
72
116
73
117
# switch back to the original source code directory
74
118
cd " $BOOST_CI_SRC_FOLDER "
75
- : " ${LCOV_BRANCH_COVERAGE:= 1} " # Set default
76
119
77
120
# 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
79
122
# 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
81
124
82
125
# all.info contains all the coverage info for all projects - limit to ours
83
126
# first we extract the interesting headers for our project then we use that list to extract the right things
84
127
for f in $( for h in include/boost/* ; do echo " $h " ; done | cut -f2- -d/) ; do echo " */$f *" ; done > /tmp/interesting
85
128
echo headers that matter:
86
129
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
88
131
89
132
# dump a summary on the console - helps us identify problems in pathing
90
133
# note this has test file coverage in it - if you do not want to count test
91
134
# files against your coverage numbers then use a .codecov.yml file which
92
135
# must be checked into the default branch (it is not read or used from a
93
136
# pull request)
94
- lcov --rc lcov_branch_coverage= " ${LCOV_BRANCH_COVERAGE} " --list coverage.info
137
+ lcov ${LCOV_OPTIONS} --list coverage.info
95
138
96
139
if [[ " $coverage_action " == " upload" ]] && [[ " $BOOST_CI_CODECOV_IO_UPLOAD " != " skip" ]]; then
97
140
#
0 commit comments