From 3de809cf6db9507ca679c5f2ca0919abe98b75b6 Mon Sep 17 00:00:00 2001 From: Romain PINSOLLE Date: Tue, 24 Nov 2026 16:11:09 +0100 Subject: [PATCH] run_wine_tests: note and carry on when the drive cannot be mapped (WINE-DRIVE-MAP-OSERROR) 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. --- scripts/run_wine_tests.py | 7 ++++++- tests/test_run_wine_tests.py | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py index 8435f7fb99..65908e1f3e 100644 --- a/scripts/run_wine_tests.py +++ b/scripts/run_wine_tests.py @@ -67,7 +67,8 @@ class DriveMap: /runtime/build/generated/x.spv. The drive is a dosdevices link to a scratch folder holding a/Leonida/Leonida as a link to the root. If the Windows checkout is the drive root itself, the drive links directly to the Linux checkout. Temporary links and scratch folders are removed afterwards. A drive the prefix already has - (c:, z:, or one set up by hand) is left alone, and so is a root without an absolute drive path. + (c:, z:, or one set up by hand) is left alone, and so is a root without an absolute drive path. A prefix that + cannot take the link (read-only, permission denied) also leaves the drive unmapped; the note says why. """ def __init__(self, windows_root: str, root: str, prefix: str): @@ -104,6 +105,10 @@ def __enter__(self): self.note = already_set return self self.link = link + except OSError as e: + # A read-only or otherwise unwritable prefix: run the tests without the drive, and say so. + self.note = f"cannot map drive {drive}: {e.strerror or e}: the run goes on without it" + return self finally: # __exit__ only runs after a successful __enter__. if self.link is None and self.scratch is not None: diff --git a/tests/test_run_wine_tests.py b/tests/test_run_wine_tests.py index 93870b9d6c..102e51b9ad 100644 --- a/tests/test_run_wine_tests.py +++ b/tests/test_run_wine_tests.py @@ -426,18 +426,25 @@ def add_mapping(target, link): self.assertEqual(os.readlink(self.link), str(other)) self.assertFalse(scratch.exists()) - def test_failed_drive_setup_removes_scratch_directory(self): + def test_an_unwritable_prefix_is_noted_and_the_run_goes_on_unmapped(self): scratch = self.prefix / "scratch" scratch.mkdir() with mock.patch.object(rwt.tempfile, "mkdtemp", return_value=str(scratch)), \ - mock.patch.object(rwt.os, "symlink", side_effect=PermissionError("link denied")): - with self.assertRaisesRegex(PermissionError, "link denied"): - with rwt.DriveMap(WINDOWS_ROOT, str(self.root), str(self.prefix)): - self.fail("drive setup unexpectedly succeeded") + mock.patch.object(rwt.os, "symlink", side_effect=PermissionError(13, "Permission denied")): + with rwt.DriveMap(WINDOWS_ROOT, str(self.root), str(self.prefix)) as drive: + self.assertIn("cannot map drive d: Permission denied", drive.note) + self.assertIsNone(drive.link) self.assertFalse(scratch.exists()) self.assertFalse(os.path.lexists(self.link)) + def test_a_scratch_folder_that_cannot_be_made_is_noted_too(self): + with mock.patch.object(rwt.tempfile, "mkdtemp", side_effect=OSError(28, "No space left on device")): + with rwt.DriveMap(WINDOWS_ROOT, str(self.root), str(self.prefix)) as drive: + self.assertIn("cannot map drive d: No space left on device", drive.note) + self.assertIsNone(drive.scratch) + self.assertFalse(os.path.lexists(self.link)) + def test_no_prefix_or_no_drive_letter_maps_nothing(self): with rwt.DriveMap("D:/a/b", str(self.root), str(self.prefix / "absent")) as drive: self.assertIn("no Wine prefix", drive.note)