Problem
The two flags exist to find snapshots no test uses. They cannot see the most
common kind: one whose owning test file was deleted or renamed.
Reproduced in a scratch project — an orphan whose owner file does not exist:
snapshots/renamed_away_test_sh.test_gone.snapshot
$ bashunit --snapshot-report-unused .
No unused snapshots.
$ bashunit --snapshot-prune .
still present
An unused snapshot whose owner file does exist is reported correctly, with
both file and directory arguments. So the gap is specifically "owner file
gone".
This repo has two
91e523bb split bashunit_direct_fn_call_test.sh into _basic_ and
_advanced_; the pre-split snapshots were left behind and are byte-identical
leftovers:
tests/acceptance/snapshots/bashunit_direct_fn_call_test_sh.test_bashunit_direct_fn_call_failure.snapshot
tests/acceptance/snapshots/bashunit_direct_fn_call_test_sh.test_bashunit_direct_fn_call_non_existing_fn.snapshot
Neither is referenced. The tooling has never been able to flag them.
Cause
collect_unused keeps a snapshot only if its owner prefix matches a test file
this run discovered:
local owner="${file##*/}"; owner="${owner%%.*}"case"$owners"in*"$owner"$'\n'*) ;; *) continue ;; esacThat filter is right for a subset run — running tests/unit/ must not report
tests/acceptance/'s snapshots. But an owner that no longer exists can never
be in owners, so a true orphan is skipped forever.
Proposed rule
Within a snapshots/ directory the scan already covers, if the owner test file
is absent from disk next to it, the snapshot is an orphan regardless of
what ran. Owner present but not run keeps today's behaviour.
Note this widens what --snapshot-prune deletes. That is the flag's stated
purpose, but it is a destructive command, so the change deserves a deliberate
yes rather than being folded in silently — collect_unused is shared by both
flags on purpose ("two implementations of unused is how they drift").
Problem
The two flags exist to find snapshots no test uses. They cannot see the most
common kind: one whose owning test file was deleted or renamed.
Reproduced in a scratch project — an orphan whose owner file does not exist:
An unused snapshot whose owner file does exist is reported correctly, with
both file and directory arguments. So the gap is specifically "owner file
gone".
This repo has two
91e523bbsplitbashunit_direct_fn_call_test.shinto_basic_and_advanced_; the pre-split snapshots were left behind and are byte-identicalleftovers:
Neither is referenced. The tooling has never been able to flag them.
Cause
collect_unusedkeeps a snapshot only if its owner prefix matches a test filethis run discovered:
That filter is right for a subset run — running
tests/unit/must not reporttests/acceptance/'s snapshots. But an owner that no longer exists can neverbe in
owners, so a true orphan is skipped forever.Proposed rule
Within a
snapshots/directory the scan already covers, if the owner test fileis absent from disk next to it, the snapshot is an orphan regardless of
what ran. Owner present but not run keeps today's behaviour.
Note this widens what
--snapshot-prunedeletes. That is the flag's statedpurpose, but it is a destructive command, so the change deserves a deliberate
yes rather than being folded in silently —
collect_unusedis shared by bothflags on purpose ("two implementations of unused is how they drift").