Skip to content

ci: add FetchContent consumer regression test - #349

Merged
bobluppes merged 2 commits into
mainfrom
verify-fetchcontent-ci
Sep 2, 2026
Merged

ci: add FetchContent consumer regression test#349
bobluppes merged 2 commits into
mainfrom
verify-fetchcontent-ci

Conversation

@bobluppes

Copy link
Copy Markdown
Owner

Why

#310 (a CMake configure-time crash) and #312 (the fix, which also avoids publishing incorrect pkgconfig metadata) both only surface when Graaf is genuinely consumed as a FetchContent dependency by a separate project. That's a build-system regression class that GTest has no visibility into -- it happens before any C++ code compiles or runs -- so there was previously no automated coverage that would catch a regression here.

What Changed

  • test/cmake_integration/consumer/: a minimal standalone CMake project that FetchContents Graaf via SOURCE_DIR (no network needed) and links a trivial executable against it.
  • A new verify_fetchcontent CI job (pull-request.yml) that configures, builds, runs, and installs that consumer project, then asserts no graaf.pc leaks into its install tree.
  • A short README documenting the purpose and how to reproduce locally.

Kept as its own CI job rather than a ctest case, so the fast unit test suite stays fast and a failure here is unambiguous about what broke (matches the pattern used by fmt/spdlog/Catch2/Abseil for this exact "does our CMake packaging work" concern).

Verification

Ran the exact CI steps locally against current main: configure/build/run/install all succeed, and no .pc file leaks into the consumer's install tree.

Also confirmed the check actually catches the original regression: reverted to the pre-#312 CMakeLists.txt (the unconditional configure_file(${CMAKE_SOURCE_DIR}/...)) in a throwaway copy and reran the same steps -- the configure step fails immediately with the same error originally reported in #310 (File .../packaging/graaf.pc.in does not exist).

Adds a minimal standalone CMake project (test/cmake_integration/consumer)
that consumes Graaf via FetchContent, plus a verify_fetchcontent CI job
that configures, builds, runs, and installs it, then asserts no
graaf.pc leaks into the consumer's install tree.

This is a build-system regression, not something GTest can observe --
both #310 (a configure-time crash) and #312's fix (avoiding incorrect
pkgconfig metadata when Graaf is a subproject) only surface when Graaf
is genuinely consumed as a FetchContent dependency. Verified locally
that this setup passes against current main and fails the same way
#310 originally did when reverted to the pre-#312 CMakeLists.txt.

Kept as its own CI job rather than a ctest case, so the fast unit test
suite stays fast and a failure here is unambiguous about what broke.
test/CMakeLists.txt globs *.cpp recursively (file(GLOB_RECURSE
TEST_SOURCES "./*.cpp")), which swept up cmake_integration/consumer's
own main() into the Graaf_test binary. Since gtest_main is a static
library, the linker satisfied the already-defined `main` symbol from
that file instead of extracting gtest_main's real one from the
archive -- silently replacing the whole test runner. `ctest` then
found and ran zero real tests, though it still exited 0 in
compile_and_test; only the stricter ctest_coverage target caught it,
which is why coverage failed while compile_and_test showed green.

Moving the consumer project to a top-level cmake_integration/
directory (sibling to test/, examples/, perf/) avoids the glob
entirely. Verified locally: all 752 real tests are discovered and
pass again via ctest, and the FetchContent consumer check still
passes from its new location.
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.58%. Comparing base (4b0ad5a) to head (5351ac0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #349   +/-   ##
=======================================
  Coverage   99.58%   99.58%           
=======================================
  Files          59       59           
  Lines        2622     2622           
  Branches      136      136           
=======================================
  Hits         2611     2611           
  Misses         11       11           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bobluppes
bobluppes merged commit 678c073 into main Sep 2, 2026
9 checks passed
@bobluppes
bobluppes deleted the verify-fetchcontent-ci branch September 2, 2026 20:02
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.

1 participant