[PR #713] [MERGED] OLD-7087: restore old upstream PR 7087 - audit_shader4_regs: --limit must be at least 1; 0 audited nothing and printed a zero report #750

Closed
opened 2026-11-26 20:18:56 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/713
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: audit-shader4-limit-zero


📝 Commits (1)

  • 165402d audit_shader4_regs: --limit must be at least 1; 0 audited nothing and printed a zero report

📊 Changes

2 files changed (+41 additions, -20 deletions)

View changed files

📝 scripts/audit_shader4_regs.py (+14 -5)
📝 tests/test_audit_shader4_regs.py (+27 -15)

📄 Description

Claimed in the coordination issue as: OLD-7087 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7131734303

Restoration of my original pull request, old upstream PR 7087 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c. The one commit cherry-picked cleanly and is unchanged. The tool is still scripts/audit_shader4_regs.py, as it was in the original. Main has no shared helper for checking that a count is positive, so the PR keeps its own shader_count type function, written like the byte_count in tools/anim_index.py.

What and why

  • On main, --limit 0 passes the non-negative check, and files[:0] keeps no listing.
  • The tool then prints === CS (0 shaders; ...) === for every stage and exits 0. A typo gives an empty audit that looks real.
  • --limit now takes a shader_count type: a value below 1 or a non-number is an argparse error that names the option, with exit 2 and no report or JSON written.
  • audit() raises ValueError for a limit below 1, so callers that bypass the command line get the same check.
  • No limit (the default None) still audits everything.

Tested

Linux, Python 3.14.10, CPU only, synthetic inputs (hand-written .s listings in temporary folders, no game files).

  • python -I tests/test_audit_shader4_regs.py: 20 tests, OK. On main the same 20 pass, but with this PR's test changes 5 subtests fail (--limit 0, -1 and x; audit() with 0 and -1).
  • New cases: --limit 0, -1 and x exit 2 with nothing on stdout and no JSON. --limit 1 on a folder with two listings audits one. --limit 2 and --limit 3 audit both.
  • The JSON-refusal test used --limit 0 to leave the listing out. It now adds a second listing that sorts first and uses --limit 1.
  • python -m compileall -q tools tests scripts, git diff --check and python -I scripts/check_no_game_data.py on the two changed files: all clean.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/713 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `audit-shader4-limit-zero` --- ### 📝 Commits (1) - [`165402d`](https://github.com/ubiquitarianism/leonida/commit/165402ddebb9f3a7e0cfc26b5223d9add488071b) audit_shader4_regs: --limit must be at least 1; 0 audited nothing and printed a zero report ### 📊 Changes **2 files changed** (+41 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `scripts/audit_shader4_regs.py` (+14 -5) 📝 `tests/test_audit_shader4_regs.py` (+27 -15) </details> ### 📄 Description Claimed in the coordination issue as: OLD-7087 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7131734303 Restoration of my original pull request, old upstream PR 7087 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c675c62f9dbffc318ce6a59d57faf31. The one commit cherry-picked cleanly and is unchanged. The tool is still `scripts/audit_shader4_regs.py`, as it was in the original. Main has no shared helper for checking that a count is positive, so the PR keeps its own `shader_count` type function, written like the `byte_count` in `tools/anim_index.py`. ### What and why - On main, `--limit 0` passes the non-negative check, and `files[:0]` keeps no listing. - The tool then prints `=== CS (0 shaders; ...) ===` for every stage and exits 0. A typo gives an empty audit that looks real. - `--limit` now takes a `shader_count` type: a value below 1 or a non-number is an argparse error that names the option, with exit 2 and no report or JSON written. - `audit()` raises `ValueError` for a limit below 1, so callers that bypass the command line get the same check. - No limit (the default `None`) still audits everything. ### Tested Linux, Python 3.14.10, CPU only, synthetic inputs (hand-written `.s` listings in temporary folders, no game files). - `python -I tests/test_audit_shader4_regs.py`: 20 tests, OK. On main the same 20 pass, but with this PR's test changes 5 subtests fail (`--limit 0`, `-1` and `x`; `audit()` with 0 and -1). - New cases: `--limit 0`, `-1` and `x` exit 2 with nothing on stdout and no JSON. `--limit 1` on a folder with two listings audits one. `--limit 2` and `--limit 3` audit both. - The JSON-refusal test used `--limit 0` to leave the listing out. It now adds a second listing that sorts first and uses `--limit 1`. - `python -m compileall -q tools tests scripts`, `git diff --check` and `python -I scripts/check_no_game_data.py` on the two changed files: all clean. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:56 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#750
No description provided.