"""Run the foreground fixture in its own configured Wine virtual desktop.""" import os from pathlib import Path import subprocess import sys from wine_test_environment import run_wine_test buildDir = Path(sys.argv[1]).resolve() if "WINE_ACCESS_TEST_ROOT" not in os.environ: sys.exit(run_wine_test([sys.executable, __file__, str(buildDir)], buildDir, "foreground-focus", timeout=90, keep=os.environ.get("WINE_ACCESS_TEST_KEEP") == "1", keepOnFailure=os.environ.get("WINE_ACCESS_TEST_KEEP_ON_FAILURE", "1") != "0")) env = os.environ.copy() env.update(WINEPREFIX=os.environ["WINEPREFIX"], 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)