-
Notifications
You must be signed in to change notification settings - Fork 38
Coverage: ranked plan to move workspace coverage toward 90% #389
Description
Summary
Coverage reporting is now in place, but the current test distribution makes 90%+ workspace coverage unrealistic without a targeted backlog. This issue proposes a ranked coverage plan based on the current crate-by-crate test footprint and source size.
Why 90% is not realistic today
From a local inventory of workspace source and tests:
- Total Rust source lines under
crates/*/src: about17,466 - Source lines in crates with no test footprint at all: about
2,450 - That alone implies a rough workspace ceiling of about
85.97%if those crates remain near0% - Source lines in crates with a very sparse test footprint (3 or fewer test markers/files): about
3,493or roughly20%of workspace source
Coverage is being measured in .github/workflows/coverage.yml, but there is currently no fail-under-* gate, so the workflow reports coverage drift without forcing the repo upward.
Main gaps
Completely untested crates
Ordered roughly by impact:
pet-windows-store(~431lines)pet-reporter(~340lines)pet-windows-registry(~310lines)pet-mac-commandlinetools(~224lines)pet-mac-xcode(~209lines)pet-linux-global-python(~206lines)pet-jsonrpc(~197lines)pet-virtualenvwrapper(~178lines)pet-mac-python-org(~153lines)pet-global-virtualenvs(~79lines)pet-pixi(~74lines)pet-env-var-path(~49lines)
Lightly tested crates
These crates have some tests, but not enough relative to their size:
pet-homebrew(~612lines, only 1 inline test marker)pet-pyenv(~431lines, only 2 integration test files)petmain crate (~2147lines, tests are mostly happy-path CLI and CI discovery validation)
Ranked plan
Phase 1: Fastest coverage lift from deterministic unit tests
Target the coordination and parsing crates first because they are small-to-medium sized and do not need heavy external environment setup.
- Add direct unit tests for
pet-jsonrpc- Cover
get_content_length - Cover request vs notification routing
- Cover unknown method handling
- Cover malformed payload handling
- Cover
- Add direct unit tests for
pet-reportercollectreporter accumulation- cache reporter behavior
- stdio/jsonrpc reporter output formatting where feasible
- Add focused tests for small utility crates with zero coverage
pet-env-var-pathpet-global-virtualenvspet-pixipet-virtualenvwrapper
Expected outcome: a meaningful coverage increase with low platform complexity.
Phase 2: Fill the biggest untested Windows-specific holes
These crates are large enough to matter, and Windows coverage already exists in CI.
- Add tests for
pet-windows-store- path normalization and matching
- cache behavior
- environment identification from discovered symlinks
- Add tests for
pet-windows-registry- registry record parsing
- environment construction
- negative cases and malformed entries
Expected outcome: another large step up in the Windows half of the coverage report.
Phase 3: Improve Linux/global and Homebrew coverage
- Expand
pet-homebrewbeyond version extraction- locator identification
- non-homebrew rejection
- symlink / prefix handling
- Add tests for
pet-linux-global-python/usr/bin,/usr/local/bin, and rejection cases
- Add more branch-focused tests to
pet-pyenv- manager discovery variants
- fallback paths
- negative identification cases
Expected outcome: better coverage on the non-Windows path and less reliance on broad end-to-end tests.
Phase 4: Add direct tests for macOS locators
These crates are not exercised by the current Linux/Windows coverage matrix and will likely need fixture-heavy unit tests rather than full CI environment setup.
pet-mac-commandlinetoolspet-mac-xcodepet-mac-python-org
Focus on pure identification logic and symlink/prefix derivation using fixtures and synthetic paths.
Expected outcome: better local confidence and clearer path to adding a macOS coverage job later if desired.
Phase 5: Strengthen the main pet crate around error paths
The main crate already has CLI and CI tests, but most are discovery validation rather than branch coverage.
- Add targeted tests for
jsonrpcrequest handling - Add tests for
configure/refreshmalformed input and edge cases - Add tests for search-path expansion behavior
- Add tests for fallback identification and unknown-environment reporting
- Add tests for refresh locking / serialization behavior where practical
Expected outcome: better coverage in the orchestration layer, where many user-facing regressions land.
Phase 6: Only then add a coverage gate
After the biggest gaps above are closed:
- Add
fail-under-linesand possiblyfail-under-functionsto the coverage workflow - Start with a realistic threshold, not 90 immediately
- Raise it incrementally as phases land
Suggested progression:
- Start with a threshold near the current measured baseline
- Raise after Phase 1 and Phase 2 land
- Revisit whether 90% is realistic after Phase 4 and Phase 5
Recommended order of implementation
pet-jsonrpcpet-reporterpet-windows-storepet-windows-registrypet-homebrewpet-linux-global-pythonpet-pyenvpet-virtualenvwrapperpet-pixipet-env-var-pathpet-global-virtualenvs- macOS locator crates
petmain-crate error-path tests- coverage threshold in CI
Acceptance criteria
- Add unit/integration tests for
pet-jsonrpc - Add tests for
pet-reporter - Add tests for
pet-windows-store - Add tests for
pet-windows-registry - Expand
pet-homebrewcoverage beyond version parsing - Add tests for
pet-linux-global-python - Expand
pet-pyenvbranch coverage - Add tests for
pet-virtualenvwrapper - Add tests for
pet-pixi - Add tests for
pet-env-var-path - Add tests for
pet-global-virtualenvs - Add direct tests for macOS locator crates
- Add error-path tests in
pet - Add a staged
fail-under-*coverage gate in CI
Notes
There was already a closed issue to add coverage reporting itself: #305. This issue is specifically the follow-up plan for raising actual code coverage in a ranked, low-risk order.