xtask: check documented switches are read #3539

Open
tharun-37 wants to merge 1 commit from upstream-pr/3539 into main
tharun-37 commented 2026-11-27 15:39:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tharun-37 on 2026-11-27T15:39:19Z.


Adds cargo xtask check-switches and runs it from the pre-commit hook after the asset-policy check.

The checker extracts concrete VICTORY_* names from README.md and docs/**/*.md, then verifies each is passed to an environment read in Rust source (var, var_os, switch::on, env!, and the existing env_path/numbers helpers). Comments and writes such as set_var or .env(...) do not count. Wildcards and lowercase names are ignored, and duplicate doc mentions yield one diagnostic.

The current tree passes with 29 documented names. Six synthetic tests cover direct reads, helpers, comments, writes, similar names, duplicate mentions, and line-number reporting. No game data, generated files, shader names or hashes are involved.

Verification:

  • cargo test -p xtask: 13 passed, 0 failed.
  • cargo xtask check-switches: 29 names ok.
  • cargo clippy --workspace --all-targets --locked -- -D warnings passes.
  • cargo xtask policy: 192 files ok.
  • Full workspace tests still show the same 3 pre-existing victory-gpu failures.

Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7222166364

AI-assisted (OpenCode).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5529280645 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3539). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-11-27T15:39:19Z. --- Adds `cargo xtask check-switches` and runs it from the pre-commit hook after the asset-policy check. The checker extracts concrete `VICTORY_*` names from `README.md` and `docs/**/*.md`, then verifies each is passed to an environment read in Rust source (`var`, `var_os`, `switch::on`, `env!`, and the existing `env_path`/`numbers` helpers). Comments and writes such as `set_var` or `.env(...)` do not count. Wildcards and lowercase names are ignored, and duplicate doc mentions yield one diagnostic. The current tree passes with 29 documented names. Six synthetic tests cover direct reads, helpers, comments, writes, similar names, duplicate mentions, and line-number reporting. No game data, generated files, shader names or hashes are involved. Verification: - `cargo test -p xtask`: 13 passed, 0 failed. - `cargo xtask check-switches`: 29 names ok. - `cargo clippy --workspace --all-targets --locked -- -D warnings` passes. - `cargo xtask policy`: 192 files ok. - Full workspace tests still show the same 3 pre-existing `victory-gpu` failures. Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7222166364 AI-assisted (OpenCode).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3539:upstream-pr/3539'
git switch 'upstream-pr/3539'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3539'
git switch 'upstream-pr/3539'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3539'
git switch 'upstream-pr/3539'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3539'
git switch 'main'
git merge --squash 'upstream-pr/3539'
git switch 'main'
git merge --ff-only 'upstream-pr/3539'
git switch 'main'
git merge 'upstream-pr/3539'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3539
No description provided.