Record the stale-build-tree coverage defect
Defects #13: gcovr searches for gcov data under --root, which CMakeLists.txt:208 and :223 set to the source directory, so any instrumented build tree left there is merged into the report. The --object-directory argument beside each does not narrow the search; it only maps gcda files back to the compiler's working directory. A leftover build-coverage/ therefore fails coverage_reset before any test runs, with gcovr unable to reconcile a function reported on two different lines. The build*/ entry in .gitignore keeps the offending tree out of git status, so the state is easy to get into and hard to spot. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
29
TODO.md
29
TODO.md
@@ -586,6 +586,35 @@ Each was found by a test written to assert correct behavior.
|
||||
dedicated `controllerdb` target, or an `OUTPUT` that matches where the
|
||||
script actually writes — so an ordinary build neither needs the network nor
|
||||
dirties the tree.
|
||||
13. **A stale build tree in the source directory breaks the coverage run.**
|
||||
`CMakeLists.txt:208` and `CMakeLists.txt:223` pass
|
||||
`--root "${CMAKE_CURRENT_SOURCE_DIR}"` to gcovr, and gcovr searches for
|
||||
`.gcda`/`.gcno` files under the root. The `--object-directory` argument on
|
||||
the line below each does *not* narrow that search: per `gcovr --help` it
|
||||
only identifies "the path between gcda files and the directory where the
|
||||
compiler was originally run". So every instrumented build tree left inside
|
||||
the source directory is folded into the report alongside the one actually
|
||||
being measured.
|
||||
|
||||
With a `build-coverage/` from an earlier session still present, a freshly
|
||||
configured `-DAKGL_COVERAGE=ON` tree fails in `coverage_reset`, before any
|
||||
test runs:
|
||||
|
||||
AssertionError: Got function akgl_game_lowfps on multiple lines: 45, 46.
|
||||
|
||||
45 and 46 are that function's line numbers before and after an unrelated
|
||||
`#include` was added to `src/game.c`: gcovr found 18 stale `.gcno` files
|
||||
describing the old layout, merged them with the current ones, and could not
|
||||
reconcile the two. Moving `build-coverage/` aside makes the same tree pass
|
||||
18/18. Verified with gcovr 7.0.
|
||||
|
||||
The `build*/` entry in `.gitignore` hides these trees from `git status`,
|
||||
which makes the state easier to get into and no easier to notice.
|
||||
|
||||
Fix: pass the build tree to gcovr as an explicit search path instead of
|
||||
letting it default to `--root`, so only the tree under measurement is
|
||||
considered. Touches the two `add_test` blocks at `CMakeLists.txt:204-211`
|
||||
and `CMakeLists.txt:220-229`; nothing outside the `AKGL_COVERAGE` branch.
|
||||
|
||||
## Build notes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user