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

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

@⁠TuroYT on GitHub · 2026-11-24 15:11 UTC · original
TuroYT:fix/wine-drive-map-oserror → main · +18 −6 · 2 files · 1 commits · open

Claimed in the coordination issue as: WINE-DRIVE-MAP-OSERROR (#14)

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).

**@⁠TuroYT** on GitHub · 2026-11-24 15:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/919) `TuroYT:fix/wine-drive-map-oserror` → `main` · +18 −6 · 2 files · 1 commits · open Claimed in the coordination issue as: WINE-DRIVE-MAP-OSERROR (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ## 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).
DriveMap.__enter__ handled only FileExistsError. A prefix whose dosdevices
folder cannot be written aborted the run with a traceback before any test.
Any OSError while mapping now sets a note and leaves the drive unmapped; the
scratch folder is removed as before.
Tests: the old drive-setup test asserted the traceback; it now checks the note,
the cleanup and that __enter__ does not raise. A second test covers a scratch
folder that cannot be created.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:28:14 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 21:21 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-25 21:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/919#issuecomment-7174976188) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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