upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/run_wine_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/run_wine_tests.py')
-rw-r--r--scripts/run_wine_tests.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py
index 8392c8121..6499eb74a 100644
--- a/scripts/run_wine_tests.py
+++ b/scripts/run_wine_tests.py
@@ -80,15 +80,26 @@ class DriveMap:
80 if not os.path.isdir(dosdevices): 80 if not os.path.isdir(dosdevices):
81 self.note = f"no Wine prefix at {self.prefix}: drive {drive}: not mapped" 81 self.note = f"no Wine prefix at {self.prefix}: drive {drive}: not mapped"
82 return self 82 return self
83 already_set = f"drive {drive}: is already set in {dosdevices}: left as it is"
83 if os.path.lexists(link): 84 if os.path.lexists(link):
84 self.note = f"drive {drive}: is already set in {dosdevices}: left as it is" 85 self.note = already_set
85 return self 86 return self
86 self.scratch = tempfile.mkdtemp(prefix="wine-drive-") 87 self.scratch = tempfile.mkdtemp(prefix="wine-drive-")
87 parent = os.path.join(self.scratch, *rest[:-1]) 88 try:
88 os.makedirs(parent, exist_ok=True) 89 parent = os.path.join(self.scratch, *rest[:-1])
89 os.symlink(self.root, os.path.join(parent, rest[-1])) 90 os.makedirs(parent, exist_ok=True)
90 os.symlink(self.scratch, link) 91 os.symlink(self.root, os.path.join(parent, rest[-1]))
91 self.link = link 92 try:
93 os.symlink(self.scratch, link)
94 except FileExistsError:
95 self.note = already_set
96 return self
97 self.link = link
98 finally:
99 # __exit__ only runs after a successful __enter__.
100 if self.link is None:
101 shutil.rmtree(self.scratch, ignore_errors=True)
102 self.scratch = None
92 self.note = f"drive {drive}: maps {self.windows_root} to {self.root} for this run" 103 self.note = f"drive {drive}: maps {self.windows_root} to {self.root} for this run"
93 return self 104 return self
94 105