run_wine_tests: keep going when the drive cannot be mapped (WINE-DRIVE-MAP-OSERROR) #919

Merged
TuroYT merged 1 commit from upstream-pr/919 into main 2026-11-29 01:32:14 +00:00
TuroYT commented 2026-11-24 15:11:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TuroYT on 2026-11-24T15:11:45Z.


Claimed in the coordination issue as: WINE-DRIVE-MAP-OSERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135519009)

What was wrong

scripts/run_wine_tests.py, DriveMap.__enter__ (around line 102 before this change). It handled only FileExistsError around os.symlink. Any other OSError, such as PermissionError from a read-only Wine prefix, escaped __enter__ and aborted main with a traceback before any test started. The other OSError handlers in the file print a message and return.

Reproduction on the unfixed branch (uid 1000, not root):

mkdir -p prefix/dosdevices && chmod 555 prefix/dosdevices
echo '{"tests": []}' > ctest.json
WINEPREFIX=prefix python3 -I scripts/run_wine_tests.py --tests ctest.json --windows-root 'D:/a/Leonida/Leonida' --root .

Output: a PermissionError: [Errno 13] Permission denied traceback from __enter__ at line 102, exit status 1.

What changed

  • DriveMap.__enter__ wraps the mapping in except OSError as e. It sets self.note to cannot map drive d: <strerror>: the run goes on without it, and returns unmapped. The existing finally removes the scratch folder. The FileExistsError path is unchanged.
  • The docstring says the same.
  • tests/test_run_wine_tests.py: the old test test_failed_drive_setup_removes_scratch_directory asserted the traceback, so it is replaced by test_an_unwritable_prefix_is_noted_and_the_run_goes_on_unmapped. It patches os.symlink to raise PermissionError and checks the note, drive.link is None, the removed scratch folder and that __enter__ does not raise. A new test, test_a_scratch_folder_that_cannot_be_made_is_noted_too, covers mkdtemp failing.

Tested

  • Same reproduction after the fix: prints cannot map drive d: Permission denied: the run goes on without it, then 0 passed, 0 failed, 0 skipped under Wine (0 tests), exit status 0. No wine-drive-* folder is left in /tmp.
  • python3 -I tests/test_run_wine_tests.py: Ran 64 tests ... OK after the fix.
  • The two new tests with scripts/run_wine_tests.py restored to origin/main: FAILED (errors=2), both new tests error on the unfixed code.
  • Edge cases run by hand: makedirs failing after the scratch folder is made (scratch removed, dosdevices left empty), D:/ root with symlink failing, an OSError with no strerror (message falls back to str(e)).
  • python3 -m compileall -q scripts tests: ok.
  • python3 -I tests/test_text_write_line_endings.py: OK.
  • python3 -I scripts/check_no_game_data.py scripts/run_wine_tests.py tests/test_run_wine_tests.py: exit 0.
  • git diff --check: clean.
  • python3 -I tests/test_run_wine_test_fixtures.py: Ran 6 tests ... OK.
  • python3 -I tests/test_tool_stdout_encoding.py: 1 failure, tools/native_pso_hashes.py is not a main block that sets errors='replace'. That file is not in this change. I did not run that test on origin/main.

Not tested: real Wine, Windows and macOS runs. The unit tests patch os.symlink; the real permission case was checked only by the manual reproduction above, which used a read-only folder as uid 1000.

Other PRs: PR #756 changes scripts/run_wine_tests.py at the end of the file (the __main__ block, after line 410). This PR changes lines 67 to 110. The hunks do not overlap.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474858419 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/919). Originally posted by [TuroYT](https://github.com/TuroYT) on 2026-11-24T15:11:45Z. --- Claimed in the coordination issue as: WINE-DRIVE-MAP-OSERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135519009) ## What was wrong `scripts/run_wine_tests.py`, `DriveMap.__enter__` (around line 102 before this change). It handled only `FileExistsError` around `os.symlink`. Any other `OSError`, such as `PermissionError` from a read-only Wine prefix, escaped `__enter__` and aborted `main` with a traceback before any test started. The other `OSError` handlers in the file print a message and return. Reproduction on the unfixed branch (uid 1000, not root): ``` mkdir -p prefix/dosdevices && chmod 555 prefix/dosdevices echo '{"tests": []}' > ctest.json WINEPREFIX=prefix python3 -I scripts/run_wine_tests.py --tests ctest.json --windows-root 'D:/a/Leonida/Leonida' --root . ``` Output: a `PermissionError: [Errno 13] Permission denied` traceback from `__enter__` at line 102, exit status 1. ## What changed - `DriveMap.__enter__` wraps the mapping in `except OSError as e`. It sets `self.note` to `cannot map drive d: <strerror>: the run goes on without it`, and returns unmapped. The existing `finally` removes the scratch folder. The `FileExistsError` path is unchanged. - The docstring says the same. - `tests/test_run_wine_tests.py`: the old test `test_failed_drive_setup_removes_scratch_directory` asserted the traceback, so it is replaced by `test_an_unwritable_prefix_is_noted_and_the_run_goes_on_unmapped`. It patches `os.symlink` to raise `PermissionError` and checks the note, `drive.link is None`, the removed scratch folder and that `__enter__` does not raise. A new test, `test_a_scratch_folder_that_cannot_be_made_is_noted_too`, covers `mkdtemp` failing. ## Tested - Same reproduction after the fix: prints `cannot map drive d: Permission denied: the run goes on without it`, then `0 passed, 0 failed, 0 skipped under Wine (0 tests)`, exit status 0. No `wine-drive-*` folder is left in `/tmp`. - `python3 -I tests/test_run_wine_tests.py`: `Ran 64 tests ... OK` after the fix. - The two new tests with `scripts/run_wine_tests.py` restored to origin/main: `FAILED (errors=2)`, both new tests error on the unfixed code. - Edge cases run by hand: `makedirs` failing after the scratch folder is made (scratch removed, `dosdevices` left empty), `D:/` root with `symlink` failing, an `OSError` with no `strerror` (message falls back to `str(e)`). - `python3 -m compileall -q scripts tests`: ok. - `python3 -I tests/test_text_write_line_endings.py`: OK. - `python3 -I scripts/check_no_game_data.py scripts/run_wine_tests.py tests/test_run_wine_tests.py`: exit 0. - `git diff --check`: clean. - `python3 -I tests/test_run_wine_test_fixtures.py`: `Ran 6 tests ... OK`. - `python3 -I tests/test_tool_stdout_encoding.py`: 1 failure, `tools/native_pso_hashes.py` is not a main block that sets `errors='replace'`. That file is not in this change. I did not run that test on origin/main. Not tested: real Wine, Windows and macOS runs. The unit tests patch `os.symlink`; the real permission case was checked only by the manual reproduction above, which used a read-only folder as uid 1000. Other PRs: PR #756 changes `scripts/run_wine_tests.py` at the end of the file (the `__main__` block, after line 410). This PR changes lines 67 to 110. The hunks do not overlap. AI-assisted (Claude Code).
PierreEbele commented 2026-11-25 21:21:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T21:21:50Z.


Reviewed 3de809cf: DriveMap now notes and survives real OSErrors instead of aborting. The PR's 64 tests pass on its tree; copied to main, its two DriveMap tests fail there as expected (main still raises), so they test the fix. A no-mock probe on both trees (read-only dosdevices, unusable temp dir, end-to-end runner) shows main aborting with a traceback and exit 1 before any test, while this branch notes why, cleans up the scratch folder and finishes with "[PASS] ok"; control mapping unchanged. The branch is older than main's wineserver/--jobs work but merges cleanly into current main, where the suite passes (3 wineserver errors in my environment are environmental and present on main without this PR). AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174976188 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/919#issuecomment-7174976188). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T21:21:50Z. --- Reviewed 3de809cf: DriveMap now notes and survives real OSErrors instead of aborting. The PR's 64 tests pass on its tree; copied to main, its two DriveMap tests fail there as expected (main still raises), so they test the fix. A no-mock probe on both trees (read-only dosdevices, unusable temp dir, end-to-end runner) shows main aborting with a traceback and exit 1 before any test, while this branch notes why, cleans up the scratch folder and finishes with "[PASS] ok"; control mapping unchanged. The branch is older than main's wineserver/--jobs work but merges cleanly into current main, where the suite passes (3 wineserver errors in my environment are environmental and present on main without this PR). AI-assisted review. **Recommendation:** Merge
OreoFR commented 2026-11-28 21:45:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:45:20Z.


Verified by OreoFR

Run 1 (win02)

  • Base: main 5cb45921e + PR head 3de809cf6
  • Test: python -I tests/test_run_wine_tests.py
  • Red on main: 79 OK (14 skipped)
  • Green with the PR: 79 OK (14 skipped)
  • Verdict: NO RED (DriveMapTest is skipped on Windows ("for Linux and macOS"): the PR's case is not exercised here; same result as lot O, redone on a newer main)

Run 2 (lot O)

  • Base: main 4a54aedcb + PR head 3de809cf6
  • Test: python -I tests/test_run_wine_tests.py
  • Red on main: OK (13 skipped)
  • Green with the PR: OK (13 skipped)
  • Verdict: NO RED (DriveMapTest is skipped on Windows; to test on Linux/macOS)

All runs

  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246248054 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/919#issuecomment-7246248054). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:45:20Z. --- **Verified by OreoFR** **Run 1 (win02)** - Base: main `5cb45921e` + PR head `3de809cf6` - Test: `python -I tests/test_run_wine_tests.py` - Red on main: 79 OK (14 skipped) - Green with the PR: 79 OK (14 skipped) - Verdict: NO RED (DriveMapTest is skipped on Windows ("for Linux and macOS"): the PR's case is not exercised here; same result as lot O, redone on a newer main) **Run 2 (lot O)** - Base: main `4a54aedcb` + PR head `3de809cf6` - Test: `python -I tests/test_run_wine_tests.py` - Red on main: OK (13 skipped) - Green with the PR: OK (13 skipped) - Verdict: NO RED (DriveMapTest is skipped on Windows; to test on Linux/macOS) **All runs** - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-29 01:25:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:25:42Z.


#919 | head 3de809cf6d (merged cleanly onto origin/main 5825b02ff8) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11)

  • Diff & safety audit: Inspected 100% of the diff across scripts/run_wine_tests.py (except OSError as e: in DriveMap.__enter__ recording self.note and letting finally: clean up self.scratch when self.link is None) and tests/test_run_wine_tests.py. python -I scripts/check_no_game_data.py scripts/run_wine_tests.py tests/test_run_wine_tests.py passed (rc=0).
  • Red -> Green on Windows 11:
    • Red (origin/main 5825b02ff8): Exercising DriveMap.__enter__ directly when os.symlink raises PermissionError(13, "Permission denied") propagated an unhandled PermissionError aborting the run.
    • Green (#919 + origin/main):
      • python -I tests/test_run_wine_tests.py -> 79 ran, OK (skipped=14) (7.893s on native Windows 11; the 14 POSIX Wine prefix/symlink tests skip cleanly on nt).
      • Direct DriveMap.__enter__ probe on Windows 11: Exercised both os.symlink PermissionError(13, "Permission denied") (drive.note == "cannot map drive q: Permission denied: the run goes on without it", drive.link is None, scratch directory removed by finally:) and tempfile.mkdtemp OSError(28, "No space left on device") (drive.note == "cannot map drive q: No space left on device: the run goes on without it", drive.scratch is None).
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248775571 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/919#issuecomment-7248775571). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:25:42Z. --- #919 | head 3de809cf6db9507ca679c5f2ca0919abe98b75b6 (merged cleanly onto origin/main 5825b02ff8) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes ### Independent Verification (Windows 11) - **Diff & safety audit**: Inspected 100% of the diff across `scripts/run_wine_tests.py` (`except OSError as e:` in `DriveMap.__enter__` recording `self.note` and letting `finally:` clean up `self.scratch` when `self.link is None`) and `tests/test_run_wine_tests.py`. `python -I scripts/check_no_game_data.py scripts/run_wine_tests.py tests/test_run_wine_tests.py` passed (`rc=0`). - **Red -> Green on Windows 11**: - **Red (`origin/main` `5825b02ff8`)**: Exercising `DriveMap.__enter__` directly when `os.symlink` raises `PermissionError(13, "Permission denied")` propagated an unhandled `PermissionError` aborting the run. - **Green (`#919 + origin/main`)**: - `python -I tests/test_run_wine_tests.py` -> `79 ran, OK (skipped=14)` (`7.893s` on native Windows 11; the 14 POSIX Wine prefix/symlink tests skip cleanly on `nt`). - **Direct `DriveMap.__enter__` probe on Windows 11**: Exercised both `os.symlink` `PermissionError(13, "Permission denied")` (`drive.note == "cannot map drive q: Permission denied: the run goes on without it"`, `drive.link is None`, `scratch` directory removed by `finally:`) and `tempfile.mkdtemp` `OSError(28, "No space left on device")` (`drive.note == "cannot map drive q: No space left on device: the run goes on without it"`, `drive.scratch is None`).
OreoFR commented 2026-11-29 01:26:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:26:08Z.


Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df14 : red 2 errors (DriveMapTest.test_an_unwritable_prefix_is_noted_and_the_run_goes_on_unmapped, DriveMapTest.test_a_scratch_folder_that_cannot_be_made_is_noted_too) / green 79 OK.

  • PR head 3de809cf6, python -I tests/test_run_wine_tests.py.
  • DriveMapTest runs here (it is skipped on Windows, see the earlier Windows runs): this is the PR's case exercised for the first time.
  • Red: 64 run, 2 errors. On main, DriveMap.__enter__ lets the OSError out (PermissionError: [Errno 13] and OSError: [Errno 28] No space left on device, both raised by the tests' mocks) instead of noting it and running unmapped. MEASURED, DriveMapTest alone 3 runs, 3/3 fail.
  • Green: 79 run, OK, 0 skipped. MEASURED, DriveMapTest alone 3/3 pass.
  • Verdict: READY.

Red = main + only the test file from this PR (git checkout pr-N -- <test>); green = main + git merge --no-ff of this PR, no conflict. Green runs more tests than red because the merge keeps the tests main added to this file since the PR branched; that is the method, not a finding.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248780352 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/919#issuecomment-7248780352). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T01:26:08Z. --- Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df14 : red 2 errors (DriveMapTest.test_an_unwritable_prefix_is_noted_and_the_run_goes_on_unmapped, DriveMapTest.test_a_scratch_folder_that_cannot_be_made_is_noted_too) / green 79 OK. - PR head 3de809cf6, `python -I tests/test_run_wine_tests.py`. - DriveMapTest runs here (it is skipped on Windows, see the earlier Windows runs): this is the PR's case exercised for the first time. - Red: 64 run, 2 errors. On main, `DriveMap.__enter__` lets the OSError out (`PermissionError: [Errno 13]` and `OSError: [Errno 28] No space left on device`, both raised by the tests' mocks) instead of noting it and running unmapped. MEASURED, DriveMapTest alone 3 runs, 3/3 fail. - Green: 79 run, OK, 0 skipped. MEASURED, DriveMapTest alone 3/3 pass. - Verdict: READY. Red = main + only the test file from this PR (`git checkout pr-N -- <test>`); green = main + `git merge --no-ff` of this PR, no conflict. Green runs more tests than red because the merge keeps the tests main added to this file since the PR branched; that is the method, not a finding. AI-assisted: Claude Code (Claude Opus 5.5).
MoonEyes commented 2026-11-29 01:32:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T01:32:16Z.


Merged after OreoFR's red/green check (check) (macOS 27.2.1, Apple M5, APFS case-insensitive, Python 3.12) and a local re-check here. Merged after local re-verification: this PR merged onto main 583882ea2 without conflict, and its test file(s) (tests/test_run_wine_tests.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248847062 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/919#issuecomment-7248847062). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T01:32:16Z. --- Merged after **OreoFR**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/919#issuecomment-7248780352)) (macOS 27.2.1, Apple M5, APFS case-insensitive, Python 3.12) and a local re-check here. Merged after local re-verification: this PR merged onto `main` 583882ea2 without conflict, and its test file(s) (`tests/test_run_wine_tests.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
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!919
No description provided.