Skip to content

regen_fixtures: preserve hand-written fixtures on collisions - #7582

Open
Barbital11111 wants to merge 2 commits into
ItsNotRexed:mainfrom
Barbital11111:fix/regen-preserve-manual-fixtures
Open

Barbital11111 wants to merge 2 commits into
ItsNotRexed:mainfrom
Barbital11111:fix/regen-preserve-manual-fixtures

Conversation

@Barbital11111

@Barbital11111 Barbital11111 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Claim: #7496 (comment)

Before writing an existing fixture, require its first line to match the complete generated header for the same source name. The writer and the generated-fixture inventory use the same header format. Named and bulk regeneration now leave a same-named hand-written fixture in place, report the collision, and continue with the other selected sources. A refused named source is left unmarked.

Validation

Windows 11, Python 3.14.3, and Ubuntu 24.04 under WSL 2, Python 3.12.3. CPU only.

  • On upstream 916a2e86, named and bulk commands both overwrote a synthetic manual fixture and exited 0. With the patch both return 1, preserve the fixture, and process the other selected source.
  • All 9 test_regen_fixtures.py tests passed on each OS. The checkout-wide regen_fixtures.py --check, semantic test_fixtures.py, diff check, and file-content check passed.
  • No game files or generated fixture files are included in the PR.

Review follow-up

On ea9791d7, named regeneration accepted a hand-written comment with the generator marker and bulk regeneration accepted a complete header copied from another fixture. Both runs exited 0. The new regression verifies that both modes exit 1 and preserve the fixture. A refused named source also stays unmarked.

Windows 11 / Python 3.14.3 and Ubuntu 24.04 under WSL / Python 3.12.3 each passed all 10 generator tests, the checkout-wide --check, and the semantic fixture test. The temporary merge with #7609 at a735c9c5 passed all 12 generator tests on Windows. The diff and changed-file content checks passed.

Review comment

AI-assisted (Codex).

@SirKingg SirKingg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted independent Windows review (Python 3.11.3; synthetic inputs only).

Comment thread tests/semantic/regen_fixtures.py Outdated
if not os.path.isfile(path):
return False
with open(path, encoding="utf-8") as f:
return HEADER_MARK in f.readline()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The substring check can classify a hand-written fixture as generated and overwrite it. On Windows, I created a UTF-8 a.s whose first line was ; not a test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/a.asm, plus a synthetic a.asm. Both named and bulk regeneration returned 0 and replaced the manual file; named regeneration also marked the source. Could the ownership check require the complete generated header for this fixture/source name instead? The current collision guard otherwise misses this case.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at the current head, including the follow-up that tightens the generated-header check.

Named and bulk regeneration now preserve hand-written fixtures, report the collision, and continue. All three new collision tests pass and fail on the pre-change tool; one repository test is red on this checkout because it has no marked sources. No game data.

AI-assisted (OpenCode).

@kapitche

Copy link
Copy Markdown
Contributor

Tested e359cfc merged with main dde82f2 on Linux/Python 3.12.16: pass

Merge is clean (tests/semantic/regen_fixtures.py, tests/test_regen_fixtures.py). A fixture now counts as generated only when its first line equals the exact header for its own name, so a hand-written .s that happens to contain the marker is kept, and a collision is reported with exit 1 while the other sources are still regenerated.

  • python -I tests/test_regen_fixtures.py: Ran 10 tests, OK.
  • Negative control (tests/semantic/regen_fixtures.py restored from upstream/main): Ran 10 tests, FAILED (failures=4): test_bulk_generation_keeps_a_hand_written_collision, test_named_generation_keeps_a_hand_written_collision, and two subtests of test_generated_header_must_match_the_fixture_name (0 != 1), so the new tests discriminate.
  • python -I -m unittest discover -s tests/semantic -p regen_fixtures.py collects 0 tests (it is a script).
  • For information: open PR regen_fixtures: reject unknown options before writing #7609 also edits tests/semantic/regen_fixtures.py (argparse); the two heads merge together without a conflict on current main.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested e359cfc on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass.

Ran the test files this PR adds or changes, from a clean checkout of the PR head: test_regen_fixtures.py - all exit 0. The translator semantic suite was not run for this PR.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants