Skip to content

Add coverage tools to cmake/autotools builds - #65

Closed
d-torrance wants to merge 57 commits into
MichaelABurr:aringsfrom
d-torrance:gcov
Closed

Add coverage tools to cmake/autotools builds#65
d-torrance wants to merge 57 commits into
MichaelABurr:aringsfrom
d-torrance:gcov

Conversation

@d-torrance

@d-torrance d-torrance commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

We add an --enable-gcov option to configure so that M2 gets compiled with all the right flags for gcov to do its thing. Then we can run some M2 code and call make coverage-report to get a nice gcovr-generated report of the coverage. Call make coverage-reset to reset the accumulated data before generating a fresh report.

There's also some analogous cmake stuff I haven't tested yet.

AI Disclosure

🤖 This was all Claude, baby! 🤖

d-torrance and others added 30 commits June 13, 2026 22:44
Builds the image from M2/BUILD/docker/testbot/Dockerfile and pushes it
to ghcr.io/macaulay2/testbot, tagged with the current Macaulay2
version (from M2/VERSION) and "latest".

[ci skip]
this commit contains the aux files moving and also some refactoring of
pushFwdRingHelper and pushAuxHgs that were hard to excise from the test
/ docs move for some reason :(
this produces a basis ordering which is more naturally aligned with the
basis for the pushforward of the coefficient ring.
this simplifies the gymnastics in computation of pushforward of
elements.
removes unnecessary call to pushFwd(RingMap) in the middle of
pushFwd(RingMap, Module) that was giving significant slowdown. Following
this simplify and unify duplicate codepaths for pushFwd(RingMap) and
pushFwd(RingMap, Module).
performance of `summands` method appears highly sensitive to the
presentation of the module it is passed. The PushForward package is
being refactored in a way that results in a different presentation for
the `frobeniusPushforward' used in this test and this causes the test to
hang. Disabling it pending investigation by @Devlin-Mallory and @mahrud
into why. See PR discussion for more context.
This appears naturally in the context of pushing forward the maps in a
free resolution.
…rd method

in my experience working with these patterns it is easy to lead to
confusion if you for example create a pushFwd with an explicit map and
then call bare pushforward of an element. it will successfully
pushforward the element but probably to a different pushforward module.

starting off requiring an explicit map seems reasonable as it is harder
to claw functionality out of the api than it is to add it later.
d-torrance and others added 9 commits August 1, 2026 09:13
Adds a --enable-gcov option (modeled on --enable-profile) that builds with
--coverage -O0, plus -fprofile-abs-path under gcc so gcov/gcovr can resolve
sources from the out-of-tree build; it also disables stripping.

Coverage data (.gcda) is generated automatically whenever any coverage-built
binary exits, so no target runs the tests for you: just run the unit tests,
make check, or the M2 binary on your own code.  Two top-level targets clear
and report on the accumulated data:
  coverage-reset   delete accumulated .gcda (tree-wide)
  coverage-report  produce an HTML report via gcovr (engine-scoped by default;
                   override COVERAGE_ROOT/COVERAGE_OBJDIR for the whole tree)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a -DGCOV=ON option that builds with --coverage -O0, plus
-fprofile-abs-path under gcc, mirroring the PROFILING flag block.  New
cmake/gcov.cmake provides coverage-reset and coverage-report (gcovr) targets,
paralleling the autotools setup; coverage data is generated by running any
coverage-built binary (unit tests, ctest, or the M2 binary).

Also fixes a pre-existing typo in the dormant Clang coverage.cmake, which
searched for clang-format instead of llvm-cov.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The coverage-report target now prints the report path as an OSC 8 terminal
hyperlink (file://host/path) via printf, so terminals that support it render
it as a clickable link.  Done for both the autotools (Makefile.in) and cmake
(gcov.cmake) targets.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gcov can report the same function on more than one line (e.g. inlines compiled
at -O0), which gcovr's default --merge-mode-functions=strict treats as a fatal
error.  Pass merge-use-line-min so those entries are merged and attributed to
the function's first line.  Applied to both the autotools and cmake targets;
the autotools value is overridable via COVERAGE_MERGE_MODE.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
-fprofile-abs-path is gcc-only (clang rejects it), and it was only a
convenience for source resolution -- which gcovr already handles via its
--root/--object-directory options.  Removing it keeps --coverage portable
across gcc and clang and avoids a compiler-specific guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Consolidate the declaration and flag-setting logic into one block, quote
macro arguments with [...], use AS_IF instead of raw test/if, and keep lines
within 80 columns.  No functional change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
On macOS, applying --coverage before AC_FC_LIBRARY_LDFLAGS/AX_BLAS/AX_LAPACK
let gfortran expand --coverage to -lgcov and bake it into FCLIBS/BLAS_LIBS.
The final clang link then pulled in both gcc's libgcov and clang's own
libclang_rt.profile, producing duplicate __gcov_reset/__gcov_fork symbols.
Move the gcov flag block after that detection so only the compiler's own
coverage runtime ends up on the link line.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Pass the object tree to gcovr as a positional search path instead of via
--object-directory.  --object-directory forces gcov to run in a single
directory, which cannot resolve the relative source paths of objects built in
deeper VPATH subdirectories (e.g. Macaulay2/e/unit-tests), causing "could not
infer a working directory" errors.  As a search path, gcovr runs gcov in each
data file's own directory, so every source resolves.

Also default COVERAGE_ROOT/COVERAGE_OBJDIR to the whole tree, drop the
hardcoded unit-tests exclude, and add a GCOVR_OPTIONS variable for passing
extra gcovr options (filters, excludes, formats).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Report over the whole tree by default (root = source tree, build tree passed
as a positional search path rather than --object-directory), drop the
hardcoded unit-tests exclude, and add a GCOVR_OPTIONS cache variable for
passing extra gcovr options (split with separate_arguments).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@d-torrance

Copy link
Copy Markdown
Collaborator Author

Closing in favor of Macaulay2#4489

@d-torrance d-torrance closed this Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants