Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class DriveMap:
<root>/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):
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 12 additions & 5 deletions tests/test_run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading