Skip to content

Add code coverage infrastructure#537

Merged
MatthewMckee4 merged 9 commits intomainfrom
feat/coverage-infrastructure
Mar 21, 2026
Merged

Add code coverage infrastructure#537
MatthewMckee4 merged 9 commits intomainfrom
feat/coverage-infrastructure

Conversation

@MatthewMckee4
Copy link
Member

Summary

  • Add cargo llvm-cov coverage infrastructure with two modes:
    • just coverage — karva crate only, ~70% line coverage, HTML output
    • just coverage-full — all crates including karva_test_semantic via instrumented worker binary, ~86% line coverage
  • Add coverage CI job to the existing workflow (same trigger conditions as cargo test)
  • Add KARVA_WORKER_BINARY env var override for worker binary discovery
  • Add private __KARVA_COVERAGE env var to gate coverage-only venv activation in the embedded Python interpreter

The coverage-specific code (venv activation for the embedded PyO3 interpreter) is completely gated behind __KARVA_COVERAGE and is a no-op during normal test runs. All 685 tests continue to pass unchanged.

Test plan

  • just test — 685/685 tests pass (no behavior change)
  • just coverage — 457/457 tests pass, HTML report generated
  • just coverage-full — 457/457 tests pass, 86% line coverage across all crates
  • uvx prek run -a — all pre-commit checks pass

Enable coverage collection for the karva codebase, including the
karva-worker subprocess which contains karva_test_semantic code.

Two coverage modes are available:
- `just coverage`: simple karva-crate-only coverage with HTML output
- `just coverage-full`: full coverage including karva_test_semantic
  (~86% line coverage), using instrumented worker binary

Key changes:
- Add `KARVA_WORKER_BINARY` env var to override worker binary discovery
- Add `__KARVA_COVERAGE` private env var to gate coverage-only venv
  activation in the embedded Python interpreter
- Add coverage job to CI workflow (same conditions as cargo test)
- Add `just coverage` and `just coverage-full` recipes
- Add `*.profraw` to .gitignore

The coverage-specific venv activation (registering embedded _karva
module, adding site-packages, fixing sys.executable) is completely
gated behind `__KARVA_COVERAGE` and is a no-op in normal test runs.
@MatthewMckee4 MatthewMckee4 added the internal An internal refactor or improvement label Mar 21, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 21, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 1 untouched benchmark


Comparing feat/coverage-infrastructure (88cf3ce) with main (991988e)

Open in CodSpeed

@MatthewMckee4 MatthewMckee4 merged commit d03f25c into main Mar 21, 2026
9 checks passed
@MatthewMckee4 MatthewMckee4 deleted the feat/coverage-infrastructure branch March 21, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant