Skip to content

test: capture guest launch errors as bytes - #7027

Closed
Flyander wants to merge 1 commit into
ItsNotRexed:mainfrom
Flyander:codex/guest-scene-cp1252
Closed

Flyander wants to merge 1 commit into
ItsNotRexed:mainfrom
Flyander:codex/guest-scene-cp1252

Conversation

@Flyander

@Flyander Flyander commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claim: #6910 comment

What changed

The launch-failure test runs a synthetic invalid executable. On Windows, CreateProcess diagnostics use the active code page, so forcing the parent subprocess.run to decode as UTF-8 can raise UnicodeDecodeError before the test checks the run record. Capture stdout/stderr as bytes instead.

Validation

  • Before the change, python -I tests/test_guest_scene_reference.py -v failed on Windows 11 / CPython 3.12.10 (cp1252) with UnicodeDecodeError in the subprocess reader and then a TypeError in the assertion.
  • After the change, the same command passes: 5 tests.
  • Rebased head 2e471196 onto main b03e803a and reran python -I tests/test_guest_scene_reference.py -v: 5/5 passed.
  • git diff --check: pass.

GPU/driver: none (CPU-only). No game data used.

AI-assisted (OpenAI Codex).

Depends on: #6924 (merged).

@kapitche

Copy link
Copy Markdown
Contributor

Tested d300336 merged with main 8575d36 on Windows/Python 3.13.1: concern

The PR changes only tests/test_guest_scene_reference.py (drops encoding="utf-8" from the subprocess.run that launches the runner with a loader that cannot start, so a non-UTF-8 Windows code-page diagnostic is not decoded as UTF-8). The change cannot be shown to matter on this machine:

  • Windows/Python 3.13.1 (native, scratch worktree with the merged test and main's scripts/): python -I tests\test_guest_scene_reference.py -> Ran 5 tests, OK
  • Same machine with main's version of the test file: Ran 5 tests, OK
  • Linux/Python 3.12.16, merged tree: python -I tests/test_guest_scene_reference.py -> Ran 5 tests, OK

The PR touches no non-test file, and main's test also passes here, because the error text from CreateProcess on this system is plain ASCII; the decode error needs a localized (non-UTF-8, non-ASCII) message, which I could not produce. So I can confirm the PR does not break anything, but not that it fixes the failure it describes. The diff itself is two lines and looks right: result.stdout + result.stderr in the assertion message now concatenates bytes, which is fine as an assertEqual msg, and read_text(encoding="utf-8") on report.json is unchanged.

@Flyander

Copy link
Copy Markdown
Contributor Author

Thanks for checking. I can reproduce the locale-dependent failure on Windows 11 / CPython 3.12.10 (locale.getpreferredencoding(False) == "cp1252"). At the exact base commit 8575d36edc, python -I tests/test_guest_scene_reference.py -v fails test_launch_failure_preserves_run_record_and_logs: the subprocess reader raises UnicodeDecodeError on byte 0x92, then the assertion hits TypeError because stdout is None. On PR head d3003366fe08, the same command passes 5/5. The test uses only a synthetic invalid executable; no game files.

So the English/ASCII run you saw is consistent with the failure being locale-specific. The head tested here is the same one in this PR.

@memorypressure

Copy link
Copy Markdown

Tested d300336 merged with main 8575d36, after #6691's make_game CLI changes landed: test_guest_scene_reference passes Ran 5 OK. Honest limitation noted in your favor: the byte-capture fix is only observable on Windows code pages — on Linux pre and post behave identically, so no red-on-main demonstration exists here; the windows CI job is the real gate. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@Flyander
Flyander force-pushed the codex/guest-scene-cp1252 branch from d300336 to 2e47119 Compare November 23, 2026 16:49
@hcampbell98

Copy link
Copy Markdown

Tested 2e47119 merged with main 5e54bda on Linux (WSL2, CPython 3.12.13 and 3.14.4, CPU-only, no game files): pass

  • tests/test_guest_scene_reference.py: 5/5 OK (8 subtests in pytest -q) under CPython 3.12.13 (-I), CPython 3.14.4 (-I), and pytest; check_no_game_data.py, compileall -q, and git diff --check clean.
  • Synthetic non-UTF-8 stderr check: when wrapping run_guest_scene.py so child stderr writes raw cp1252 byte 0x92, test_launch_failure_preserves_run_record_and_logs crashes on 5e54bda (UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 7) and passes (Ran 1 test ... OK) on 2e47119.
  • Limit: Linux host emits UTF-8 OS diagnostics natively, so the non-UTF-8 failure path was reproduced synthetically on stderr rather than via native Windows CreateProcess.

AI-assisted.

@Flyander

Copy link
Copy Markdown
Contributor Author

Superseded by #7635, which covers the same localized Windows launch-diagnostic failure with a native pt-BR reproduction. Both fixes address the same test line; closing this to avoid duplicate review. Thanks.

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