Skip to content
Merged
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
16 changes: 10 additions & 6 deletions scripts/run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ def _run(self, *flags, timeout=30.0) -> int | None:
except (OSError, subprocess.TimeoutExpired):
return None

def _warmup(self) -> None:
env = dict(os.environ, WINEDLLOVERRIDES=merge_dll_overrides(os.environ.get("WINEDLLOVERRIDES")))
try:
subprocess.run(self.wine + ["wineboot"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, env=env, timeout=120)
except (OSError, subprocess.TimeoutExpired):
pass # the tests start the services then, as without a kept server

def __enter__(self):
if not self.command:
self.note = "no wineserver found: each test starts its own"
Expand All @@ -200,18 +208,14 @@ def __enter__(self):
code = self._run("-p")
else:
self.note = "a wineserver already runs for this prefix: used and left running"
self._warmup()
return self
self.started = code == 0
if not self.started:
self.note = f"could not start {self.command} -p: each test starts its own server"
return self
self.note = "wineserver kept alive for the run"
env = dict(os.environ, WINEDLLOVERRIDES=merge_dll_overrides(os.environ.get("WINEDLLOVERRIDES")))
try:
subprocess.run(self.wine + ["wineboot"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, env=env, timeout=120)
except (OSError, subprocess.TimeoutExpired):
pass # the tests start the services then, as without a kept server
self._warmup()
return self

def __exit__(self, *exc):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,20 @@ def test_a_server_still_shutting_down_is_waited_for(self):
self.assertEqual(code, 0)
self.assertEqual(log.read_text(encoding="utf-8").splitlines(), ["-p", "-w", "-p", "-k"])

def test_an_existing_persistent_server_is_warmed_but_not_stopped(self):
with mock.patch.object(rwt.KeptServer, "_run", side_effect=[2, 1]) as server, \
mock.patch.object(rwt.subprocess, "run") as warm:
kept = rwt.KeptServer("wineserver", [sys.executable])
with kept:
self.assertFalse(kept.started)
self.assertIn("used and left running", kept.note)
self.assertEqual(server.call_args_list, [mock.call("-p"), mock.call("-w", timeout=15.0)])
warm.assert_called_once()
self.assertEqual(warm.call_args.args[0], [sys.executable, "wineboot"])
self.assertIs(warm.call_args.kwargs["stdout"], subprocess.DEVNULL)
self.assertIs(warm.call_args.kwargs["stderr"], subprocess.DEVNULL)
self.assertEqual(warm.call_args.kwargs["timeout"], 120)

def test_no_wineserver_is_one_line_and_the_run_goes_on(self):
code, out, _ = self.run_main([ctest_entry("ok", self.command("ok.py"))], "--require", "ok")
self.assertEqual(code, 0)
Expand Down
Loading