Skip to content

regen_fixtures: reject unknown options before writing - #7609

Open
Barbital11111 wants to merge 1 commit into
ItsNotRexed:mainfrom
Barbital11111:fix/regen-validate-cli-options
Open

Barbital11111 wants to merge 1 commit into
ItsNotRexed:mainfrom
Barbital11111:fix/regen-validate-cli-options

Conversation

@Barbital11111

Copy link
Copy Markdown
Contributor

Summary

Claim: #7496 (comment)

Parse the arguments before marking or writing fixtures. --help now prints usage and exits cleanly. Unknown and abbreviated options fail with a usage diagnostic. Valid --check options can still appear before, after, or between fixture names.

The semantic README now shows the existing regen_fixtures.py NAME workflow. This is separate from #7582. The two patches merge cleanly in a local Git simulation.

Validation

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

  • On upstream 6adeaf0b, both --help and a misspelled check option overwrote a synthetic fixture. The new regression confirms that help, a misspelling, and an abbreviation leave sources and fixture bytes intact.
  • All 9 fixture-generator tests passed on both environments. Help, the checkout-wide --check and semantic test_fixtures.py passed, as did the diff and changed-file content checks.
  • The PR contains code, usage text and synthetic regression tests.

AI-assisted (Codex).

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Independent Windows CPU verification at a735c9c5a91846566723a53fc6c1081efed85f61.

Environment & Test Suite

  • Platform: Native Windows 11 x64, Python 3.12 / 3.13, CPU-only.
  • Clean-room: Pure synthetic test fixtures only, zero game data (scripts/check_no_game_data.py passes with exit 0).

Verification

  • python -I tests/test_regen_fixtures.py ran 9 tests, OK (0.21s).
  • Verified test_help_and_bad_options_leave_sources_and_fixtures_alone:
    • --help prints usage without modifying or overwriting existing fixtures.
    • Misspelled (--chekc) or abbreviated (--chec) flags are rejected with exit code 2 and usage diagnostics via allow_abbrev=False.
    • Fixtures and sources remain intact.
  • Verified intermixed arguments via parse_intermixed_args: --check can appear before, between, or after fixture names.
  • python -I tests/semantic/regen_fixtures.py --help: clean exit 0.
  • python -I tests/semantic/regen_fixtures.py --check: clean exit 0.
  • Merges cleanly into current upstream/main (6a4299563) with zero conflicts.
  • python -I -m compileall tests/semantic/regen_fixtures.py tests/test_regen_fixtures.py: clean, exit 0.
  • git diff --check: clean (0).

LGTM. Approved.

@kapitche

Copy link
Copy Markdown
Contributor

Tested a735c9c merged with main 5074124 on Linux/Python 3.12.16: pass

Merge is clean (tests/semantic/regen_fixtures.py, tests/semantic/README.md, tests/test_regen_fixtures.py). main now parses its arguments with argparse (--check, NAME..., allow_abbrev=False), so --help and a mistyped option exit instead of being treated as a shader name.

  • python -I tests/test_regen_fixtures.py: Ran 9 tests, OK.
  • Negative control (tests/semantic/regen_fixtures.py restored from upstream/main): Ran 9 tests, FAILED (failures=3): test_help_and_bad_options_leave_sources_and_fixtures_alone for --help, --chekc and --chec (SystemExit not raised), so the new test discriminates.
  • python -I -m unittest discover -s tests/semantic -p regen_fixtures.py collects 0 tests (it is a script, not a test module); nothing else in that folder imports it.
  • tests/test_docs_*.py with the README change: only the known test_docs_cli_flags (docs/embedded_shaders.md, docs/dev-tools.md) and test_docs_links (docs/dev-tools.md) failures, none in files this PR touches.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested a735c9c 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.

4 participants