Files
claudeandClaude Opus 5.5 5d275e4e14 Phase 4: regenerating ore veins, each tier in one zone
Regenerating Ore Veins 1.4.0 (CurseForge only, MIT). tools/zone_ores.py
writes its config from world/zones.json: surface zones as boxes from the
zone grid, cave tiers by cave biome, 21 tiers including Cobblemon's
evolution stones (their natural ores are off). The world report now
allows ore only in tracked veins inside their tier's zone. Self-tests:
a mined vein regrows after its chunk unloads and after a restart (new
after_restart pass in selftest.py and quick_check.py). make_world places
showcase veins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 02:30:34 +01:00

70 lines
3.1 KiB
Python
Executable File

#!/usr/bin/env python3
"""Run the companion mod's in-game tests on their own: one server boot on a fresh flat
world, `/cobblesurvival selftest run`, wait for the results, stop, scan the log; then boot
the world again for the second halves of the tests that span a restart
(`/cobblesurvival selftest run after_restart`).
The tests (mod/src/main/kotlin/dev/cobblesurvival/selftest/) play real situations on the
live server with every mod and config of the pack, e.g. the permadeath matrix: Pokémon
fainting from a fall, lava, poison, in wild and trainer battles, with and without a
Revival Charm. tools/quick_check.py runs them too; this is the faster loop while
working on them.
Usage: tools/selftest.py [--accept-eula] (run tools/build.py first)
"""
import argparse
import shutil
import sys
import time
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from mcserver import SELFTEST_JVM_ARGS, SERVER, Server, eula_accepted, prepare, scan_log # noqa: E402
LEVEL = "selftest"
def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--accept-eula", action="store_true", help="write eula=true for the test server")
args = parser.parse_args()
if args.accept_eula:
(SERVER / "eula.txt").parent.mkdir(parents=True, exist_ok=True)
(SERVER / "eula.txt").write_text("eula=true\n")
elif not eula_accepted():
sys.exit("build/server/eula.txt does not accept the Minecraft EULA yet; pass --accept-eula if you accept it.")
started = time.time()
args_file = prepare()
shutil.rmtree(SERVER / LEVEL, ignore_errors=True)
flat = '{"layers":[{"block":"minecraft:bedrock","height":1},{"block":"minecraft:stone","height":3},' \
'{"block":"minecraft:grass_block","height":1}],"biome":"minecraft:plains"}'
props = {"level-name": LEVEL, "level-type": "minecraft:flat", "generator-settings": flat}
failures = []
with Server(args_file, props, stdout_name="selftest-stdout.log", jvm_args=SELFTEST_JVM_ARGS) as server:
try:
print(f"server started in {server.wait_ready():.0f}s")
failures += server.run_selftest()
server.stop()
except Exception as e: # report; the context manager still kills the process
failures.append(f"{type(e).__name__}: {e}")
failures += [f"log: {line}" for line in scan_log(server.log)]
with Server(args_file, props, stdout_name="selftest-restart-stdout.log", jvm_args=SELFTEST_JVM_ARGS) as server:
try:
print(f"server restarted in {server.wait_ready():.0f}s")
failures += server.run_selftest(after_restart=True)
server.stop()
except Exception as e: # report; the context manager still kills the process
failures.append(f"{type(e).__name__}: {e}")
failures += [f"log after restart: {line}" for line in scan_log(server.log)]
print(f"\nselftest took {time.time() - started:.0f}s")
if failures:
print("SELFTEST FAILED")
print("\n".join(f" - {f}" for f in failures))
sys.exit(1)
print("SELFTEST PASSED")
if __name__ == "__main__":
main()