Background
Raised during review of PR #75 (refresh stale Cargo lockfiles before publish preflight).
Problem
discover_tracked_lockfiles enforces several filtering invariants (exclude target/ paths, require adjacent Cargo.toml, restrict to git-tracked files) that are only verified by fixed-scenario unit tests. Property-based coverage would catch edge cases across generated input ranges that fixed tests miss.
Resolution
Add @hypothesis.given tests in tests/unit/test_lockfile.py that generate workspace trees with:
- Random
Cargo.lock / Cargo.toml placements at varying nesting depths
target/ directory subtrees at varying depths
- Synthesised
git ls-files stdout with varying combinations of tracked / untracked / target paths
Assert that all four invariants hold for every returned path:
- Path ends with
Cargo.lock
- No
target component in the relative path
- An adjacent
Cargo.toml exists
- The path was present in the git ls-files output
References
Background
Raised during review of PR #75 (refresh stale Cargo lockfiles before publish preflight).
Problem
discover_tracked_lockfilesenforces several filtering invariants (excludetarget/paths, require adjacentCargo.toml, restrict to git-tracked files) that are only verified by fixed-scenario unit tests. Property-based coverage would catch edge cases across generated input ranges that fixed tests miss.Resolution
Add
@hypothesis.giventests intests/unit/test_lockfile.pythat generate workspace trees with:Cargo.lock/Cargo.tomlplacements at varying nesting depthstarget/directory subtrees at varying depthsgit ls-filesstdout with varying combinations of tracked / untracked / target pathsAssert that all four invariants hold for every returned path:
Cargo.locktargetcomponent in the relative pathCargo.tomlexistsReferences