"""Run the foreground fixture in its own configured Wine virtual desktop.""" import os from pathlib import Path import subprocess import sys buildDir = Path(sys.argv[1]).resolve() env = os.environ.copy() env.update(WINEPREFIX=str(buildDir / "focus-prefix"), CTHULHU_WINE_ACCESS_MANAGED="1", WINEDEBUG="-all", WINEDLLOVERRIDES="mscoree,mshtml=") try: for key, value, data in ( (r"HKCU\Software\Wine\Explorer", "Desktop", "WineAccessFocusFixture"), (r"HKCU\Software\Wine\Explorer\Desktops", "WineAccessFocusFixture", "800x600"), ): subprocess.run(["wine", "reg", "add", key, "/v", value, "/t", "REG_SZ", "/d", data, "/f"], env=env, check=True, timeout=40) # The next loader must create the configured desktop. Wait for this test # prefix's old server to stop, without touching any user application. subprocess.run(["wineserver", "-k"], env=env, check=True, timeout=5) subprocess.run(["wineserver", "-w"], env=env, check=True, timeout=5) result = subprocess.run([str(buildDir / "foreground-focus-test.exe"), str(buildDir / "foreground-fixture.exe")], env=env, timeout=20) sys.exit(result.returncode) finally: subprocess.run(["wineserver", "-k"], env=env, timeout=5)