Skip to content

build: wire tests, coverage, static analysis, and Tracy options in CMake - #11

Merged
MarcelRaschke merged 1 commit into
masterfrom
vibe/cmake-tests-coverage-tracy-ddb4db
Aug 18, 2026
Merged

MarcelRaschke merged 1 commit into
masterfrom
vibe/cmake-tests-coverage-tracy-ddb4db

Conversation

@MarcelRaschke

Copy link
Copy Markdown
Owner

Summary

Focused, additive build-system + CI changes addressing the parts of the requested plan that represent genuine gaps. Several items in the original plan were skipped because they rest on incorrect premises or already exist (details below).

Changes made

  • CMake — activate tests (Step 7): The BUILD_TESTING block was a no-op (# Add tests here when available) even though tests/CMakeLists.txt existed. Now add_subdirectory(tests) is wired so ctest actually runs the existing GoogleTest suite.
  • CMake — code coverage (Step 4): ENABLE_COVERAGE now uses directory-scoped add_compile_options(--coverage -O0 -g) / add_link_options(--coverage), ordered before the test subdirectory so the test target inherits coverage flags too. Guards against non-GCC/Clang toolchains.
  • CMake — clang-tidy / cppcheck (Step 3): Replaced the brittle target-property-only stub with proper CMAKE_CXX_CLANG_TIDY / CMAKE_CXX_CPPCHECK wiring that locates the tool and gracefully skips when absent (ENABLE_CLANG_TIDY / ENABLE_CPPCHECK).
  • CMake — Tracy profiler (Step 5): New ENABLE_TRACY / TRACY_ON_DEMAND options. When the tracy headers are present they are added to the include path and TRACY_ENABLE/TRACY_ON_DEMAND are defined; otherwise the option no-ops, so it is always safe to enable.
  • tests/CMakeLists.txt: Converted from a standalone project() into a proper subdirectory. Fetches GoogleTest via FetchContent (no system GTest dependency) and registers the test with add_test.
  • src/tracyprofiler.h: Dependency-free instrumentation shim. Pulls in Tracy zones when TRACY_ENABLE is defined and headers exist, else expands to no-ops — sources can be instrumented unconditionally without forcing a tracy dependency on regular builds.
  • .github/workflows/code-coverage.yml: New gcov/lcov CI workflow: builds with BUILD_TESTING=ON -DENABLE_COVERAGE=ON, runs ctest, captures and filters lcov (excluding system/third-party/test-framework code), generates an HTML report, and uploads it as an artifact.

Items intentionally NOT done (with reasons)

  • Step 1 — OpenGL-Header anpassen (glad/glew → Kodi): Premise is false. There is no glad/glad.h or GL/glew.h include anywhere in src/. The code already uses the correct Kodi headers (<kodi/addon-instance/Visualization.h>, <kodi/gui/gl/Shader.h> in src/main.h:10-11). Nothing to replace.
  • Step 3 (clang-tidy/cppcheck) and Step 5 (Tracy) CI: The dedicated .github/workflows/clang-tidy.yml, cppcheck.yml, and sonarqube.yml already exist and run in CI. The CMake-side wiring (above) is the genuine gap; the CI workflows were not duplicated.
  • Step 8 (Dockerfile): Already exists as a working multi-stage build.
  • Steps 2, 6, 9, 10 and platform backends (Vulkan/Metal/DirectX): These are substantial architectural refactorings (multithreaded FFT, shader hot-reloading, dynamic resolution scaling, frame skipping, alternate graphics backends) of an 815-line src/main.cpp with no test coverage for the new behavior. Each is its own design decision and was not guessed at. Recommend tackling them as separate, scoped PRs.

Verification

Local sandbox validation (no Kodi SDK available, so the addon module target cannot fully configure — that is expected and pre-existing):

  • Tests build & pass: Standalone harness using the new tests/CMakeLists.txt pattern configured, built, and ran test_visualization_matrix — 14/14 tests PASSED, discovered by ctest.
  • Coverage flags: With BUILD_TESTING=ON -DENABLE_COVERAGE=ON, confirmed the test target inherits --coverage -O0 -g (compile) and --coverage (link); .gcno/.gcda artifacts generated after running tests.
  • New CMake blocks: Stub-validated the top-level CMakeLists.txt configure with -DENABLE_COVERAGE=ON, -DENABLE_TRACY=ON, -DENABLE_CLANG_TIDY=ON, -DENABLE_CPPCHECK=ON — all configure cleanly, with graceful skip messages when the tool/headers are absent.

- CMake: activate the BUILD_TESTING path (was a no-op) via add_subdirectory(tests)
  so ctest actually runs the existing GoogleTest suite.
- CMake: make ENABLE_COVERAGE use directory-scoped add_compile/add_link_options
  (--coverage -O0 -g) ordered before the test subdirectory so the test target
  inherits coverage flags too; guard against non-GCC/Clang toolchains.
- CMake: replace the brittle clang-tidy target-property stub with proper
  CMAKE_CXX_CLANG_TIDY / CMAKE_CXX_CPPCHECK wiring that finds the tools and
  gracefully skips when absent (ENABLE_CLANG_TIDY / ENABLE_CPPCHECK).
- CMake: add optional ENABLE_TRACY / TRACY_ON_DEMAND options that define
  TRACY_ENABLE/TRACY_ON_DEMAND and add the tracy include dir when the headers
  are present, and no-op otherwise.
- tests/CMakeLists.txt: convert from a standalone project() to a proper
  subdirectory; fetch GoogleTest via FetchContent (no system GTest dependency)
  and register the test with add_test.
- src/tracyprofiler.h: dependency-free instrumentation shim that pulls in Tracy
  zones when TRACY_ENABLE is defined and the headers exist, else expands to
  no-ops, so sources can be instrumented unconditionally.
- .github/workflows/code-coverage.yml: new gcov/lcov CI workflow that builds
  with BUILD_TESTING+ENABLE_COVERAGE, runs ctest, captures/filters lcov, and
  uploads an HTML coverage report.

Co-authored-by: MarcelRaschke <MarcelRaschke@users.noreply.github.com>
@MarcelRaschke
MarcelRaschke marked this pull request as ready for review August 18, 2026 05:54

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@MarcelRaschke
MarcelRaschke merged commit 4f6fa58 into master Aug 18, 2026
3 of 22 checks passed
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.

2 participants