Skip to content

Commit 1afbfef

Browse files
committed
Check if json.gz files exist, not the gcov version.
Different versions of gcov output different types of files; older versions output textual data, newer ones output compressed JSON files (the switch happens in gcov). "llvm-cov gcov" is supposed to be compatible with gcov, but never outputs compressed JSON files. This means the version check will break if gcov is substituted with this tool. Checking for the output files created should avoid this issue, and be a more robust check overall. Fixes #18874
1 parent 70e31da commit 1afbfef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/test/collect_cc_coverage.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ function gcov_coverage() {
155155
# the major version.
156156
gcov_major_version=$("${GCOV}" --version | sed -n -E -e 's/^.*\s([0-9]+)\.[0-9]+\.[0-9]+\s?.*$/\1/p')
157157

158-
# Check the gcov version so we can process the data correctly
159-
if [[ $gcov_major_version -ge 9 ]]; then
160-
# gcov 9 or higher use a JSON based format for their coverage reports.
161-
# The output is generated into multiple files: "$(basename ${gcda}).gcov.json.gz"
158+
# Check the type of output: gcov 9 outputs ompressed JSON files, but
159+
# earlier versions of gcov, and all versions of llvm-cov, do not.
160+
# versions of gcov (and all llvm-cov) versions do not.
161+
if stat --printf='' *.gcov.json.gz > /dev/null 2>&1; then
162162
# Concatenating JSON documents does not yield a valid document, so they are moved individually
163163
mv -- *.gcov.json.gz "$(dirname "$output_file")/$(dirname ${gcno_path})"
164164
else

0 commit comments

Comments
 (0)