Public Access
68 lines
3.4 KiB
Python
68 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Check Native biome-family contracts; real 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(target, biome_mods=False):
|
|
log = ROOT / f"build/verification/native111/{target}-{'bop' if biome_mods else 'vanilla'}.log"
|
|
log.parent.mkdir(parents=True, exist_ok=True)
|
|
with server_test_lock(), tempfile.TemporaryDirectory(prefix=f"rivencraft-native111-{target}-") 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/native111" / target) + """'))
|
|
}
|
|
}
|
|
""")
|
|
if biome_mods:
|
|
game = "1.21.1" if target == "mc1211" else "26.3"
|
|
mods = Path.home() / ".local/share/PrismLauncher/instances" / ("Dev " + game) / "minecraft/mods"
|
|
jars = [next(mods.glob(pattern)) for pattern in ("BiomesOPlenty*.jar", "TerraBlender*.jar", "GlitchCore*.jar")]
|
|
init.write_text(init.read_text() + "\ngradle.projectsEvaluated { gradle.rootProject.dependencies.add('localRuntime', gradle.rootProject.files("
|
|
+ ",".join("'" + str(jar) + "'" for jar in jars) + ")) }\n")
|
|
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")]
|
|
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: Native biome probe stalled; stopping without retry. Use docs/NATIVE_BIOME_FAMILIES.md.")
|
|
return 2
|
|
text = log.read_text()
|
|
if process.returncode or "NATIVE111_PASS" not in text or "NATIVE111_FAIL" in text:
|
|
print(text[-8000:])
|
|
return 1
|
|
print(next(line for line in text.splitlines() if "NATIVE111_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("target", choices=("mc1211", "mc263"))
|
|
parser.add_argument("--biome-mods", action="store_true")
|
|
args=parser.parse_args()
|
|
raise SystemExit(run(args.target,args.biome_mods))
|