Public Access
69 lines
3.1 KiB
Python
69 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Check optional portal engines sequentially; actual client rendering remains player validation."""
|
|
import argparse
|
|
import subprocess
|
|
import tempfile
|
|
from pathlib import Path
|
|
from server_test_lock import server_test_lock
|
|
from smoke_server import stop
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
def run(engine, jar=None):
|
|
target="mc263"
|
|
log = ROOT / f"build/verification/portal117/{engine}.log"
|
|
log.parent.mkdir(parents=True, exist_ok=True)
|
|
with server_test_lock(), tempfile.TemporaryDirectory(prefix=f"rivencraft-portal117-{engine}-") as directory:
|
|
work = Path(directory)
|
|
init = work / "fixture.gradle"
|
|
init.write_text("""
|
|
gradle.beforeProject { p ->
|
|
p.layout.buildDirectory.set(p.file('""" + str(work / "build") + """'))
|
|
p.afterEvaluate {
|
|
p.sourceSets.main.java.srcDir(p.file('""" + str(ROOT / "scripts/fixtures/portal117") + """'))
|
|
}
|
|
}
|
|
""")
|
|
server = work / "server"
|
|
server.mkdir()
|
|
(server / "eula.txt").write_text("eula=true\n")
|
|
(server / "server.properties").write_text(
|
|
"server-ip=127.0.0.1\nserver-port=0\nonline-mode=false\nwhite-list=false\n"
|
|
"level-type=minecraft:flat\nlevel-seed=109\nview-distance=2\nsimulation-distance=2\n"
|
|
'generator-settings={"layers":[{"height":1,"block":"minecraft:bedrock"}],"biome":"minecraft:plains"}\n')
|
|
process = None
|
|
try:
|
|
args = [str(ROOT / "gradlew")]
|
|
if target == "mc263": args += ["-p", str(ROOT / "ports/mc263")]
|
|
if engine == "seamless":
|
|
args += ["-PwithSeamlessPortals", f"-PseamlessPortalsJar={jar}"]
|
|
elif engine == "reborn":
|
|
args += ["-PwithImmersivePortalsReborn"]
|
|
args += ["--no-daemon", "-I", str(init), "runServer", f"-PserverRunDir={server}", "--console=plain"]
|
|
with log.open("w") as output:
|
|
process = subprocess.Popen(args, cwd=ROOT, stdin=subprocess.PIPE, stdout=output,
|
|
stderr=subprocess.STDOUT, text=True, start_new_session=True)
|
|
try:
|
|
process.wait(timeout=60)
|
|
except subprocess.TimeoutExpired:
|
|
print("HANDOFF: Portal engine probe stalled; stopping without retry. Use docs/SEAMLESS_PORTALS.md.")
|
|
return 2
|
|
text = log.read_text()
|
|
if process.returncode or "PORTAL117_PASS" not in text or "PORTAL117_FAIL" in text:
|
|
print(text[-8000:])
|
|
return 1
|
|
print(next(line for line in text.splitlines() if "PORTAL117_PASS" in line))
|
|
return 0
|
|
finally:
|
|
stop(process)
|
|
print("Removed temporary test world and isolated fixture outputs. Log:", log)
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("engine", choices=("none", "seamless", "reborn"))
|
|
parser.add_argument("--jar", type=Path)
|
|
args=parser.parse_args()
|
|
if args.engine=="seamless" and (args.jar is None or not args.jar.is_file()):
|
|
parser.error("Seamless test needs --jar pointing at its actual 26.3 JAR")
|
|
raise SystemExit(run(args.engine,args.jar))
|