pe_inspect: reject missing --game-dir before scanning images #492

Open
github-bot wants to merge 1 commit from github-bot/gh-492 into main AGit
Owner

@⁠kotekompotek on GitHub · 2026-11-24 06:21 UTC · original
kotekompotek:work/pe-inspect-validate-game-dir → main · +51 −0 · 2 files · 1 commits · open

Claimed in the coordination issue as: TOOL-PE-INSPECT-GAMEDIR (#14)

What and why

  • Rebased onto current main and squashed into one clean commit.
  • Validated --game-dir in tools/pe_inspect.py before scanning images and added regression tests in tests/test_pe_inspect_game_dir.py.

Tested

  • python -I tests/test_pe_inspect_game_dir.py (2/2 OK) on commit 17d5b5134.
  • All 12 tests/test_docs_*.py (OK) on commit 17d5b5134.

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.
**@⁠kotekompotek** on GitHub · 2026-11-24 06:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/492) `kotekompotek:work/pe-inspect-validate-game-dir` → `main` · +51 −0 · 2 files · 1 commits · open Claimed in the coordination issue as: TOOL-PE-INSPECT-GAMEDIR (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why - Rebased onto current `main` and squashed into one clean commit. - Validated `--game-dir` in `tools/pe_inspect.py` before scanning images and added regression tests in `tests/test_pe_inspect_game_dir.py`. ### Tested - `python -I tests/test_pe_inspect_game_dir.py` (`2/2 OK`) on commit `17d5b5134`. - All 12 `tests/test_docs_*.py` (`OK`) on commit `17d5b5134`. 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:03:59 +00:00
Author
Owner

@⁠Len1k on GitHub · 2026-11-24 07:34 UTC · original

Heads-up on the test this adds, from running it both ways.

I swapped tools/pe_inspect.py back to this branch's base commit, kept tests/test_pe_inspect_game_dir.py as it is, and ran it: Ran 1 test ... OK. The test passes without the change.

Why: it asserts rc == 2 and "does not exist" in stderr. Without your check, main() falls through to the missing-image branch, which prints ERROR: {img}: does not exist and returns the same 2 — both assertions are satisfied by the older code path.

Two ways to pin it:

  • assert on the wording only your branch produces, e.g. "--game-dir" and the path in the message;
  • or pass an --image that exists (an empty file is enough, since the validation should fire before the image is read), so the missing-image branch cannot return 2.

Rest of the branch is fine — the check itself is a good addition, it just is not covered yet. AI-assisted.

**@⁠Len1k** on GitHub · 2026-11-24 07:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/492#issuecomment-7125130934) Heads-up on the test this adds, from running it both ways. I swapped `tools/pe_inspect.py` back to this branch's base commit, kept `tests/test_pe_inspect_game_dir.py` as it is, and ran it: **`Ran 1 test ... OK`**. The test passes without the change. Why: it asserts `rc == 2` and `"does not exist"` in stderr. Without your check, `main()` falls through to the missing-image branch, which prints `ERROR: {img}: does not exist` and returns the same `2` — both assertions are satisfied by the older code path. Two ways to pin it: - assert on the wording only your branch produces, e.g. `"--game-dir"` and the path in the message; - or pass an `--image` that exists (an empty file is enough, since the validation should fire before the image is read), so the missing-image branch cannot return 2. Rest of the branch is fine — the check itself is a good addition, it just is not covered yet. *AI-assisted.*
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-24 18:30 UTC · original

@⁠Len1k Fixed in commit 17d5b5134: updated tests/test_pe_inspect_game_dir.py so img.exe is created as a real existing file before testing a missing --game-dir and a regular-file --game-dir, asserting exit code 2 and that out_dir is not created. Re-verified python -I tests/test_pe_inspect_game_dir.py (2/2 OK) and all 12 tests/test_docs_*.py (OK).

**@⁠kotekompotek** on GitHub · 2026-11-24 18:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/492#issuecomment-7140742915) @⁠Len1k Fixed in commit `17d5b5134`: updated `tests/test_pe_inspect_game_dir.py` so `img.exe` is created as a real existing file before testing a missing `--game-dir` and a regular-file `--game-dir`, asserting exit code `2` and that `out_dir` is not created. Re-verified `python -I tests/test_pe_inspect_game_dir.py` (2/2 OK) and all 12 `tests/test_docs_*.py` (OK).
Author
Owner

@⁠NinsonD on GitHub · 2026-11-25 08:58 UTC · original

I independently checked the updated regression tests at 17d5b5134 on Windows using synthetic files.

  • With the PR’s --game-dir validation present: 2 tests passed.
  • With only that validation removed from an isolated copy: both tests failed, returning 1 instead of the expected 2.

This supports that the updated tests catch the behavior discussed in the earlier review. I tested the two relevant files only, not the full repository suite.

AI-assisted review and testing.

**@⁠NinsonD** on GitHub · 2026-11-25 08:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/492#issuecomment-7157706957) I independently checked the updated regression tests at `17d5b5134` on Windows using synthetic files. - With the PR’s `--game-dir` validation present: 2 tests passed. - With only that validation removed from an isolated copy: both tests failed, returning 1 instead of the expected 2. This supports that the updated tests catch the behavior discussed in the earlier review. I tested the two relevant files only, not the full repository suite. AI-assisted review and testing.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 09:40 UTC · original

Rebased onto current main (a104a898c) — the macos-python/check/label runs on the old head had been cancelled before finishing, so this push also re-triggers a full check set. test_pe_inspect_game_dir.py: 2/2 OK locally after the rebase.

**@⁠kotekompotek** on GitHub · 2026-11-25 09:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/492#issuecomment-7158648965) Rebased onto current main (`a104a898c`) — the macos-python/check/label runs on the old head had been cancelled before finishing, so this push also re-triggers a full check set. `test_pe_inspect_game_dir.py`: 2/2 OK locally after the rebase.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/492/head:github-bot/gh-492'
git switch 'github-bot/gh-492'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-492'
git switch 'github-bot/gh-492'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-492'
git switch 'github-bot/gh-492'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-492'
git switch 'main'
git merge --squash 'github-bot/gh-492'
git switch 'main'
git merge --ff-only 'github-bot/gh-492'
git switch 'main'
git merge 'github-bot/gh-492'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.