Skip to content

Commit de18ac8

Browse files
committed
Add gcovr UI customization templates and build scripts
- Add HTML templates for customized gcovr coverage reports with sidebar navigation - Add build_tree.py script to generate tree.json for directory navigation - Add gcovr_wrapper.py for local coverage processing - Update build.sh to handle both local/macOS and CI/Linux environments - Add macOS workaround: auto-detect paths from .info files since gcovr cannot read .gcda files directly on macOS - Add .gitignore for generated coverage reports and temp files
1 parent 832bc10 commit de18ac8

126 files changed

Lines changed: 536491 additions & 7 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Generated coverage reports
2+
# json/gcovr/
3+
# json/gcovr-lcov/
4+
# json/gcovr-output/
5+
6+
# Claude Code
7+
.claude/
8+
9+
# Temp files
10+
*.bak

build.sh

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,51 @@ export REPONAME="json"
88
export ORGANIZATION="boostorg"
99
GCOVRFILTER=".*/$REPONAME/.*"
1010

11-
cd "$REPONAME"
11+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
12+
cd "$SCRIPT_DIR/$REPONAME"
1213
BOOST_CI_SRC_FOLDER=$(pwd)
1314

14-
cd ../boost-root
15-
1615
outputlocation="$BOOST_CI_SRC_FOLDER/gcovr"
17-
outputlocation="/mnt/c/output"
1816
rm -rf $outputlocation || true
19-
2017
mkdir -p $outputlocation
2118

22-
gcovr --merge-mode-functions separate -p --html-nested --html-template-dir=..\templates --exclude-unreachable-branches --exclude-throw-branches --exclude '.*/test/.*' --exclude '.*/extra/.*' --filter "$GCOVRFILTER" --html --output "$outputlocation/index.html"
19+
if [[ -f "$BOOST_CI_SRC_FOLDER/coverage_filtered.info" ]]; then
20+
# Local/macOS workaround: gcovr cannot read .gcda coverage files directly on macOS,
21+
# so we convert the .info file (from lcov) to Cobertura XML format instead.
22+
# The .info file contains absolute paths from the original build environment,
23+
# which we auto-detect and rewrite to match the local machine's paths.
24+
# Use 'boost-root' as anchor since it's consistently named across all builds
25+
ORIGINAL_PATH=$(grep -m1 "^SF:" "$BOOST_CI_SRC_FOLDER/coverage_filtered.info" | sed 's|^SF:||' | sed 's|/boost-root/.*||')
26+
TEMP_COVERAGE="/tmp/coverage_local.info"
27+
TEMP_XML="/tmp/coverage.xml"
28+
29+
sed "s|$ORIGINAL_PATH|$SCRIPT_DIR|g" "$BOOST_CI_SRC_FOLDER/coverage_filtered.info" > "$TEMP_COVERAGE"
30+
lcov_cobertura "$TEMP_COVERAGE" -o "$TEMP_XML"
31+
sed -i.bak "s|filename=\"\.\./boost-root/|filename=\"$SCRIPT_DIR/boost-root/|g" "$TEMP_XML"
32+
33+
"$SCRIPT_DIR/scripts/gcovr_wrapper.py" \
34+
--cobertura-add-tracefile "$TEMP_XML" \
35+
--root "$SCRIPT_DIR" \
36+
--html-nested \
37+
--html-template-dir "$SCRIPT_DIR/templates/html" \
38+
--output "$outputlocation/index.html"
39+
40+
# Generate tree.json for sidebar navigation
41+
python3 "$SCRIPT_DIR/scripts/build_tree.py" "$outputlocation"
42+
else
43+
# CI/Linux: gcovr reads coverage data directly
44+
cd ../boost-root
45+
gcovr --merge-mode-functions separate -p \
46+
--html-nested \
47+
--html-template-dir=../templates/html \
48+
--exclude-unreachable-branches \
49+
--exclude-throw-branches \
50+
--exclude '.*/test/.*' \
51+
--exclude '.*/extra/.*' \
52+
--filter "$GCOVRFILTER" \
53+
--html \
54+
--output "$outputlocation/index.html"
55+
56+
# Generate tree.json for sidebar navigation
57+
python3 "../scripts/build_tree.py" "$outputlocation"
58+
fi

0 commit comments

Comments
 (0)