[Bugfix] tests/unit/api_manifest_test.py rewrites the tracked api/manifest.json — every suite run dirties the working tree #401
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#401
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
tests/unit/api_manifest_test.pyexercisestools/generate_api_manifest.pyby running the real generator against its real output path. The generator writesapi/manifest.json, which is a tracked file. So merely running the test suite modifies a committed file.Surfaced during review of
mcrogueface-002(branchsim/integration); pre-existing, unrelated to that work.Reproduction
From a clean tree:
The diff is the two provenance fields the generator stamps from the live repo state:
Why it matters
run_tests.pybefore committing now has a modified tracked file that they did not author, and the natural reaction —git add -A— silently commits a manifest stamped with the wrong commit and an arbitrarydirtyvalue.tools/hooks/pre-commit, which is the component that is supposed to own this file: the hook regenerates it from a freshly built binary andgit adds it as its only index write. Two writers, one file, different trigger conditions.commitis whatever HEAD is;dirtyis whatever the tree looked like at that instant), so the churn is guaranteed, not occasional.Suggested fix
Point the generator at a temp directory for the duration of the test and assert against that output, rather than against the repository's own artifact. The test's actual assertions — determinism across two runs, schema version, presence and types of the top-level keys — do not need the canonical path; they only need a generated manifest.
If the generator cannot currently be redirected, that redirect is the fix: a test should not be able to mutate a tracked file as a side effect of asserting on it.
Related
tools/hooks/pre-commit), the intended sole writer ofapi/manifest.json