test_guest_scene_reference: compare the resolved loader path #320

Closed
Andretuta wants to merge 1 commit from upstream-pr/320 into main
Andretuta commented 2026-11-24 03:08:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T03:08:39Z.


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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465338328 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/320). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T03:08:39Z. --- > 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.
Len1k commented 2026-11-24 08:19:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Len1k on 2026-11-24T08:19:36Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7125998104 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/320#issuecomment-7125998104). Originally posted by [Len1k](https://github.com/Len1k) on 2026-11-24T08:19:36Z. --- 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.*
aslan2142 commented 2026-12-01 11:38:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:38:57Z.


Draft PR review note: this carried-over PR currently conflicts with main in tests/test_guest_scene_reference.py and has no CI run. Note that the resolved-path fixes (report.resolve() and bad_loader.resolve()) have already landed on main (tests/test_guest_scene_reference.py:82,155); only the separate invalid-wine stub and test_launch_failure_records_the_resolved_launcher symlink test remain distinct. Please rebase onto current main (dropping the already-landed hunks), mark ready, and run CI if you still want those additions, or close if no longer needed.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7309932102 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/320#issuecomment-7309932102). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:38:57Z. --- Draft PR review note: this carried-over PR currently conflicts with `main` in `tests/test_guest_scene_reference.py` and has no CI run. Note that the resolved-path fixes (`report.resolve()` and `bad_loader.resolve()`) have already landed on `main` (`tests/test_guest_scene_reference.py:82,155`); only the separate `invalid-wine` stub and `test_launch_failure_records_the_resolved_launcher` symlink test remain distinct. Please rebase onto current `main` (dropping the already-landed hunks), mark ready, and run CI if you still want those additions, or close if no longer needed. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:18:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:18:11Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310938795 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/320#issuecomment-7310938795). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:18:11Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 12:59:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:59:15Z.

Review: CHANGES_REQUESTED


Now ready for review, requesting changes before merge:

  • Merge conflicts (CONFLICTING/DIRTY): conflicts with main in tests/test_guest_scene_reference.py. The core resolved-path comparison has already landed on main; please either rebase keeping only any remaining distinct symlink coverage with green CI, or close if superseded.
  • CI: no CI runs on the current head.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131722318 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/320#pullrequestreview-6131722318). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:59:15Z. **Review:** CHANGES_REQUESTED --- Now ready for review, requesting changes before merge: - **Merge conflicts (`CONFLICTING`/`DIRTY`)**: conflicts with `main` in `tests/test_guest_scene_reference.py`. The core resolved-path comparison has already landed on `main`; please either rebase keeping only any remaining distinct symlink coverage with green CI, or close if superseded. - **CI**: no CI runs on the current head. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 17:20:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:20:36Z.


Closing this PR because it targets the deprecated legacy C++ Vulkan runtime's run_guest_scene test (in favor of the new Rust Vulkan runtime in progress and the Rust DX12 runtime (d3d12/) available now), and its resolved-path fix has already been superseded on main. Thank you for the contribution! If you believe this PR was closed by mistake, please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319146726 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/320#issuecomment-7319146726). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:20:36Z. --- Closing this PR because it targets the deprecated legacy C++ Vulkan runtime's `run_guest_scene` test (in favor of the new Rust Vulkan runtime in progress and the Rust DX12 runtime (`d3d12/`) available now), and its resolved-path fix has already been superseded on `main`. Thank you for the contribution! If you believe this PR was closed by mistake, please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!320
No description provided.