test_guest_scene_reference: compare the resolved loader path #320

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

@⁠Andretuta on GitHub · 2026-11-24 03:08 UTC · original
ubiquitarianism:old-pr/10055 → main · +52 −3 · 1 files · 1 commits · draft

Carried over from old PR 10055 by wavehs in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10055, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
wavehs: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Re-lands the fix from the closed #8514 (6fa2c8cac) on current main, where tests/test_guest_scene_reference.py::test_launch_failure_preserves_run_record_and_logs still fails:

AssertionError: '/private/var/...invalid.exe' != '/var/...invalid.exe'
Ran 7 tests ... FAILED (failures=1)

Session.run gets resolved paths (scripts/run_guest_scene.py:341), and macOS reaches the temp directory through /var, a symlink to /private/var. The test compared the record to the unresolved spelling.

Coordination claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117112264

What changed

  • The launcher assertion compares record["cmd"][loader_index] to str(bad_loader.resolve()).
  • POSIX uses a wine stub separate from the loader: Session.run builds [wine, *wine_args, loader, …], so cmd[0] is the wine path — comparing it would leave the loader's resolve unfalsifiable (YordiLorenzo's finding on #8514). loader_index is computed from the wine args that main now supports, and their cmd[1:3] assertion is kept.
  • The redirected-CLI assertion uses str(report.resolve()), for a junctioned or symlinked --out.
  • A new test_launch_failure_records_the_resolved_launcher uses a symlinked root, so the contract is pinned on hosts where the temp directory is not already a symlink (skipped where symlinks cannot be created).

Tested

macOS 27.2.1, Apple M3 Pro, CPython 3.15.2, synthetic inputs, no game files:

  • python -I tests/test_guest_scene_reference.py → 7 tests OK, and 7 OK again with a symlinked TMPDIR.
  • Negative control, args.loader left unresolved at run_guest_scene.py:341: 2 tests fail (test_launch_failure_preserves_run_record_and_logs, test_launch_failure_records_the_resolved_launcher).
  • python -m compileall -q make_game.py tools tests, python -I scripts/check_no_game_data.py tests/test_guest_scene_reference.py, git diff --check: clean.
**@⁠Andretuta** on GitHub · 2026-11-24 03:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/320) `ubiquitarianism:old-pr/10055` → `main` · +52 −3 · 1 files · 1 commits · draft > Carried over from **old PR 10055** by `wavehs` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10055`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `wavehs`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Re-lands the fix from the closed `#8514` (`6fa2c8cac`) on current `main`, where `tests/test_guest_scene_reference.py::test_launch_failure_preserves_run_record_and_logs` still fails: ``` AssertionError: '/private/var/...invalid.exe' != '/var/...invalid.exe' Ran 7 tests ... FAILED (failures=1) ``` `Session.run` gets resolved paths (`scripts/run_guest_scene.py:341`), and macOS reaches the temp directory through `/var`, a symlink to `/private/var`. The test compared the record to the unresolved spelling. Coordination claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117112264 ### What changed - The launcher assertion compares `record["cmd"][loader_index]` to `str(bad_loader.resolve())`. - POSIX uses a wine stub **separate** from the loader: `Session.run` builds `[wine, *wine_args, loader, …]`, so `cmd[0]` is the wine path — comparing it would leave the loader's resolve unfalsifiable (YordiLorenzo's finding on `#8514`). `loader_index` is computed from the wine args that main now supports, and their `cmd[1:3]` assertion is kept. - The redirected-CLI assertion uses `str(report.resolve())`, for a junctioned or symlinked `--out`. - A new `test_launch_failure_records_the_resolved_launcher` uses a symlinked root, so the contract is pinned on hosts where the temp directory is *not* already a symlink (skipped where symlinks cannot be created). ### Tested macOS 27.2.1, Apple M3 Pro, CPython 3.15.2, synthetic inputs, no game files: - `python -I tests/test_guest_scene_reference.py` → **7 tests OK**, and **7 OK** again with a symlinked `TMPDIR`. - Negative control, `args.loader` left unresolved at `run_guest_scene.py:341`: **2 tests fail** (`test_launch_failure_preserves_run_record_and_logs`, `test_launch_failure_records_the_resolved_launcher`). - `python -m compileall -q make_game.py tools tests`, `python -I scripts/check_no_game_data.py tests/test_guest_scene_reference.py`, `git diff --check`: clean.
main: the run record keeps the loader as Session.run got it, and main.py
resolves args.loader, guest and shaders before launching. The test asserts
record["cmd"][0] against the unresolved spelling, so macOS fails through
its /var -> /private/var temporary directory.

Assert the resolved path at the loader's own index: with --wine the
command starts [wine, *wine_args, loader, ...], so the test now names a
wine stub separate from the loader and computes the index from the wine
args, instead of comparing cmd[0] (the wine path) by accident.

Also assert the redirected-CLI report path resolves (a junctioned or
symlinked --out prints the target), and add a symlinked-root regression
test that pins the same contract without depending on the host volume.

Negative control: leaving args.loader unresolved fails both tests; with
the code intact 7 tests pass, also with a symlinked TMPDIR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:53:13 +00:00
Author
Owner

@⁠Len1k on GitHub · 2026-11-24 08:19 UTC · original

Ran this branch's test file on its head: Ran 7 tests in 3.0 s → FAILED (errors=1). The failure is not yours — test_launch_failure_preserves_run_record_and_logs errors the same way on main (Ran 6 tests ... FAILED (errors=1), same test, so it predates your branch).

Underneath it: the test runs the child with subprocess.run(..., capture_output=True, encoding="utf-8"). On a Windows console whose code page is cp1251 the child echoes non-UTF-8 bytes, the decoder raises inside subprocess's reader thread, and result.stdout ends up None; the assertion message then does result.stdout + result.stderr and raises TypeError instead. So the visible error hides the real one.

Reproduced without unittest:

rc 1
stdout type <class 'NoneType'> None
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position 105

Two small changes fix it for everyone on Windows: errors="replace" on that subprocess.run, and (result.stdout or "") + (result.stderr or "") for the message. I filed it against main in the coordination issue so it is not mistaken for a regression in this pull request.

Your own change is green: the sixth test on main becomes seven here, and the added loader-path comparison passes.

AI-assisted.

**@⁠Len1k** on GitHub · 2026-11-24 08:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/320#issuecomment-7125998104) Ran this branch's test file on its head: `Ran 7 tests in 3.0 s` → `FAILED (errors=1)`. **The failure is not yours** — `test_launch_failure_preserves_run_record_and_logs` errors the same way on `main` (`Ran 6 tests ... FAILED (errors=1)`, same test, so it predates your branch). Underneath it: the test runs the child with `subprocess.run(..., capture_output=True, encoding="utf-8")`. On a Windows console whose code page is cp1251 the child echoes non-UTF-8 bytes, the decoder raises inside `subprocess`'s reader thread, and `result.stdout` ends up `None`; the assertion message then does `result.stdout + result.stderr` and raises `TypeError` instead. So the visible error hides the real one. Reproduced without unittest: ``` rc 1 stdout type <class 'NoneType'> None UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position 105 ``` Two small changes fix it for everyone on Windows: `errors="replace"` on that `subprocess.run`, and `(result.stdout or "") + (result.stderr or "")` for the message. I filed it against `main` in the coordination issue so it is not mistaken for a regression in this pull request. Your own change is green: the sixth test on `main` becomes seven here, and the added loader-path comparison passes. *AI-assisted.*
This pull request has changes conflicting with the target branch.
  • tests/test_guest_scene_reference.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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