Run Designer previews with application-owned DI adapters

This commit is contained in:
2026-11-26 16:01:19 +01:00
parent e49d586916
commit 6126967fdc
56 changed files with 2131 additions and 50 deletions
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""Exercise the Spring fixture in native standalone and registered IntelliJ hosts."""
import argparse
import os
from pathlib import Path
import re
import signal
import subprocess
import sys
import time
from native_crashes import NativeCrashGuard, await_worker_exit, descendant_workers
ROOT = Path(__file__).resolve().parent.parent
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--java-home", type=Path, required=True)
parser.add_argument("--target-java-home", type=Path, required=True)
parser.add_argument("--idea-home", type=Path)
parser.add_argument("--host", choices=("all", "standalone", "intellij"), default="all")
args = parser.parse_args()
hosts = ("standalone", "intellij") if args.host == "all" else (args.host,)
if "intellij" in hosts and args.idea_home is None:
parser.error("--idea-home is required for the IntelliJ check")
for host in hosts:
crashes = NativeCrashGuard(ROOT)
idea = ["--idea-home", args.idea_home] if host == "intellij" else []
result = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", host,
"--spring-di", "--check", "--java-home", args.java_home,
"--target-java-home", args.target_java_home, *idea],
cwd=ROOT, capture_output=True, text=True, timeout=90)
if result.returncode:
raise RuntimeError(result.stdout + result.stderr)
pid = int(re.search(r"Host PID: (\d+)", result.stdout)[1])
evidence = Path(re.search(r"Disposable host: (.+)", result.stdout)[1])
print(f"{host} evidence: {evidence}", flush=True)
log = evidence / "launcher.log"
success = evidence / "SUCCESS.txt"
failure = evidence / "FAILURE.txt"
try:
deadline = time.monotonic() + 240
while time.monotonic() < deadline:
if success.exists():
print(success.read_text(), flush=True)
break
if failure.exists():
raise RuntimeError(failure.read_text())
try:
os.kill(pid, 0)
except ProcessLookupError:
raise RuntimeError(log.read_text()[-12000:]) from None
if subprocess.run(["ps", "-p", str(pid), "-o", "state="], capture_output=True,
text=True).stdout.lstrip().startswith("Z"):
raise RuntimeError(log.read_text()[-12000:])
time.sleep(0.25)
else:
raise RuntimeError("Host qualification timed out\n" + log.read_text()[-12000:])
finally:
workers = descendant_workers(pid)
try:
os.kill(pid, signal.SIGTERM)
except ProcessLookupError:
pass
await_worker_exit(workers)
crashes.check()