Files
betterxen/docs/testing/test-inventory.md
T
elforeign 1784836639 audit: compare Cargo test inventories between two commits
Testing the old #166 and #165 heads silently ran without 12 BC texture
tests that main already had, because those heads predated the merge
that added them; nothing flagged the smaller inventory.

scripts/audit/test_inventory.py lists every test (and the ignored set)
of a base and a candidate commit, each in a temporary detached worktree
it always removes, and reports removed, added, newly ignored and newly
un-ignored tests keyed by package, target and name. Unexplained losses
exit 1; an --allow file with a reason per key explains intended ones.

951189c -> 5450612: removed 12 (all xenora-texture bc_formats), exit 1.
0cac6c4 -> 0cac6c4: 219 tests each side, no change, exit 0.

Fixes #208

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:37:54 -06:00

45 lines
2.1 KiB
Markdown

# Compare test inventories across commits
Run this check from a Xenora checkout with Python 3.11 or later and the
native ARM64 Rust toolchain. Choose the base commit whose tests the candidate
should preserve. Comparing against `main` can catch tests missing from a
branch that predates their merge.
```sh
python3 scripts/audit/test_inventory.py main HEAD
python3 scripts/audit/test_inventory.py main HEAD --allow intended-losses.tsv
python3 scripts/audit/test_inventory.py --self-test
```
The script resolves both refs to commits, then uses a temporary detached Git
worktree for each commit. It builds the workspace with the lockfile and
default features in offline mode, using Cargo's cached dependencies. It lists
tests and then lists ignored tests using the same build. It removes each
temporary worktree after listing, including when a build fails. Git needs
permission to update its worktree registry.
Each test is identified by `package/kind:target/test_name`. The report shows
removed, added, newly ignored and newly un-ignored tests. Renames appear as a
removal and an addition. Exit code 1 means at least one unexplained removal or
newly ignored test. Exit code 0 means every loss was explained or there were
no losses. Exit code 2 means the check could not complete, for example because
a ref did not resolve or Cargo could not build it.
To explain an intended removal or a newly ignored test, copy its exact key
from the report into a UTF-8 file, followed by a literal tab and a reason.
Use one entry per line. Blank lines and lines starting with `#` are allowed.
```text
xenora-texture/test:bc_formats/old_case Replaced by new_case, which covers both endpoint orders.
```
The report still shows explained losses. Keep the reasons specific enough for
a reviewer to verify.
The inventory covers Cargo's default workspace test targets for the host and
build configuration. Feature-gated targets such as those requiring
`gpu-tests` are outside that inventory. The check lists tests without
running their bodies or verifying CPU or GPU behavior. Benchmarks are
excluded. Rustdoc includes source positions in doctest names, so moving a
doctest can appear as a removal and an addition.