Skip to content

Commit 9470429

Browse files
thirtytwobitsScott DixonCopilotCopilot
authored
Switching to llvm source based coverage. (#385)
A much better way to generate source coverage for C++ --------- Co-authored-by: Scott Dixon <thirtytwobits@Scotts-MacBook-Pro.local> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: thirtytwobits <19180861+thirtytwobits@users.noreply.github.com>
1 parent 426fe05 commit 9470429

15 files changed

Lines changed: 502 additions & 758 deletions

File tree

.devcontainer/toolshed-amd64/devcontainer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"streetsidesoftware.code-spell-checker",
2020
"xaver.clang-format",
2121
"vadimcn.vscode-lldb",
22-
"matepek.vscode-catch2-test-adapter",
2322
"ms-python.python",
2423
"ms-python.mypy-type-checker",
2524
"ms-python.black-formatter",

.devcontainer/toolshed-arm64/devcontainer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"streetsidesoftware.code-spell-checker",
2020
"xaver.clang-format",
2121
"vadimcn.vscode-lldb",
22-
"matepek.vscode-catch2-test-adapter",
2322
"ms-python.python",
2423
"ms-python.mypy-type-checker",
2524
"ms-python.black-formatter",

.devcontainer/toolshed-cov-amd64/devcontainer.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

.devcontainer/toolshed-cov-arm64/devcontainer.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,14 @@ jobs:
172172
uses: actions/upload-artifact@v4
173173
with:
174174
name: verification-c-coverage-reports
175-
path: verification/build/DebugCov/coverage/*
175+
path: |
176+
verification/build/DebugCov/coverage/html/
177+
verification/build/DebugCov/coverage/lcov/
176178
177179
language-verification-cpp-clang-native-extra:
178180
runs-on: ubuntu-latest
179181
needs: test
180-
container: ghcr.io/opencyphal/toolshed:ts22.4.10
182+
container: ghcr.io/opencyphal/toolshed:ts24.4.3
181183
steps:
182184
- uses: actions/checkout@v4
183185
with:
@@ -191,7 +193,9 @@ jobs:
191193
uses: actions/upload-artifact@v4
192194
with:
193195
name: verification-cpp-coverage-reports
194-
path: verification/build/DebugCov/coverage/*
196+
path: |
197+
verification/build/DebugCov/coverage/html/
198+
verification/build/DebugCov/coverage/lcov/
195199
196200
language-verification-python:
197201
runs-on: ubuntu-latest

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@
1313
"streetsidesoftware.code-spell-checker",
1414
"xaver.clang-format",
1515
"vadimcn.vscode-lldb",
16-
"matepek.vscode-catch2-test-adapter"
1716
]
1817
}

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,9 @@
138138
"addWords": true
139139
}
140140
},
141-
"cmake.sourceDirectory": "${workspaceFolder}/verification"
141+
"cmake.sourceDirectory": "${workspaceFolder}/verification",
142+
"sonarlint.connectedMode.project": {
143+
"connectionId": "opencyphal",
144+
"projectKey": "OpenCyphal_nunavut"
145+
}
142146
}

CONTRIBUTING.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,35 @@ After configuring you can also use Ninja directly::
285285
ninja -t targets
286286

287287
To obtain coverage information for the verification suite (not the Python code),
288-
build the `cov_all` target and inspect the output under the `coverage` directory::
288+
build the ``cov_all`` target and inspect the output under the ``coverage`` directory.
289+
Coverage is generated using LLVM source-based code coverage and includes HTML, text,
290+
and lcov format reports. Only generated Nunavut code is included in coverage; vendor
291+
code (submodules, googletest, Unity), build artifacts, system headers, and test source
292+
files are excluded::
293+
294+
cmake --build --preset build-DebugCov-clang-native-c-11 --target cov_all
295+
296+
This will:
297+
1. Build all test executables with coverage instrumentation
298+
2. Run all tests (generating .profraw files)
299+
3. Merge coverage data into tests.profdata
300+
4. Generate coverage reports in:
301+
- ``build/DebugCov/coverage/html/index.html`` - Interactive HTML report
302+
- ``build/DebugCov/coverage/text/summary.txt`` - Text summary
303+
- ``build/DebugCov/coverage/lcov/coverage.lcov`` - lcov format for SonarCloud
289304

290-
cmake --build --preset build-clang-native-c-11-debug --target cov_all
305+
.. note::
306+
307+
The ``DebugCov`` configuration is specifically for coverage builds. Use a preset
308+
that includes ``DebugCov`` in its name (e.g., ``build-DebugCov-clang-native-c-11``)
291309

292310
.. warning::
293311

294312
When switching between gcc and clang you must do a full clean of your repo if you previously ran the coverage
295313
build. For example ``git clean -xdf`` or clone a new repo in a different folder. Each compiler suite leaves
296314
different byproducts that may interfere with the coverage tools in the other suite.
297315

316+
298317
While we strongly encourage you to use the cmake presets, the CMakeLists.txt for the verification suite is driven by
299318
three variables you can set in your environment or pass into cmake if using cmake directly:
300319

0 commit comments

Comments
 (0)