Skip to content

tools, tests: fix six standalone unit tests that fail on Windows - #7425

Open
TricksterG wants to merge 1 commit into
ItsNotRexed:mainfrom
TricksterG:fix/windows-unit-tests
Open

TricksterG wants to merge 1 commit into
ItsNotRexed:mainfrom
TricksterG:fix/windows-unit-tests

Conversation

@TricksterG

Copy link
Copy Markdown
Contributor

Claim: #7333 (comment)

Six standard-library unit tests are red on Windows at 042c5f3 and no open pull request covers them:

  • tools/find_hash_lookup.py: joaat encoded the lower-cased name as UTF-8; hashdict.joaat (the pinned dictionary) uses Latin-1 with replace. Non-ASCII names (café, Señor, ...) hashed differently. Fixes test_joaat_agreement.
  • tools/opus_tags.py, tools/bink_names.py (mount lists), tools/world_names.py: the error line printed str(OSError), which quotes the path with repr() and doubles every backslash of a Windows path. They now print <path>: <strerror> (other errors unchanged). Fixes test_opus_tags, test_bink_names, test_world_names.
  • tools/bcpack_tool.py: the same-input/output guard formatted both paths with !r; now quoted as written. Fixes test_bcpack_tool.
  • tests/test_first_look_paths.py: the fixture checkout lacked tools/report_paths.py, which exe_checklist.py and gdk_runtime_calls.py import, so checklist.md was never written.

Tested on Windows 11, Python 3.14, CPU only (no GPU or game files involved): python -I tests/test_<name>.py for opus_tags, bink_names, world_names, bcpack_tool, joaat_agreement, first_look_paths, find_hash_lookup all pass; python -m compileall -q make_game.py tools tests and scripts/check_no_game_data.py on the changed files are clean. Not run: pytest-based tests, runtime/CMake and GPU tests.

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

🤖 Generated with Claude Code

- find_hash_lookup.joaat hashes the lower-cased name's Latin-1 bytes like
  hashdict.joaat; UTF-8 gave other hashes for non-ASCII names
  (test_joaat_agreement).
- opus_tags, bink_names (mount lists), world_names and bcpack_tool print
  the path as written instead of through repr(), which doubled every
  backslash of a Windows path (test_opus_tags, test_bink_names,
  test_world_names, test_bcpack_tool).
- test_first_look_paths copies tools/report_paths.py, which
  exe_checklist.py and gdk_runtime_calls.py import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent Review of PR #7425

Verdict: LGTM / Approve.

Environment

  • Windows 11 Pro x64, CPython 3.14.3.
  • CPU only; zero game data or GPU hardware needed.
  • Evaluated PR head commit 397c77923 cleanly rebased on origin/main (26ecd9f96, 0 conflicts).

Negative Control Reproduction on main

On current main (26ecd9f96), all six unit tests reproduce the reported failures on Windows:

  1. tests/test_joaat_agreement.py:
    Failed with 6 assertion errors:

    AssertionError: 2425794034 != 4009490211 : find_hash_lookup hashes 'café' differently from hashdict.joaat
    

    Because tools/find_hash_lookup.py:joaat encoded names as UTF-8, while hashdict.joaat encodes as latin-1, replace.

  2. tests/test_bcpack_tool.py:
    Failed with 3 assertion errors (test_decode_refuses_hardlink_output, test_decode_refuses_same_input_output_path, test_decode_refuses_symlink_output):

    AssertionError: '...\link.bcpack' not found in "output path '...\\\\link.bcpack' names the compressed input '...\\\\same.bcpack'; refusing to overwrite it"
    

    !r formatting in tools/bcpack_tool.py:110 doubled backslashes on Windows paths.

  3. tests/test_first_look_paths.py:
    Failed with FileNotFoundError for checklist.md:

    FileNotFoundError: [Errno 2] No such file or directory: '...\checklist.md'
    

    The sandbox checkout fixture was missing tools/report_paths.py, required by exe_checklist.py.

  4. tests/test_opus_tags.py, tests/test_bink_names.py, tests/test_world_names.py:
    Failed with path mismatch assertion errors because str(OSError) on Windows formats error.filename with repr(), doubling backslashes (\\\\).

Verification with PR #7425 Applied

All 6 test suites now pass completely green on Windows 11:

python -I tests/test_joaat_agreement.py     # 2/2 OK (0.12s)
python -I tests/test_bcpack_tool.py         # 18/18 OK (0.22s)
python -I tests/test_first_look_paths.py    # 1/1 OK (3.27s)
python -I tests/test_opus_tags.py           # 20/20 OK (2.33s)
python -I tests/test_bink_names.py          # 33/33 OK (0.27s)
python -I tests/test_world_names.py         # 30/30 OK (0.17s)

Hygiene checks:

  • python -m compileall -q tools/bcpack_tool.py tools/bink_names.py tools/find_hash_lookup.py tools/opus_tags.py tools/world_names.py tests/test_first_look_paths.py -> exit 0.
  • python -I scripts/check_no_game_data.py -> clean, exit 0.
  • Synthetic inputs only; clean room.

AI-assisted.

@leoleahy leoleahy 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.

Independent Windows 11 / Python 3.14.8 review of latest head 911f9d44 (synthetic inputs, CPU only, no game data).

Verification on 911f9d44

  • python -I tests/test_joaat_agreement.py: 2/2 OK (base 042c5f37: 6 failures in find_hash_lookup for non-ASCII names due to UTF-8 vs Latin-1 hashing)
  • python -I tests/test_first_look_paths.py: 1/1 OK (base 042c5f37: 1 error missing tools/report_paths.py)
  • python -I tests/test_bcpack_tool.py: 18 tests run, OK (1 skipped; base 042c5f37: failed on doubled Windows backslashes from repr())
  • python -I tests/test_bink_names.py: 33/33 OK (base 042c5f37: 1 failure on doubled Windows backslashes)
  • python -I tests/test_opus_tags.py: 20/20 OK (base 042c5f37: 1 failure on doubled Windows backslashes)
  • python -I tests/test_world_names.py: 30/30 OK (base 042c5f37: 1 failure on doubled Windows backslashes)
  • python -I tests/test_find_hash_lookup.py: 5/5 OK
  • python -m compileall -q on all 6 touched files and git diff --check 042c5f37..911f9d44: clean.

Scope is tight, matches the Windows OSError / repr() and Latin-1 joaat() root causes, and resolves all six Windows test failures. LGTM.

AI-assisted.

@cloph-dsp

Copy link
Copy Markdown
Contributor

Independent local verification (Windows, Python 3.14.6, synthetic inputs only), head 911f9d4:

  • python -I tests/test_first_look_paths.py — 1 test OK
  • python -I tests/test_bcpack_tool.py — 18 tests OK (1 skipped)
  • python -I tests/test_bink_names.py — 33 tests OK
  • python -I tests/test_find_hash_lookup.py — 5 tests OK
  • python -I tests/test_opus_tags.py — 20 tests OK
  • python -I tests/test_world_names.py — 30 tests OK
  • python -I -m compileall -q tools tests and git diff --check HEAD~1 HEAD — clean

Negative control: the same test_opus_tags.py on upstream main 0c46fa1 fails test_cli_reports_incomplete_directory_discovery (1 failure) because str(OSError) repr-doubles Windows backslashes. With this PR's tools/opus_tags.py change, that test passes. This also clears the failure we had repeatedly flagged as pre-existing in other Python-tool PRs.

Overlap to be aware of: #6049, #5927 and #5760 touch the same five tools for the same repr-path bug and are still open. #6049 centralises the formatting in tools/report_paths.error_text() (including filename2 for renames), while this PR repeats the e.filename/e.strerror branch in each tool and additionally fixes find_hash_lookup.py/test_first_look_paths.py. Not byte-identical, but maintainers should decide which patch lands first; I posted the overlap on the coordination board.

AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only Python tooling). No game data, assets or extracted content used.

@theo-bggtt

Copy link
Copy Markdown

Tested 911f9d4 merged onto main 48ff424 on Windows 11, CPython 3.14.4, CPU only, no game files: pass. This adds the negative control for all seven files, not only opus_tags.

AI-assisted (Claude Code).

@garuspl

garuspl commented Nov 23, 2026

Copy link
Copy Markdown

Tested 911f9d4 on Windows 11 (CPU only, no GPU needed): pass

Windows 11 Pro, Python 3.14.7, CPU only (no GPU or game files involved); pytest/numpy/Pillow pinned from tests/requirements.txt in a fresh venv. Method: PR head merged onto main b03e803, the PR's test files run with python -m pytest before and after the merge, plus python -m compileall -q on the changed files (clean).

  • python -I tests/test_<name>.py for opus_tags, bink_names, world_names, bcpack_tool, joaat_agreement, first_look_paths, find_hash_lookup: on main 6 of 7 fail (find_hash_lookup passes); with the PR all 7 pass.
  • pytest tests/test_first_look_paths.py: main 1 failed, with the PR 1 passed.

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

@Daazd

Daazd commented Nov 23, 2026

Copy link
Copy Markdown

Independent check (Linux, Python 3.12.3, Node 24.13, CPU only, no game files): head 911f9d449 merged onto main 6a4299563: merges clean.

  • python3 -I tests/test_joaat_agreement.py: Ran 2 tests in 0.133s OK (exit 0)
  • python3 -I tests/test_first_look_paths.py: Ran 1 test in 0.000s OK (skipped=1) (exit 0)

Fixes test_joaat_agreement on Linux too (red on main). #4753, #4882 and #6254 also fix it; all four pass.

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.

7 participants