updated compatible tool arguments

This commit is contained in:
matlabbe
2026-05-24 22:49:45 -07:00
parent 8caae61978
commit 422d065e75
+13 -14
View File
@@ -33,17 +33,16 @@ detect_gcov_tool() {
} }
GCOV_TOOL="$(detect_gcov_tool)" GCOV_TOOL="$(detect_gcov_tool)"
# lcov 1.14 (Ubuntu 22.04) only knows --ignore-errors gcov,source,graph. # lcov 1.14 (Ubuntu 22.04) supports different --ignore-errors vocabularies
# lcov 1.15+ also accepts mismatch,unused,format,deprecated. The category # per tool: geninfo (gcov,source,graph), genhtml (source only), lcov also
# vocabulary is shared by lcov and geninfo so we parse the help output of # gcov,source,graph. lcov 1.15+ adds mismatch,unused,format,deprecated.
# geninfo (the tool that actually fails first) and use the intersection # Probe each tool's own help and pick the intersection with what we want.
# with what we want. detect_ignore_categories_for() {
detect_lcov_ignore_categories() { local tool="$1"
local wanted=(gcov source graph mismatch unused) local wanted=(gcov source graph mismatch unused)
local help_line local help_line
# geninfo prints the supported categories inline: "(gcov, source, graph)" # Each tool prints "(gcov, source, graph)" style inside its --help.
# on 1.14; newer versions list more. Pull whatever's between the parens. help_line="$("$tool" --help 2>&1 | grep -m1 -- '--ignore-errors')"
help_line="$(geninfo --help 2>&1 | grep -m1 -- '--ignore-errors ERROR')"
local available=() local available=()
if [[ "$help_line" =~ \(([^\)]+)\) ]]; then if [[ "$help_line" =~ \(([^\)]+)\) ]]; then
IFS=', ' read -r -a available <<<"${BASH_REMATCH[1]}" IFS=', ' read -r -a available <<<"${BASH_REMATCH[1]}"
@@ -57,14 +56,14 @@ detect_lcov_ignore_categories() {
fi fi
done done
done done
# Fallback to the lcov-1.14 minimum if parsing failed. # Fallback if parsing failed: source is the only one universally accepted.
if [[ ${#supported[@]} -eq 0 ]]; then if [[ ${#supported[@]} -eq 0 ]]; then
supported=(gcov source graph) supported=(source)
fi fi
(IFS=,; echo "${supported[*]}") (IFS=,; echo "${supported[*]}")
} }
LCOV_IGNORE_CATEGORIES="$(detect_lcov_ignore_categories)" LCOV_IGNORE=(--ignore-errors "$(detect_ignore_categories_for lcov)")
LCOV_IGNORE=(--ignore-errors "$LCOV_IGNORE_CATEGORIES") GENHTML_IGNORE=(--ignore-errors "$(detect_ignore_categories_for genhtml)")
configure_coverage_build() { configure_coverage_build() {
local -a gtest_args=() local -a gtest_args=()
@@ -142,7 +141,7 @@ lcov "${LCOV_IGNORE[@]}" --remove "$INFO_FILE" \
echo "Generating HTML..." echo "Generating HTML..."
rm -rf "$HTML_DIR" rm -rf "$HTML_DIR"
genhtml --ignore-errors source,mismatch "$INFO_FILE" --output-directory "$HTML_DIR" --legend --demangle-cpp genhtml "${GENHTML_IGNORE[@]}" "$INFO_FILE" --output-directory "$HTML_DIR" --legend --demangle-cpp
echo "" echo ""
echo "Done: $HTML_DIR/index.html" echo "Done: $HTML_DIR/index.html"