Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,6 +75,8 @@ def game_env(screen, home=None):
|
||||
extra['HORIZON_HOME'] = home
|
||||
if sys.platform == 'darwin':
|
||||
return lab.game_env(**extra)
|
||||
if not shutil.which('vscreen') and os.environ.get('DISPLAY'):
|
||||
return lab.game_env(**extra)
|
||||
env = lab.game_env(VSCREEN=screen, **extra)
|
||||
subprocess.run(['vscreen', 'up'], env=env, check=False, capture_output=True)
|
||||
text = subprocess.run(['vscreen', 'env'], env=env, capture_output=True, text=True, check=True).stdout
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render regression: bundle component tooltips in anvil and brewing screens.
|
||||
|
||||
Requires prepared 26.3 resources, a built horizon-client/horizon-ctl and Pillow.
|
||||
Runs an isolated offscreen game; never opens existing player data. A name-only
|
||||
bundle tooltip is narrower than the component's 96 GUI-pixel minimum, so its
|
||||
purple frame cannot pass the image assertion. Screenshots are kept as evidence.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from PIL import Image
|
||||
import lab
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def longest_tooltip_border(image):
|
||||
"""Longest horizontal purple tooltip-frame run (physical pixels)."""
|
||||
rgb = image.convert("RGB")
|
||||
longest = 0
|
||||
pixels = rgb.load()
|
||||
for y in range(rgb.height):
|
||||
run = 0
|
||||
for x in range(rgb.width):
|
||||
r, g, b = pixels[x, y]
|
||||
if g < 25 and r < 100 and b >= r + 15:
|
||||
run += 1
|
||||
longest = max(longest, run)
|
||||
else:
|
||||
run = 0
|
||||
return longest
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--game", type=Path, default=ROOT / "target/fast/horizon-client")
|
||||
parser.add_argument("--ctl", type=Path, default=ROOT / "target/fast/horizon-ctl")
|
||||
parser.add_argument("--resources", type=Path, default=ROOT / ".local/horizon-client/26.3")
|
||||
parser.add_argument("--output", type=Path)
|
||||
parser.add_argument("--in-frame", action="store_true")
|
||||
args = parser.parse_args()
|
||||
output = args.output or Path(tempfile.mkdtemp(prefix="bundle-tooltip-"))
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
output = output.resolve()
|
||||
homes = {}
|
||||
for key in ("HORIZON_HOME", "HORIZON_LAUNCHER_HOME", "XDG_DATA_HOME", "XDG_CONFIG_HOME"):
|
||||
directory = output / key
|
||||
directory.mkdir(exist_ok=True)
|
||||
homes[key] = directory
|
||||
env = lab.game_env(**homes)
|
||||
socket = output / "ctl.sock"
|
||||
|
||||
def ctl(*commands, timeout=45):
|
||||
result = subprocess.run(
|
||||
[str(args.ctl.resolve()), "--socket", str(socket), *map(str, commands)],
|
||||
env=env, cwd=output, capture_output=True, text=True, timeout=timeout,
|
||||
)
|
||||
data = json.loads(result.stdout)
|
||||
if result.returncode or data.get("error"):
|
||||
raise RuntimeError(f"{commands}: {data}; {result.stderr}")
|
||||
return data
|
||||
|
||||
results = []
|
||||
try:
|
||||
ctl("launch", "--game", args.game.resolve(), "--world", output / "world",
|
||||
"--creative", "--offscreen", "--wait", "--resources", args.resources.resolve(),
|
||||
*(["--in-frame"] if args.in_frame else []), timeout=120)
|
||||
state = ctl("state")
|
||||
px, _, pz = state["player"]["block_pos"]
|
||||
x, z = (px // 16) * 16 + 8, (pz // 16) * 16 + 8
|
||||
ctl("command", f"fill {x-3} 99 {z-3} {x+3} 99 {z+3} minecraft:stone")
|
||||
ctl("command", f"fill {x-3} 100 {z-3} {x+3} 105 {z+3} minecraft:air")
|
||||
ctl("tp", x + 0.5, 100, z + 0.5)
|
||||
ctl("command", 'item replace entity @s hotbar.0 with minecraft:bundle['
|
||||
'minecraft:bundle_contents=[{id:"minecraft:stone",count:32}]]')
|
||||
for station in ("anvil", "brewing_stand"):
|
||||
ctl("command", f"setblock {x} 100 {z+2} minecraft:{station}")
|
||||
ctl("wait", 5)
|
||||
ctl("look-at-block", x, 100, z+2, "north")
|
||||
ctl("interact", x, 100, z+2, "north")
|
||||
time.sleep(0.3)
|
||||
ui = ctl("ui")
|
||||
slot = next(w for w in ui["widgets"] if w["id"] == "slot-0")
|
||||
assert slot["stack"]["item"] == "minecraft:bundle", slot
|
||||
sx, sy, sw, sh = slot["bounds"]
|
||||
ctl("scroll-at", sx + sw / 2, sy + sh / 2, 0)
|
||||
screenshot = output / f"{station}.png"
|
||||
ctl("screenshot", screenshot)
|
||||
with Image.open(screenshot) as image:
|
||||
scale = image.width / ui["gui_size"][0]
|
||||
longest = longest_tooltip_border(image)
|
||||
# The component reserves 96 GUI pixels; allow its border/integer rounding.
|
||||
required = int(90 * scale)
|
||||
results.append({"station": station, "border_pixels": longest,
|
||||
"required_pixels": required, "pass": longest >= required,
|
||||
"screenshot": str(screenshot)})
|
||||
ctl("close")
|
||||
finally:
|
||||
try:
|
||||
ctl("quit")
|
||||
except (RuntimeError, subprocess.TimeoutExpired, json.JSONDecodeError):
|
||||
pass
|
||||
report = {"mode": "in-frame" if args.in_frame else "server-thread", "results": results}
|
||||
(output / "results.json").write_text(json.dumps(report, indent=2) + "\n")
|
||||
print(json.dumps(report, indent=2))
|
||||
assert len(results) == 2 and all(r["pass"] for r in results), "Missing bundle component tooltip"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+79
-36
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# A Horizon CI runner (labels self-hosted, Linux, X64, horizon-game and the host's name) on a Linux machine of the
|
||||
# maintainer's (NixOS: ludodesktop, ludothinkpad), as a systemd user service of the account that holds his
|
||||
# Minecraft files, like the Mac mini's runners (docs/release-flow.md). Run it on that machine, as that user:
|
||||
# maintainer's (NixOS: ludodesktop, ludothinkpad; Ubuntu: playhorizon, a partner's server), as a systemd user service
|
||||
# of the account that holds his Minecraft files, like the Mac mini's runners (docs/release-flow.md). Run it on that
|
||||
# machine, as that user:
|
||||
#
|
||||
# bash tools/ci/linux-runner.sh install # register (gh login), install, start; again to update the scripts
|
||||
# bash tools/ci/linux-runner.sh status # the services, the runner's state, the pause watcher's last lines
|
||||
@@ -12,10 +13,16 @@
|
||||
# never runs as the service). horizon-runner-pause.service (runner_pause.py) starts the runner only while nobody
|
||||
# uses the machine (screen locked or untouched for 15 min, no game), and stops it otherwise. The runner runs nice,
|
||||
# in horizon-ci.slice (low CPU and I/O weight, memory capped), on its own virtual screen: vscreen (a headless sway)
|
||||
# where it is installed, else Xvfb from nixpkgs with Mesa's Vulkan drivers.
|
||||
# where it is installed, else Xvfb with Mesa's Vulkan drivers (from nixpkgs on NixOS, from the system elsewhere).
|
||||
# HORIZON_SHARED_SOURCE: the imported vanilla data (default ~/horizon-local/shared-local, else
|
||||
# ~/code/horizon/.local); RUNNER_JOBS: cargo jobs and harnesses at once (default a third of the threads, at most 8:
|
||||
# ludodesktop froze under ~7 cold cargo builds on 2026-10-14, and it is the maintainer's own machine).
|
||||
# RUNNER_CPUS and RUNNER_MEMORY (GB): the slice's CPU quota and memory cap (default half the threads, two thirds of
|
||||
# the memory), for a machine that does nothing else. RUNNER_TOKEN: the registration (or, for uninstall, removal)
|
||||
# token, made with gh on another machine, where gh must not be logged in (a machine someone else also runs):
|
||||
# RUNNER_TOKEN=$(gh api -X POST repos/ludovic111/horizon/actions/runners/registration-token --jq .token)
|
||||
# Without Nix (Debian, Ubuntu), the packages come from apt (the list in system_packages) and python3.13 from the
|
||||
# PATH (uv python install 3.13, linked into ~/.local/bin).
|
||||
set -euo pipefail
|
||||
repo=ludovic111/horizon
|
||||
dir=$HOME/.actions-runners/horizon
|
||||
@@ -27,9 +34,16 @@ here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# Nix packages the jobs need, kept alive by GC roots in $dir/nix. nix-build prints the store path; the root's name
|
||||
# gets the output's suffix (alsa-dev-dev for alsa-lib.dev), so it is not read back from the link.
|
||||
nix_out() { nix-build '<nixpkgs>' -A "$1" -o "$dir/nix/$2" | tail -1; }
|
||||
nixos() { [ -d /run/current-system/sw ]; }
|
||||
system_packages="build-essential pkg-config cmake libasound2-dev libudev-dev sccache mesa-vulkan-drivers libvulkan1 xvfb
|
||||
libx11-6 libxcursor1 libxrandr2 libxi6 libxinerama1 libxkbcommon0 libxkbcommon-x11-0 libgl1 libegl1 rsync git curl"
|
||||
|
||||
# The runner is a .NET program: on NixOS its native libraries (libstdc++, ICU, OpenSSL) come from nix-ld.
|
||||
export LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
if nixos; then export LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}; fi
|
||||
|
||||
token() {
|
||||
if [ -n "${RUNNER_TOKEN:-}" ]; then echo "$RUNNER_TOKEN"; else gh api -X POST "repos/$repo/actions/runners/$1" --jq .token; fi
|
||||
}
|
||||
# NixOS has no /bin/bash: the runner's scripts (again after each of its self-updates) get a portable one.
|
||||
fix_shebangs() { sed -i '1s|^#!/bin/bash|#!/usr/bin/env bash|' "$dir"/*.sh "$dir"/bin/*.sh; }
|
||||
|
||||
@@ -77,32 +91,59 @@ install() {
|
||||
fi
|
||||
tar xzf "$cache" -C "$dir"
|
||||
fix_shebangs
|
||||
gh api -X POST "repos/$repo/actions/runners/registration-token" --jq .token |
|
||||
token registration-token |
|
||||
(cd "$dir" && bash ./config.sh --unattended --replace --url "https://github.com/$repo" --token "$(cat)" \
|
||||
--name "$name" --labels "${RUNNER_LABELS:-horizon-game,$(hostname)}" --work _work > /dev/null)
|
||||
fi
|
||||
|
||||
# Libraries for building (pkg-config) and running (dlopen) the game, the JDK pinned by research-lock.json, sccache.
|
||||
local alsa udev java
|
||||
alsa=$(nix_out alsa-lib.dev alsa-dev)
|
||||
udev=$(nix_out systemd.dev systemd-dev)
|
||||
java=$(nix_out "jdk$(sed -n 's/.*"java_major": *\([0-9]*\).*/\1/p' "$here/../../research-lock.json" | head -1)_headless" jdk)/lib/openjdk
|
||||
nix_out sccache sccache > /dev/null # on the PATH below: runner-env.sh hands it to cargo
|
||||
local libs=/run/opengl-driver/lib:/run/current-system/sw/share/nix-ld/lib
|
||||
if ! command -v vscreen > /dev/null; then
|
||||
local mesa x
|
||||
mesa=$(nix_out mesa mesa)
|
||||
x=$(nix_out xvfb-run xvfb-run)
|
||||
for lib in libx11 libxcursor libxrandr libxi libxext libxinerama libxrender libxxf86vm libxcb libxkbcommon \
|
||||
vulkan-loader libGL; do
|
||||
libs=$libs:$(nix_out "$lib" "$lib")/lib
|
||||
done
|
||||
libs=$mesa/lib:$libs
|
||||
echo "VK_DRIVER_FILES=$mesa/share/vulkan/icd.d/intel_icd.x86_64.json:$mesa/share/vulkan/icd.d/lvp_icd.x86_64.json" \
|
||||
> "$dir/.env.display"
|
||||
echo "$x/bin" > "$dir/.path.display"
|
||||
local major java platform_env path
|
||||
major=$(sed -n 's/.*"java_major": *\([0-9]*\).*/\1/p' "$here/../../research-lock.json" | head -1)
|
||||
if nixos; then
|
||||
local alsa udev libs=/run/opengl-driver/lib:/run/current-system/sw/share/nix-ld/lib display_path=""
|
||||
alsa=$(nix_out alsa-lib.dev alsa-dev)
|
||||
udev=$(nix_out systemd.dev systemd-dev)
|
||||
java=$(nix_out "jdk${major}_headless" jdk)/lib/openjdk
|
||||
nix_out sccache sccache > /dev/null # on the PATH below: runner-env.sh hands it to cargo
|
||||
platform_env="PKG_CONFIG_PATH=$alsa/lib/pkgconfig:$udev/lib/pkgconfig
|
||||
C_INCLUDE_PATH=$udev/include
|
||||
NIX_LD=/run/current-system/sw/share/nix-ld/lib/ld.so
|
||||
NIX_LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib"
|
||||
if ! command -v vscreen > /dev/null; then
|
||||
local mesa x
|
||||
mesa=$(nix_out mesa mesa)
|
||||
x=$(nix_out xvfb-run xvfb-run)
|
||||
for lib in libx11 libxcursor libxrandr libxi libxext libxinerama libxrender libxxf86vm libxcb libxkbcommon \
|
||||
vulkan-loader libGL; do
|
||||
libs=$libs:$(nix_out "$lib" "$lib")/lib
|
||||
done
|
||||
libs=$mesa/lib:$libs
|
||||
platform_env="$platform_env
|
||||
VK_DRIVER_FILES=$mesa/share/vulkan/icd.d/intel_icd.x86_64.json:$mesa/share/vulkan/icd.d/lvp_icd.x86_64.json"
|
||||
display_path=$x/bin:
|
||||
fi
|
||||
platform_env="$platform_env
|
||||
LD_LIBRARY_PATH=$libs"
|
||||
path="$dir/cargo/bin:$display_path$dir/nix/sccache/bin:$java/bin:$HOME/.local/bin:/run/wrappers/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin"
|
||||
else
|
||||
# apt's packages (installed here when sudo needs no password), its JDK, and Mesa's software Vulkan (lavapipe):
|
||||
# a server has no GPU.
|
||||
local missing
|
||||
missing=$(dpkg-query -W -f='${Package} ${Status}\n' $system_packages "openjdk-$major-jdk-headless" 2>&1 |
|
||||
awk '/^dpkg-query: no packages found matching/ {print $NF; next} !/ installed$/ {print $1}' | tr '\n' ' ')
|
||||
if [ -n "${missing// /}" ]; then
|
||||
sudo -n env DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $missing > /dev/null ||
|
||||
{ echo "Install first: sudo apt-get install $missing"; exit 1; }
|
||||
fi
|
||||
command -v python3.13 > /dev/null || [ -x "$HOME/.local/bin/python3.13" ] ||
|
||||
{ echo "No python3.13: uv python install 3.13, then link it into ~/.local/bin"; exit 1; }
|
||||
java=$(ls -d /usr/lib/jvm/java-"$major"-openjdk-* | head -1)
|
||||
platform_env=""
|
||||
command -v vscreen > /dev/null || platform_env="VK_DRIVER_FILES=$(ls /usr/share/vulkan/icd.d/lvp_icd*.json | head -1)"
|
||||
path="$dir/cargo/bin:$java/bin:$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
fi
|
||||
cat > "$dir/.env" <<EOF
|
||||
{
|
||||
cat <<EOF
|
||||
LANG=C.UTF-8
|
||||
RUSTUP_HOME=$dir/rustup
|
||||
CARGO_HOME=$dir/cargo
|
||||
@@ -115,25 +156,26 @@ HORIZON_NO_AUDIO=1
|
||||
HORIZON_NO_HEARTBEAT=1
|
||||
HORIZON_TELEMETRY_URL=off
|
||||
HORIZON_LAUNCHER_NO_SELF_UPDATE=1
|
||||
PKG_CONFIG_PATH=$alsa/lib/pkgconfig:$udev/lib/pkgconfig
|
||||
C_INCLUDE_PATH=$udev/include
|
||||
LD_LIBRARY_PATH=$libs
|
||||
NIX_LD=/run/current-system/sw/share/nix-ld/lib/ld.so
|
||||
NIX_LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib
|
||||
EOF
|
||||
if [ -f "$dir/.env.display" ]; then cat "$dir/.env.display" >> "$dir/.env"; else echo "VSCREEN=ci-horizon" >> "$dir/.env"; fi
|
||||
echo "$dir/cargo/bin:$(cat "$dir/.path.display" 2>/dev/null || true)${dir}/nix/sccache/bin:$java/bin:$HOME/.local/bin:/run/wrappers/bin:/etc/profiles/per-user/$USER/bin:/run/current-system/sw/bin" \
|
||||
| sed 's/::/:/g' > "$dir/.path"
|
||||
[ -n "$platform_env" ] && echo "$platform_env"
|
||||
command -v vscreen > /dev/null && echo "VSCREEN=ci-horizon"
|
||||
true
|
||||
} > "$dir/.env"
|
||||
echo "$path" > "$dir/.path"
|
||||
rm -f "$dir/.env.display" "$dir/.path.display" # written by older versions of this script
|
||||
|
||||
local memory cpus
|
||||
memory=${RUNNER_MEMORY:-$(( $(awk '/MemTotal/ {print int($2 / 1048576)}' /proc/meminfo) * 2 / 3 ))}
|
||||
cpus=${RUNNER_CPUS:-$(( threads / 2 > 1 ? threads / 2 : 1 ))}
|
||||
cat > "$units/horizon-ci.slice" <<EOF
|
||||
[Unit]
|
||||
Description=Horizon CI: the runner's jobs and parity workers sent from other machines
|
||||
[Slice]
|
||||
CPUWeight=20
|
||||
IOWeight=20
|
||||
CPUQuota=$(( threads * 50 ))%
|
||||
MemoryHigh=$(( $(awk '/MemTotal/ {print int($2 / 1048576)}' /proc/meminfo) / 2 ))G
|
||||
MemoryMax=$(( $(awk '/MemTotal/ {print int($2 / 1048576)}' /proc/meminfo) * 2 / 3 ))G
|
||||
CPUQuota=$(( cpus * 100 ))%
|
||||
MemoryHigh=$(( memory * 3 / 4 ))G
|
||||
MemoryMax=${memory}G
|
||||
EOF
|
||||
cat > "$units/horizon-runner.service" <<EOF
|
||||
[Unit]
|
||||
@@ -156,6 +198,7 @@ EOF
|
||||
Description=Runs the Horizon CI runner only while nobody uses the machine or plays on it
|
||||
[Service]
|
||||
ExecStart=$(command -v python3) $dir/runner_pause.py
|
||||
Environment=NORMAL_CPUS=$cpus
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
[Install]
|
||||
@@ -201,7 +244,7 @@ status() {
|
||||
|
||||
uninstall() {
|
||||
systemctl --user disable --now horizon-runner-pause.service horizon-runner.service 2>/dev/null || true
|
||||
gh api -X POST "repos/$repo/actions/runners/remove-token" --jq .token |
|
||||
token remove-token |
|
||||
(cd "$dir" && bash ./config.sh remove --token "$(cat)")
|
||||
rm -f "$units/horizon-runner.service" "$units/horizon-runner-pause.service" "$units/horizon-ci.slice"
|
||||
systemctl --user daemon-reload
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# The tools the vanilla harnesses need, on a self-hosted runner (label horizon-game): the Mac mini's, whose service
|
||||
# starts with a bare PATH, and the Linux ones (tools/ci/linux-runner.sh, NixOS). Python 3.13 and the JDK pinned by
|
||||
# starts with a bare PATH, and the Linux ones (tools/ci/linux-runner.sh: NixOS, Ubuntu). Python 3.13 and the JDK pinned by
|
||||
# research-lock.json come from the machine, never from a download. Writes them to $GITHUB_PATH and $GITHUB_ENV for
|
||||
# the next steps.
|
||||
set -euo pipefail
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Per-process scratch data for game integration tests (never a player's home)."""
|
||||
from pathlib import Path
|
||||
from contextlib import contextmanager
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
try:
|
||||
from . import lab
|
||||
except ImportError:
|
||||
import lab
|
||||
|
||||
|
||||
def game_environment(base, root):
|
||||
root = Path(root)
|
||||
env = dict(base, HORIZON_TELEMETRY_URL='off')
|
||||
for key, folder in [('HORIZON_HOME', 'home'), ('HORIZON_LAUNCHER_HOME', 'launcher'),
|
||||
('XDG_DATA_HOME', 'data'), ('XDG_CONFIG_HOME', 'config')]:
|
||||
path = root / folder
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
env[key] = str(path)
|
||||
return lab.game_env(env)
|
||||
|
||||
|
||||
def run_game(command, **kwargs):
|
||||
"""Run a headless game fixture with the same isolation as real-client tests."""
|
||||
with tempfile.TemporaryDirectory(prefix='hz-fixture-') as root:
|
||||
kwargs['env'] = game_environment(kwargs.pop('env', os.environ), root)
|
||||
if any(key in kwargs['env'] for key in
|
||||
('HORIZON_COMMAND_SCRIPT', 'HORIZON_DISPENSE_FIXTURE', 'HORIZON_SCULK_FIXTURE')):
|
||||
# These compare seeded rule/callback traces, not the client/server boundary.
|
||||
command = [*command, '--in-frame']
|
||||
return subprocess.run(command, **kwargs)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def suite_lock():
|
||||
"""Real-client CI suites share a GPU, even when parity.py runs harnesses in parallel."""
|
||||
import fcntl
|
||||
with (Path(tempfile.gettempdir()) / 'horizon-integration-gpu.lock').open('a') as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX)
|
||||
yield
|
||||
|
||||
|
||||
def require_server_reports(resources):
|
||||
"""Match Builtin.find: a registry report shadows later fallback directories."""
|
||||
resources = Path(resources)
|
||||
reports = next((p for p in (resources, resources / '../../datagen/out/reports',
|
||||
resources / '../datagen/out/reports')
|
||||
if (p / 'registries.json').is_file()), None)
|
||||
if reports is None or not (reports / 'commands.json').is_file():
|
||||
raise ValueError(f'incomplete prepared resources in {resources}: registries.json and '
|
||||
'commands.json must be installed together; prepare the pinned resources again')
|
||||
return reports
|
||||
+620
-62
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
"""LAN multiplayer end to end: a host opens its world to LAN and a guest joins, both real games.
|
||||
|
||||
Two Horizon clients run side by side under horizon-ctl, each in its own scratch folder. The host
|
||||
The host uses its integrated server thread by default; --in-frame compares the fallback, and
|
||||
--server-thread remains accepted. Two Horizon clients run under horizon-ctl in scratch folders. The host
|
||||
creates a survival world and opens it to LAN with commands allowed; the guest connects to it by
|
||||
address. The script then checks, from both sides, what a guest's game used to get wrong (#366):
|
||||
|
||||
@@ -272,7 +273,6 @@ import math
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -284,12 +284,21 @@ from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from agent_control_e2e import Cli, Failed, game_env # noqa: E402
|
||||
import lab # noqa: E402
|
||||
from integration_env import game_environment, require_server_reports # noqa: E402
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
GUEST_NAME = 'Guest'
|
||||
# The host plays single player on its server thread (--server-thread).
|
||||
SERVER_THREAD = False
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'styles', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'doors', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'hands', 'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption', 'breath', 'lava', 'levels', 'drops', 'underwater']
|
||||
# Match normal single player; --in-frame is the comparison path.
|
||||
SERVER_THREAD = True
|
||||
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp',
|
||||
'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'styles',
|
||||
'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing',
|
||||
'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push',
|
||||
'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles',
|
||||
'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects',
|
||||
'portals', 'distance', 'growth', 'doors', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'hands',
|
||||
'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption',
|
||||
'breath', 'lava', 'levels', 'drops', 'underwater', 'fireworks']
|
||||
|
||||
|
||||
class Game:
|
||||
@@ -302,6 +311,7 @@ class Game:
|
||||
os.symlink(resources, self.work / '.local/horizon-client' / lab.VERSION)
|
||||
self.socket = self.work / 'c.sock'
|
||||
env = game_env(os.environ.get('VSCREEN', 'lan-e2e'), home=self.work / 'home')
|
||||
env = game_environment(env, self.work)
|
||||
self.d = Cli(ctl, self.socket, self.work, env)
|
||||
self.d.name = name
|
||||
|
||||
@@ -327,6 +337,28 @@ class Game:
|
||||
def wait(self, ticks):
|
||||
self.d('wait', ticks=ticks)
|
||||
|
||||
def script(self, lines):
|
||||
"""Keep tick-sensitive input in one ctl process, through the normal control commands."""
|
||||
result = subprocess.run(self.d.base + ['script'], input='\n'.join(lines) + '\n',
|
||||
cwd=self.work, env=self.d.env, capture_output=True, text=True,
|
||||
timeout=600)
|
||||
replies = [json.loads(line) for line in result.stdout.splitlines() if line.strip()]
|
||||
ticks = [r['ticks'] for r in replies if 'ticks' in r]
|
||||
print(f'[{self.name}] script {lines} -> {replies[-1] if replies else result.stderr[:400]}; ticks={ticks}')
|
||||
assert result.returncode == 0 and replies and not any('error' in r for r in replies), result.stdout
|
||||
return replies[-1]
|
||||
|
||||
def until(self, observe, predicate, ticks=100):
|
||||
"""Wait for an observable answer, within the existing tick budget."""
|
||||
last = observe()
|
||||
for _ in range(ticks):
|
||||
if predicate(last):
|
||||
return last
|
||||
self.wait(1)
|
||||
last = observe()
|
||||
assert predicate(last), f'{self.name}: state did not arrive within {ticks} ticks: {last}'
|
||||
return last
|
||||
|
||||
def close(self):
|
||||
try:
|
||||
self.d('quit')
|
||||
@@ -534,6 +566,8 @@ def check_sign(host, guest, out):
|
||||
host.shot(out, 'sign')
|
||||
assert placed and 'sign' in placed, f'the guest placed {placed}'
|
||||
host_unaffected(host, "the guest's sign")
|
||||
guest.raw('key', 'esc', 'tap')
|
||||
guest.raw('wait-for', 'screen', 'playing')
|
||||
return placed
|
||||
|
||||
|
||||
@@ -653,6 +687,16 @@ def portals(host, guest, out, x, y, z, hx, hy, hz):
|
||||
guest('command', command=f'tp @s {arrived[0] + 0.5} {arrived[1]} {arrived[2] - 2.5}')
|
||||
guest.wait(30)
|
||||
guest('command', command=f'tp @s {arrived[0] + 0.5} {arrived[1]} {arrived[2] + 0.5}')
|
||||
# ServerPlayer.showEndCredits: the host's first exit from the End rolls the poem and credits;
|
||||
# closing them (WinScreen.onClose sends PERFORM_RESPAWN) takes it home.
|
||||
credits = False
|
||||
for _ in range(60):
|
||||
host.wait(5)
|
||||
if host('screen').get('screen') == 'win':
|
||||
credits = True
|
||||
host.raw('key', 'esc', 'tap')
|
||||
break
|
||||
assert credits, 'the host left the End without the credits'
|
||||
home = wait_dimension(host, 'minecraft:overworld', 600)
|
||||
back = wait_dimension(guest, 'minecraft:overworld', 600)
|
||||
guest.wait(40)
|
||||
@@ -660,7 +704,7 @@ def portals(host, guest, out, x, y, z, hx, hy, hz):
|
||||
guest.shot(out, 'portals-back')
|
||||
assert home.get('dimension') == 'minecraft:overworld', f'the host stayed in {home.get("dimension")}'
|
||||
assert back.get('dimension') == 'minecraft:overworld', f'the guest stayed in {back.get("dimension")}'
|
||||
return {'guest_nether': arrived, 'host_end': [ex, ey, ez], 'back': pos_of(guest)}
|
||||
return {'guest_nether': arrived, 'host_end': [ex, ey, ez], 'credits': credits, 'back': pos_of(guest)}
|
||||
|
||||
|
||||
NETHER, END, OVERWORLD = 'minecraft:the_nether', 'minecraft:the_end', 'minecraft:overworld'
|
||||
@@ -678,7 +722,7 @@ def check_levels(host, guest, out):
|
||||
for name, step in LEVEL_STEPS:
|
||||
try:
|
||||
steps[name] = step(host, guest, out)
|
||||
except (Failed, AssertionError, StopIteration, KeyError) as e:
|
||||
except (Failed, AssertionError, StopIteration, KeyError, TypeError, IndexError) as e:
|
||||
steps[name], failed = repr(e), failed + [name]
|
||||
for g in (host, guest):
|
||||
back_to_game(g)
|
||||
@@ -751,10 +795,12 @@ def level_ticking(host, guest, out):
|
||||
has its own id across the levels."""
|
||||
gx, gy, gz = pos_of(guest)
|
||||
hx, hy, hz = pos_of(host)
|
||||
# A floor of its own beside the host (earlier checks may have broken the open one there).
|
||||
bx, by, bz = int(hx // 1), int(hy // 1), int(hz // 1)
|
||||
host('command', command=f'fill {bx - 4} {by - 1} {bz - 4} {bx + 4} {by - 1} {bz - 2} minecraft:stone')
|
||||
host('command', command=f'fill {bx - 4} {by} {bz - 4} {bx + 4} {by + 4} {bz - 2} minecraft:air')
|
||||
# Clear the whole walking area in each level: normal pig AI can leave a
|
||||
# narrow landing strip during the fall/observation window.
|
||||
for game, x, y, z in ((host, hx, hy, hz), (guest, gx, gy, gz)):
|
||||
bx, by, bz = int(x // 1), int(y // 1), int(z // 1)
|
||||
game('command', command=f'fill {bx - 12} {by - 1} {bz - 12} {bx + 12} {by - 1} {bz + 12} minecraft:stone')
|
||||
game('command', command=f'fill {bx - 12} {by} {bz - 12} {bx + 12} {by + 6} {bz + 12} minecraft:air')
|
||||
guest('command', command=f'summon minecraft:pig {gx + 2.5:.2f} {gy + 3:.2f} {gz:.2f}')
|
||||
guest('command', command=f'summon minecraft:armor_stand {gx - 2.5:.2f} {gy + 3:.2f} {gz:.2f}')
|
||||
host('command', command=f'summon minecraft:pig {hx + 2.5:.2f} {hy + 3:.2f} {hz - 3:.2f}')
|
||||
@@ -766,6 +812,7 @@ def level_ticking(host, guest, out):
|
||||
mobs = [m for m in g.raw('mobs', 8)['near'] if m['kind'] == 'minecraft:pig']
|
||||
stands = [o for o in g('status')['objects'] if o['kind'] == 'minecraft:armor_stand']
|
||||
seen[name] = {'pigs': [(m['id'], round(m['pos'][1], 2)) for m in mobs],
|
||||
'pig_positions': [m['pos'] for m in mobs],
|
||||
'stands': [(o['id'], round(o['position'][1], 2)) for o in stands], 'floor': floor}
|
||||
finally:
|
||||
guest('command', command='kill @e[type=!minecraft:player,distance=..8]')
|
||||
@@ -1993,12 +2040,11 @@ def chat_input(game):
|
||||
def complete(guest, text):
|
||||
"""Opens the chat on `/`, types `text` and presses Tab: the input after it."""
|
||||
guest.raw('key', 'slash', 'tap')
|
||||
guest.wait(3)
|
||||
guest.until(lambda: guest('screen').get('screen'), lambda s: s == 'chat', ticks=3)
|
||||
guest.raw('type', text)
|
||||
guest.wait(2)
|
||||
guest.until(lambda: guest('screen').get('chat_suggestions'), bool, ticks=2)
|
||||
guest.raw('key', 'tab', 'tap')
|
||||
guest.wait(2)
|
||||
return chat_input(guest)
|
||||
return guest.until(lambda: chat_input(guest), lambda value: value != '/' + text, ticks=2)
|
||||
|
||||
|
||||
def check_commands(host, guest, out):
|
||||
@@ -2075,6 +2121,53 @@ def check_recipes(host, guest, out):
|
||||
guest.raw('key', 'esc', 'tap')
|
||||
guest.wait(5)
|
||||
assert any('oak_log' in str(item) for item in grid.values()), f'nothing placed in the grid: {grid}'
|
||||
# #2019: the alternatives popup belongs to one screen. Check both the
|
||||
# in-frame host (or --server-thread host) and the remote guest, with both
|
||||
# inventory-close keys and a different recipe-book type on reopening.
|
||||
for game in (host, guest):
|
||||
game('command', command='recipe give @s minecraft:oak_planks')
|
||||
game('command', command='recipe give @s minecraft:birch_planks')
|
||||
game.wait(10)
|
||||
for close_key, reopen in (('e', 'inventory'), ('esc', 'furnace')):
|
||||
game.raw('key', 'e', 'tap')
|
||||
game.wait(5)
|
||||
book = game('screen')['recipe_book']
|
||||
if len(book['targets']) == 1:
|
||||
game.raw('click-at', *centre(book['targets'][0]))
|
||||
game.wait(5)
|
||||
book = game('screen')['recipe_book']
|
||||
for rect in book['targets']:
|
||||
if rect[2:] != [25.0, 25.0]:
|
||||
continue
|
||||
game.raw('click-at', *centre(rect), 'right')
|
||||
game.wait(2)
|
||||
targets = game('screen')['recipe_book']['targets']
|
||||
if targets and all(r[2:] == [24.0, 24.0] for r in targets):
|
||||
break
|
||||
else:
|
||||
raise AssertionError(f'{game.name}: no alternatives popup opened: {book}')
|
||||
game.shot(out, f'recipe-overlay-{close_key}-before')
|
||||
game.raw('key', close_key, 'tap')
|
||||
game.wait(5)
|
||||
if reopen == 'inventory':
|
||||
game.raw('key', 'e', 'tap')
|
||||
else:
|
||||
x, y, z = (int(v // 1) for v in pos_of(game))
|
||||
game('command', command=f'setblock {x} {y} {z - 2} minecraft:furnace')
|
||||
game.wait(5)
|
||||
game.raw('interact', x, y, z - 2)
|
||||
game.wait(5)
|
||||
targets = game('screen')['recipe_book']['targets']
|
||||
if reopen == 'furnace' and len(targets) == 1 and targets[0][2:] == [20.0, 18.0]:
|
||||
game.raw('click-at', *centre(targets[0]))
|
||||
game.wait(5)
|
||||
targets = game('screen')['recipe_book']['targets']
|
||||
game.shot(out, f'recipe-overlay-{close_key}-after')
|
||||
assert any(r[2:] == [20.0, 18.0] for r in targets), f'{game.name}: stale popup: {targets}'
|
||||
if reopen == 'inventory':
|
||||
assert len(targets) > 1, f'{game.name}: the book forgot its open setting'
|
||||
game.raw('key', 'esc', 'tap')
|
||||
game.wait(5)
|
||||
return {'known': known, 'grid': grid}
|
||||
|
||||
|
||||
@@ -2408,7 +2501,8 @@ def check_predict(host, guest, out):
|
||||
seen = {}
|
||||
creaks = lambda game: sum(n for s, n in game('status')['heard'].items() if 'door' in s)
|
||||
heard = {'guest': creaks(guest), 'host': creaks(host)}
|
||||
os.kill(host.pid, signal.SIGSTOP)
|
||||
host.raw('server-hold', 'on')
|
||||
held_at = host.raw('simulation')['game_time']
|
||||
try:
|
||||
guest.raw('interact', *wood)
|
||||
seen['guest_frozen'] = (state(guest, wood), state(guest, (wood[0], wood[1] + 1, wood[2])))
|
||||
@@ -2416,8 +2510,9 @@ def check_predict(host, guest, out):
|
||||
seen['guest_heard_frozen'] = creaks(guest) - heard['guest']
|
||||
guest.raw('interact', *iron)
|
||||
seen['guest_iron_frozen'] = state(guest, iron)
|
||||
assert host.raw('simulation')['game_time'] == held_at, 'server barrier advanced the world'
|
||||
finally:
|
||||
os.kill(host.pid, signal.SIGCONT)
|
||||
host.raw('server-hold', 'off')
|
||||
guest.wait(20)
|
||||
seen['guest_after'] = state(guest, wood)
|
||||
seen['host_after'] = state(host, wood)
|
||||
@@ -2529,7 +2624,11 @@ def check_swings(host, guest, out):
|
||||
guest.wait(10)
|
||||
guest.raw('select', 'minecraft:wooden_hoe')
|
||||
before = guest('state')['swings']
|
||||
guest.raw('interact', *soil)
|
||||
guest.raw('look-at', soil[0] + 0.5, soil[1] + 1, soil[2] + 0.5)
|
||||
guest.wait(1)
|
||||
target = guest('state')['looking_at']['block']
|
||||
assert target and target['pos'] == list(soil) and target['face'] == 'up', target
|
||||
guest.raw('mouse', 'right', 'click')
|
||||
guest.wait(10)
|
||||
hoe = {'swings': guest('state')['swings'] - before, 'soil': host.raw('block', *soil)['block']}
|
||||
guest('command', command=f'setblock {soil[0]} {soil[1]} {soil[2]} minecraft:stone')
|
||||
@@ -2636,16 +2735,22 @@ def check_xp(host, guest, out):
|
||||
x, y, z = pos_of(guest)
|
||||
# Three orbs of 7 points 4 blocks east of the guest (out of reach, within the 8 blocks orbs
|
||||
# follow from): they fly to the guest.
|
||||
# Freeze setup so command/IPC latency cannot let all three be collected
|
||||
# before the two-tick in-flight observation.
|
||||
host('command', command='tick freeze')
|
||||
for _ in range(3):
|
||||
guest('command', command=f'summon minecraft:experience_orb {x + 4:.2f} {y + 0.5:.2f} {z:.2f} {{Value:7s}}')
|
||||
host('command', command='tick step 2')
|
||||
guest.wait(2)
|
||||
seen = remote(guest).get('entities', {}).get('minecraft:experience_orb', 0)
|
||||
guest.shot(out, 'xp-orbs')
|
||||
host('command', command='tick unfreeze')
|
||||
guest.wait(60)
|
||||
xp = guest('state')['player']['xp']
|
||||
host_xp = host('state')['player']['xp']
|
||||
left = remote(guest).get('entities', {}).get('minecraft:experience_orb', 0)
|
||||
finally:
|
||||
host('command', command='tick unfreeze')
|
||||
host('command', command='gamemode survival')
|
||||
# Back where it stood: a spectator sinks (Player.travel keeps 0.6 of its fall speed each tick,
|
||||
# about 0.2 blocks from standing), and a later check that makes it survival again would land
|
||||
@@ -2671,9 +2776,7 @@ def check_time(host, guest, out):
|
||||
guest.wait(20)
|
||||
# A stalled game runs at most 10 missed ticks when it wakes (DeltaTracker); the server's
|
||||
# game time, sent every second, moves the guest's clock on (ClientClockManager.tick).
|
||||
os.kill(guest.pid, signal.SIGSTOP)
|
||||
time.sleep(4)
|
||||
os.kill(guest.pid, signal.SIGCONT)
|
||||
guest.raw('stall', 4000)
|
||||
guest.wait(60)
|
||||
stalled = times()
|
||||
detail = {'paused': paused, 'after_stall': stalled}
|
||||
@@ -2813,6 +2916,55 @@ def sparked(player, other, kinds, act, ticks=20):
|
||||
return seen
|
||||
|
||||
|
||||
def check_fireworks(host, guest, out):
|
||||
"""Event 17 must arrive before removal, with the item's colored, trailing explosion (#1478).
|
||||
|
||||
FireworkRocketEntity.explode / handleEntityEvent; run with and without --server-thread.
|
||||
The flash proves a configured explosion reached both clients; red pixels in later screenshots
|
||||
check that its sparks keep rendering after the tracked rocket disappears.
|
||||
"""
|
||||
x, y, z = (int(v // 1) for v in pos_of(host))
|
||||
at = (x, y - 1, z + 3)
|
||||
host('command', command=f'fill {x - 5} {y - 1} {z - 2} {x + 5} {y - 1} {z + 8} minecraft:stone')
|
||||
host('command', command=f'fill {x - 5} {y} {z - 2} {x + 5} {y + 4} {z + 8} minecraft:air')
|
||||
host('command', command=f'fill {x - 2} {y + 2} {z + 1} {x + 2} {y + 2} {z + 5} minecraft:stone')
|
||||
for game, dx in ((host, -2), (guest, 2)):
|
||||
game('command', command='gamemode creative')
|
||||
game('command', command=f'tp @s {x + dx + 0.5} {y} {z + 0.5}')
|
||||
game.raw('look-at', x + 0.5, y + 1.5, z + 3.5)
|
||||
|
||||
def red(path):
|
||||
rows, bpp = png_rows(path)
|
||||
# Exclude the hotbar and chat at the bottom of the view.
|
||||
return sum(row[i] > 80 and row[i] > 2 * row[i + 1] and row[i] > 2 * row[i + 2]
|
||||
for row in rows[:len(rows) * 3 // 4] for i in range(0, len(row), bpp))
|
||||
|
||||
baseline = {g.name: red(g.shot(out, 'fireworks-before')) for g in (host, guest)}
|
||||
before = {g.name: made(g, 'flash') for g in (host, guest)}
|
||||
host('command', command='item replace entity @s weapon.mainhand with minecraft:firework_rocket'
|
||||
'[fireworks={flight_duration:0,explosions:[{shape:"large_ball",colors:[I;16711680],has_trail:true}]}]')
|
||||
host.raw('interact', *at)
|
||||
# The held item's red texture must not count as a burst or a later spark.
|
||||
host('command', command='item replace entity @s weapon.mainhand with minecraft:air')
|
||||
for _ in range(30):
|
||||
host.wait(2)
|
||||
if all(made(g, 'flash') > before[g.name] for g in (host, guest)):
|
||||
break
|
||||
flashes = {g.name: made(g, 'flash') - before[g.name] for g in (host, guest)}
|
||||
assert all(n == 1 for n in flashes.values()), f'configured burst missing or duplicated: {flashes}'
|
||||
# Capture both views before decoding PNGs: decoding must not consume the sparks' lifetime.
|
||||
burst_shots = {g.name: g.shot(out, 'fireworks-burst') for g in (host, guest)}
|
||||
host.wait(16)
|
||||
trail_shots = {g.name: g.shot(out, 'fireworks-trail-fade') for g in (host, guest)}
|
||||
burst = {name: red(path) - baseline[name] for name, path in burst_shots.items()}
|
||||
trails = {name: red(path) - baseline[name] for name, path in trail_shots.items()}
|
||||
rockets = {g.name: g('status')['rockets'] for g in (host, guest)}
|
||||
assert not any(rockets.values()), f'exploded rocket remains: {rockets}'
|
||||
assert all(n > 20 for n in burst.values()), f'no red burst: {burst}'
|
||||
assert all(n > 20 for n in trails.values()), f'no later red trail/fade: {trails}'
|
||||
return {'flashes': flashes, 'red_burst': burst, 'red_trail_fade': trails, 'rockets': rockets}
|
||||
|
||||
|
||||
def check_sparks(host, guest, out):
|
||||
spots = apart(host, guest)
|
||||
result = {}
|
||||
@@ -3126,12 +3278,10 @@ def same_light(host, guest, lo, hi, what, ticks=100):
|
||||
def check_flight(host, guest, out):
|
||||
def double_jump(game):
|
||||
# LocalPlayer.aiStep: a second jump press within 7 ticks of the first toggles flight.
|
||||
lines = []
|
||||
for hold in (1, 4):
|
||||
game.raw('key', 'space', 'down')
|
||||
game.wait(hold)
|
||||
game.raw('key', 'space', 'up')
|
||||
game.wait(2)
|
||||
game.wait(10)
|
||||
lines += ['key space down', f'wait {hold}', 'key space up', 'wait 2']
|
||||
game.script(lines + ['wait 10'])
|
||||
return game('state')['player']
|
||||
|
||||
def set_mode(game, mode):
|
||||
@@ -3146,6 +3296,9 @@ def check_flight(host, guest, out):
|
||||
|
||||
players = [('guest', guest)] + ([('host', host)] if SERVER_THREAD else [])
|
||||
seen = {}
|
||||
# The rule is seven simulation ticks, independent of wall time. A slow
|
||||
# server clock leaves enough time to deliver the key events even on busy CI.
|
||||
host('command', command='tick rate 4')
|
||||
try:
|
||||
for name, game in players:
|
||||
set_mode(game, 'creative')
|
||||
@@ -3159,6 +3312,7 @@ def check_flight(host, guest, out):
|
||||
'stayed': round(later['position'][1] - up['position'][1], 2),
|
||||
'survival_flying': fell['flying']}
|
||||
finally:
|
||||
host('command', command='tick rate 20')
|
||||
for _, game in players:
|
||||
game('command', command='gamemode survival')
|
||||
for name, s in seen.items():
|
||||
@@ -3673,15 +3827,16 @@ def leave_vehicle(player, kind):
|
||||
|
||||
def break_vehicle(player, vehicle_id, kind):
|
||||
"""Hit it with fists until it breaks: VehicleEntity.tick takes 1 off its damage every tick."""
|
||||
for _ in range(10):
|
||||
here = [o for o in player('status')['objects'] if o['id'] == vehicle_id]
|
||||
if not here:
|
||||
return
|
||||
vp = here[0]['position']
|
||||
player.raw('look-at', f'{vp[0]:.2f}', f'{vp[1] + 0.3:.2f}', f'{vp[2]:.2f}')
|
||||
player.raw('mouse', 'left', 'click')
|
||||
player.wait(2)
|
||||
raise AssertionError(f'ten hits left the {kind} in place')
|
||||
here = [o for o in player('status')['objects'] if o['id'] == vehicle_id]
|
||||
if not here:
|
||||
return
|
||||
vp = here[0]['position']
|
||||
# Keep the original ten hits/two-tick spacing in one connection. Starting
|
||||
# several ctl processes per hit lets the vehicle's damage decay between hits.
|
||||
player.script([f'look-at {vp[0]:.2f} {vp[1] + 0.3:.2f} {vp[2]:.2f}',
|
||||
*[line for _ in range(10) for line in ('mouse left click', 'wait 2')]])
|
||||
assert not any(o['id'] == vehicle_id for o in player('status')['objects']), \
|
||||
f'ten hits left the {kind} in place'
|
||||
|
||||
|
||||
def check_boats(host, guest, out):
|
||||
@@ -4338,10 +4493,8 @@ def check_deflect(host, guest, out):
|
||||
(Player.attack: AIM_DEFLECT on #redirectable_projectile; Ghast.isReflectedFireball). The ghast is caged
|
||||
(a window toward the host); the game runs at 4 ticks a second, and once the fireball is within 4.5 blocks
|
||||
the host looks at the ghast and clicks."""
|
||||
if SERVER_THREAD:
|
||||
# The fireball's position and the host's hurts are read from the host's own level.
|
||||
return 'skipped (in-frame only)'
|
||||
x, y, z = (int(v // 1) for v in pos_of(host))
|
||||
back = pos_of(host)
|
||||
x, y, z = (int(v // 1) for v in back)
|
||||
guest('command', command='gamemode creative')
|
||||
host('command', command='gamemode survival')
|
||||
host('command', command='difficulty normal')
|
||||
@@ -4362,23 +4515,36 @@ def check_deflect(host, guest, out):
|
||||
try:
|
||||
deadline = time.monotonic() + 120
|
||||
while time.monotonic() < deadline:
|
||||
balls = [q for q in host.raw('status')['projectiles'] if q['kind'] == 'LargeFireball']
|
||||
# Aim and click at the projectile the client actually sees. Holding
|
||||
# non-player simulation keeps the reach window open while ordinary
|
||||
# player input and its attack packet cross the connection.
|
||||
balls = [q for q in host('status')['projectiles'] if q['kind'] == 'LargeFireball']
|
||||
near = min((math.dist(q['position'], eye) for q in balls), default=None)
|
||||
if near is not None and near < 4.5:
|
||||
ball = min(balls, key=lambda q: math.dist(q['position'], eye))
|
||||
host('command', command='tick freeze')
|
||||
held_tick = host.raw('simulation')['game_time']
|
||||
g = [m['pos'] for m in host.raw('mobs', 60).get('near', []) if m['kind'].endswith('ghast')][0]
|
||||
host.raw('look-at', f'{g[0]:.2f}', f'{g[1] + 2:.2f}', f'{g[2]:.2f}')
|
||||
host.raw('mouse', 'left', 'down')
|
||||
host.raw('mouse', 'left', 'up')
|
||||
host.script([f'look-at {g[0]:.2f} {g[1] + 2:.2f} {g[2]:.2f}',
|
||||
'wait 1', 'mouse left click', 'wait 1'])
|
||||
host.until(lambda: host.raw('simulation')['projectiles'],
|
||||
lambda qs: any(q.get('id') == ball['id'] and q.get('player_owned') for q in qs),
|
||||
ticks=60)
|
||||
assert host.raw('simulation')['game_time'] == held_tick, 'the deflection barrier advanced simulation'
|
||||
host('command', command='tick unfreeze')
|
||||
turned = near
|
||||
break
|
||||
host('command', command='tick rate 20')
|
||||
host.wait(60)
|
||||
ghast = [m for m in host.raw('mobs', 60).get('near', []) if m['kind'].endswith('ghast') and m['health'] > 0]
|
||||
hurt = [h for pl in host.raw('hurtlog')['players'] if pl['name'] == 'host' for h in pl['hurts']
|
||||
hurt = [h for pl in host.raw('hurtlog')['players'] if pl['name'] == (host.player if SERVER_THREAD else 'host') for h in pl['hurts']
|
||||
if 'fireball' in h['source'] or 'explosion' in h['source']]
|
||||
finally:
|
||||
host('command', command='tick unfreeze')
|
||||
host('command', command='tick rate 20')
|
||||
host('command', command='kill @e[type=minecraft:ghast]')
|
||||
host('command', command=f'tp @s {back[0]} {back[1]} {back[2]}')
|
||||
host.until(lambda: pos_of(host), lambda p: math.dist(p, back) < 0.1)
|
||||
host('command', command=f'fill {gx - 3} {gy - 1} {gz - 3} {gx + 24} {gy + 8} {gz + 3} minecraft:air')
|
||||
guest('command', command='gamemode survival')
|
||||
assert turned is not None, f'no fireball came within 4.5 blocks (nearest {near})'
|
||||
@@ -4532,7 +4698,7 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour,
|
||||
'hud': check_hud,
|
||||
'sidebar': check_sidebar,
|
||||
'border': check_border,
|
||||
'particles': check_particles}
|
||||
'particles': check_particles, 'fireworks': check_fireworks}
|
||||
|
||||
|
||||
def run(ctl, out, resources, checks):
|
||||
@@ -4564,8 +4730,22 @@ def run(ctl, out, resources, checks):
|
||||
guest.shot(out, 'joined')
|
||||
for name in checks:
|
||||
try:
|
||||
results[name] = {'pass': True, 'detail': CHECK_FNS[name](host, guest, out)}
|
||||
except (Failed, AssertionError, StopIteration, KeyError) as e:
|
||||
# Cases assert their own deaths, menus and held actions before returning.
|
||||
# Do not let those states turn later independent cases into false failures.
|
||||
for game in (host, guest):
|
||||
game.raw('release')
|
||||
back_to_game(game)
|
||||
state = game('state')
|
||||
assert state.get('player') is not None, f'{game.name} lost its session before {name}: {state}'
|
||||
if state.get('screen') == 'dead' or state['player']['health'] <= 0:
|
||||
game.raw('respawn')
|
||||
game.until(lambda: game('state'),
|
||||
lambda s: s.get('screen') == 'playing' and s['player']['health'] > 0,
|
||||
ticks=40)
|
||||
detail = CHECK_FNS[name](host, guest, out)
|
||||
skipped = isinstance(detail, str) and detail.startswith('skipped')
|
||||
results[name] = {'pass': not skipped, 'skipped': skipped, 'detail': detail}
|
||||
except (Failed, AssertionError, StopIteration, KeyError, TypeError, IndexError) as e:
|
||||
results[name] = {'pass': False, 'detail': repr(e)}
|
||||
for g in (host, guest):
|
||||
back_to_game(g)
|
||||
@@ -4584,14 +4764,19 @@ def main():
|
||||
parser.add_argument('--bin-dir', help='prebuilt horizon-client and horizon-ctl (default: build with the fast profile)')
|
||||
parser.add_argument('--check', action='append', choices=CHECKS, help='run only these checks (repeatable)')
|
||||
parser.add_argument('--out', default=str(ROOT / '.local/lan-e2e'), help='screenshots and game logs go here')
|
||||
parser.add_argument('--server-thread', action='store_true', help="the host's world runs on its server thread")
|
||||
mode = parser.add_mutually_exclusive_group()
|
||||
mode.add_argument('--server-thread', dest='server_thread', action='store_true', default=True,
|
||||
help='host on its server thread (default; retained for existing callers)')
|
||||
mode.add_argument('--in-frame', dest='server_thread', action='store_false',
|
||||
help='host the world in the window, for comparison')
|
||||
args = parser.parse_args()
|
||||
global SERVER_THREAD
|
||||
SERVER_THREAD = args.server_thread
|
||||
if args.bin_dir:
|
||||
bins = Path(args.bin_dir).resolve()
|
||||
else:
|
||||
subprocess.run(['cargo', 'build', '--locked', '--profile', 'fast', '-p', 'horizon-client', '--bins'],
|
||||
subprocess.run(['cargo', 'build', '--locked', '--profile', 'fast', '-p', 'horizon-client',
|
||||
'--bin', 'horizon-client', '--bin', 'horizon-ctl'],
|
||||
cwd=ROOT, check=True)
|
||||
meta = json.loads(subprocess.run(['cargo', 'metadata', '--format-version', '1', '--no-deps'], cwd=ROOT,
|
||||
capture_output=True, text=True, check=True).stdout)
|
||||
@@ -4599,9 +4784,16 @@ def main():
|
||||
resources = lab.RESOURCES.resolve()
|
||||
if not (resources / 'horizon-resources.json').exists():
|
||||
sys.exit(f'no prepared resources in {resources}')
|
||||
out = Path(args.out)
|
||||
try:
|
||||
require_server_reports(resources)
|
||||
except ValueError as error:
|
||||
sys.exit(str(error))
|
||||
out = Path(args.out).resolve()
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
print(f'LAN host mode: {"server-thread" if SERVER_THREAD else "in-frame"}')
|
||||
results = run(bins / 'horizon-ctl', out, resources, args.check or CHECKS)
|
||||
(out / 'results.json').write_text(json.dumps({'mode': 'server-thread' if SERVER_THREAD else 'in-frame',
|
||||
'checks': results}, indent=2) + '\n')
|
||||
print(json.dumps(results, indent=1))
|
||||
sys.exit(0 if results and all(r['pass'] for r in results.values()) else 1)
|
||||
|
||||
@@ -4658,16 +4850,33 @@ def check_keep_inventory(host, guest, out):
|
||||
neither; with it on, nothing drops and it respawns with both (#1284)."""
|
||||
hx, hy, hz = (int(v // 1) for v in pos_of(host))
|
||||
seen = {}
|
||||
# Totem coverage leaves both players near one health. Protect the waiting
|
||||
# player from residual fire/damage while the other player's death is tested.
|
||||
for game in (host, guest):
|
||||
game('command', command='gamemode creative')
|
||||
game('command', command='effect clear @s')
|
||||
game('command', command='effect give @s minecraft:instant_health 1 5 true')
|
||||
host('command', command=f'setworldspawn {hx} {hy} {hz}')
|
||||
host('command', command='gamerule respawn_radius 0')
|
||||
# Keep the inactive player alive and away from the death drops. Earlier
|
||||
# fixtures may leave a personal respawn point or an unsafe waiting position.
|
||||
host('command', command=f'fill {hx - 6} {hy - 1} {hz - 6} {hx + 6} {hy - 1} {hz + 6} minecraft:stone')
|
||||
host('command', command=f'fill {hx - 6} {hy} {hz - 6} {hx + 6} {hy + 3} {hz + 6} minecraft:air')
|
||||
for game, dz in ((host, -3), (guest, 3)):
|
||||
waiting = (hx - 3.5, hy, hz + dz + 0.5)
|
||||
game('command', command=f'spawnpoint @s {hx} {hy} {hz}')
|
||||
game('command', command=f'tp @s {waiting[0]} {waiting[1]} {waiting[2]}')
|
||||
game.until(lambda: pos_of(game), lambda p: math.dist(p, waiting) < 0.1)
|
||||
try:
|
||||
for keep in ('false', 'true'):
|
||||
host('command', command=f'gamerule keep_inventory {keep}')
|
||||
for game, dz in ((host, -3), (guest, 3)):
|
||||
# 14 blocks from the world spawn: nothing dropped is picked up on respawning.
|
||||
x, z = hx + 14, hz + dz
|
||||
host('command', command=f'fill {x - 2} {hy - 1} {z - 1} {x + 2} {hy - 1} {z + 1} minecraft:stone')
|
||||
host('command', command=f'fill {x - 2} {hy} {z - 1} {x + 2} {hy + 2} {z + 1} minecraft:air')
|
||||
# Death drops scatter several blocks before landing. Keep the
|
||||
# entire observation area solid so they cannot fall off a ledge.
|
||||
host('command', command=f'fill {x - 6} {hy - 1} {z - 6} {x + 6} {hy - 1} {z + 6} minecraft:stone')
|
||||
host('command', command=f'fill {x - 6} {hy} {z - 6} {x + 6} {hy + 3} {z + 6} minecraft:air')
|
||||
host('command', command='kill @e[type=minecraft:item]')
|
||||
game('command', command='gamemode survival')
|
||||
game('command', command='clear @s')
|
||||
@@ -4675,8 +4884,10 @@ def check_keep_inventory(host, guest, out):
|
||||
game('command', command='item replace entity @s armor.head with minecraft:iron_helmet')
|
||||
game('command', command=f'tp @s {x + 0.5} {hy} {z + 0.5}')
|
||||
game.wait(20)
|
||||
assert game('state').get('screen') == 'playing', f'{game.name} died during setup'
|
||||
game('command', command='kill @s')
|
||||
game.wait(30)
|
||||
assert game('state').get('screen') == 'dead', f'{game.name} did not die'
|
||||
dropped = sorted((e['item']['item'], e['item']['count'])
|
||||
for e in game.raw('entities', 8, 'minecraft:item')['entities'])
|
||||
game.shot(out, f'keepinv-{keep}')
|
||||
@@ -4686,12 +4897,14 @@ def check_keep_inventory(host, guest, out):
|
||||
seen[f'{game.name}-keep-{keep}'] = {
|
||||
'dropped': dropped,
|
||||
'kept': {item: server_count(game, item) for item in ('diamond', 'iron_helmet')}}
|
||||
game('command', command='gamemode creative')
|
||||
finally:
|
||||
host('command', command='gamerule keep_inventory false')
|
||||
host('command', command='gamerule respawn_radius 10')
|
||||
host('command', command='kill @e[type=minecraft:item]')
|
||||
for game in (host, guest):
|
||||
game('command', command='clear @s')
|
||||
game('command', command='gamemode survival')
|
||||
face_each_other(host, guest)
|
||||
for case, s in seen.items():
|
||||
want = ({'dropped': [], 'kept': {'diamond': 7, 'iron_helmet': 1}} if case.endswith('true') else
|
||||
@@ -4709,6 +4922,16 @@ def check_signs(host, guest, out):
|
||||
seen = {}
|
||||
for game, other, dz in ((host, guest, -2), (guest, host, 2)):
|
||||
spot = (hx + 2, hy, hz + dz)
|
||||
for viewer in (game, other):
|
||||
back_to_game(viewer)
|
||||
# Earlier death/travel checks leave the players at different spawn points.
|
||||
# Give this placement case its own floor, line of sight and reachable target.
|
||||
host('command', command=f'fill {spot[0] - 3} {hy - 1} {spot[2] - 1} {spot[0] + 3} {hy - 1} {spot[2] + 1} minecraft:stone')
|
||||
host('command', command=f'fill {spot[0] - 3} {hy} {spot[2] - 1} {spot[0] + 3} {hy + 3} {spot[2] + 1} minecraft:air')
|
||||
for viewer, dx in ((game, -2), (other, 2)):
|
||||
at = (spot[0] + dx + 0.5, hy, spot[2] + 0.5)
|
||||
viewer('command', command=f'tp @s {at[0]} {at[1]} {at[2]}')
|
||||
viewer.until(lambda: pos_of(viewer), lambda p: math.dist(p, at) < 0.1)
|
||||
game('command', command=f'setblock {spot[0]} {spot[1] - 1} {spot[2]} minecraft:stone')
|
||||
game('command', command=f'setblock {spot[0]} {spot[1]} {spot[2]} minecraft:air')
|
||||
game('command', command='gamemode survival')
|
||||
@@ -4716,7 +4939,12 @@ def check_signs(host, guest, out):
|
||||
game('command', command='give @s minecraft:oak_sign 1')
|
||||
game.wait(10)
|
||||
game.raw('place', *spot, '--item', 'minecraft:oak_sign')
|
||||
game.wait(10)
|
||||
game.until(lambda: game('state').get('screen'), lambda s: s == 'sign', ticks=10)
|
||||
# Drain the placement's initial block-entity data before typing. The
|
||||
# reply travels on the same connection after that data, unlike a local
|
||||
# screen check which may see the editor before the initial data arrives.
|
||||
server_reply(game, f'data get block {spot[0]} {spot[1]} {spot[2]} front_text.messages',
|
||||
'following block data')
|
||||
opened = {g.name: g('state').get('screen') for g in (game, other)}
|
||||
game.shot(out, 'signs-editor')
|
||||
lines = [f'{game.name} wrote', 'line two']
|
||||
@@ -4724,11 +4952,13 @@ def check_signs(host, guest, out):
|
||||
game.raw('key', 'enter', 'tap')
|
||||
game.raw('type', lines[1])
|
||||
game.raw('key', 'esc', 'tap')
|
||||
game.wait(20)
|
||||
game.until(lambda: game('state').get('screen'), lambda s: s == 'playing', ticks=20)
|
||||
back_to_game(other)
|
||||
shown = {g.name: g.until(lambda: (g.raw('block', *spot).get('sign') or {}).get('front'),
|
||||
lambda front: front == lines + ['', ''], ticks=20)
|
||||
for g in (game, other)}
|
||||
seen[game.name] = {'opened': opened,
|
||||
'shown': {g.name: (g.raw('block', *spot).get('sign') or {}).get('front')
|
||||
for g in (game, other)}}
|
||||
'shown': shown}
|
||||
other.shot(out, 'signs-shown')
|
||||
for name, s in seen.items():
|
||||
other = 'guest' if name == 'host' else 'host'
|
||||
@@ -5079,8 +5309,12 @@ def check_fishing(host, guest, out):
|
||||
tracked to the clients as a fishing bobber under its owner), lands on the ground and reels back
|
||||
in; cast into open water with Lure III, a fish bites and reeling in
|
||||
during the bite catches it for 1 (#1348)."""
|
||||
# Both players need a safe floor for the entire other player's fishing wait.
|
||||
apart(host, guest)
|
||||
hx, hy, hz = (int(v // 1) for v in pos_of(host))
|
||||
host('command', command='weather clear')
|
||||
for game in (host, guest):
|
||||
game('command', command='effect give @s minecraft:instant_health 1 5 true')
|
||||
seen = {}
|
||||
try:
|
||||
for game, other, dz in ((host, guest, -5), (guest, host, 5)):
|
||||
@@ -5396,12 +5630,8 @@ def check_digging(host, guest, out):
|
||||
before = heard('minecraft:block.stone.break')
|
||||
guest.raw('look-at', *at(stone))
|
||||
guest.raw('mouse', 'left', 'down')
|
||||
time.sleep(0.4)
|
||||
os.kill(guest.pid, signal.SIGSTOP)
|
||||
try:
|
||||
time.sleep(1.0)
|
||||
finally:
|
||||
os.kill(guest.pid, signal.SIGCONT)
|
||||
guest.wait(8)
|
||||
guest.raw('stall', 1000)
|
||||
resumed = {'guest': guest.raw('block', *stone).get('block'), 'server': host.raw('block', *stone).get('block'),
|
||||
'mining': guest('state').get('mining')}
|
||||
# Let go once it breaks: past it the crosshair reaches the floor.
|
||||
@@ -5597,6 +5827,68 @@ CHECKS += ['knockback']
|
||||
CHECK_FNS.update(knockback=check_knockback)
|
||||
|
||||
|
||||
|
||||
def check_fixture_input(host, guest, out, kind, role):
|
||||
"""Complement seeded rules with real client input and authoritative observations."""
|
||||
player = host if role == 'host' else guest
|
||||
hx, y, hz = (int(v // 1) for v in pos_of(host))
|
||||
x, z = hx + 6, hz + (-8 if role == 'host' else 8)
|
||||
sensor, dispenser, button = (x + 3, y, z + 1), (x, y, z + 3), (x, y, z + 2)
|
||||
player('command', command='gamemode survival')
|
||||
player('command', command='item replace entity @s weapon.mainhand with minecraft:air')
|
||||
host('command', command=f'fill {x - 2} {y - 1} {z - 2} {x + 5} {y - 1} {z + 5} minecraft:stone')
|
||||
host('command', command=f'fill {x - 2} {y} {z - 2} {x + 5} {y + 3} {z + 5} minecraft:air')
|
||||
start = (x + 0.5, y, z + 0.5)
|
||||
player('command', command=f'tp @s {start[0]} {start[1]} {start[2]} 0 0')
|
||||
player.until(lambda: pos_of(player), lambda p: math.dist(p, start) < 0.1)
|
||||
player.raw('look', 0, 0)
|
||||
try:
|
||||
if kind == 'sculk':
|
||||
player.wait(2) # finish setup movement before installing the listener
|
||||
host.raw('setblock', *sensor, 'minecraft:sculk_sensor')
|
||||
phase = lambda: host.raw('getblock', *sensor)['block']
|
||||
host.until(phase, lambda state: 'sculk_sensor_phase=inactive' in state)
|
||||
player.wait(10)
|
||||
assert 'sculk_sensor_phase=inactive' in phase(), 'setup activated the sensor before player input'
|
||||
player.raw('key', 'w', 'down')
|
||||
try:
|
||||
player.wait(15) # defined input duration; no wall-clock simulation sleep
|
||||
finally:
|
||||
player.raw('key', 'w', 'up')
|
||||
moved = {'client': math.dist(pos_of(player), start),
|
||||
'server': math.dist(server_player(host, player)['position'], start)}
|
||||
assert all(d > 1 for d in moved.values()), f'{role} did not walk on both sides: {moved}'
|
||||
active = host.until(phase, lambda state: 'sculk_sensor_phase=active' in state, ticks=85)
|
||||
for viewer in (host, guest):
|
||||
viewer.until(lambda: state_of(viewer, sensor, 'sculk_sensor_phase'), lambda v: v == 'active')
|
||||
return {'moved': moved, 'phase': active}
|
||||
host.raw('setblock', *dispenser, 'minecraft:dispenser[facing=east]')
|
||||
host.raw('container', *dispenser, 'minecraft:diamond', 1)
|
||||
host.raw('setblock', *button, 'minecraft:stone_button[face=wall,facing=north]')
|
||||
player.until(lambda: player.raw('block', *button)['block'], lambda v: v == 'minecraft:stone_button')
|
||||
player.raw('interact', *button)
|
||||
slots = host.until(lambda: host.raw('container', *dispenser)['slots'], lambda v: all(s is None for s in v))
|
||||
dropped = {}
|
||||
for viewer in (host, guest):
|
||||
dropped[viewer.name] = viewer.until(
|
||||
lambda: [e for e in viewer.raw('entities', 24, 'minecraft:item')['entities']
|
||||
if e.get('item', {}).get('item') == 'minecraft:diamond'
|
||||
and math.dist(e['pos'], (x + 1.5, y + 0.5, z + 3.5)) < 3],
|
||||
lambda drops: len(drops) == 1 and drops[0]['item']['count'] == 1)
|
||||
player.shot(out, f'{kind}-input')
|
||||
return {'slots': slots, 'drops': dropped}
|
||||
finally:
|
||||
player.raw('key', 'w', 'up')
|
||||
host('command', command=f'fill {x - 2} {y} {z - 2} {x + 5} {y + 3} {z + 5} minecraft:air')
|
||||
|
||||
|
||||
for _kind in ('sculk', 'dispenser'):
|
||||
for _role in ('host', 'guest'):
|
||||
_name = f'{_kind}_input_{_role}'
|
||||
CHECKS.append(_name)
|
||||
CHECK_FNS[_name] = lambda h, g, o, kind=_kind, role=_role: check_fixture_input(h, g, o, kind, role)
|
||||
|
||||
|
||||
def check_hero_trading(host, guest, out):
|
||||
"""Villager.updateSpecialPrices keeps the trading player's Hero effect: the offer sent to the
|
||||
client and the server's payment consumption agree, independently of the other player's effect."""
|
||||
@@ -6486,6 +6778,94 @@ CHECKS += ['sprint-fov']
|
||||
CHECK_FNS['sprint-fov'] = check_sprint_fov
|
||||
|
||||
|
||||
def check_critical_hits(host, guest, out):
|
||||
"""#1898: a real falling melee hit emits crits on the attacker and observer.
|
||||
Grounded hits and refused falling hits emit none, against mobs and players.
|
||||
"""
|
||||
x, y, z = map(math.floor, pos_of(host))
|
||||
target = [x + 2.5, y, z + 0.5]
|
||||
tag = 'critical_hit_particles'
|
||||
seen = {}
|
||||
host('command', command=f'fill {x - 3} {y - 1} {z - 3} {x + 6} {y - 1} {z + 6} minecraft:stone')
|
||||
host('command', command=f'fill {x - 3} {y} {z - 3} {x + 6} {y + 5} {z + 6} minecraft:air')
|
||||
host('command', command='time set midnight')
|
||||
host('command', command='gamerule natural_health_regeneration false')
|
||||
try:
|
||||
for label, player, other in (('host', host, guest), ('guest', guest, host)):
|
||||
for kind in ('zombie', 'player'):
|
||||
for hit in ('grounded', 'critical', 'refused'):
|
||||
case = f'{label}-{kind}-{hit}'
|
||||
for game in (player, other):
|
||||
game('command', command='gamemode survival')
|
||||
game('command', command='clear @s')
|
||||
game('command', command='effect clear @s')
|
||||
game('command', command='effect give @s minecraft:instant_health 1 5 true')
|
||||
player('command', command=f'tp @s {x + 0.5} {y} {z + 0.5}')
|
||||
other_at = target if kind == 'player' else [x + 0.5, y, z + 4.5]
|
||||
other('command', command=f'tp @s {other_at[0]} {other_at[1]} {other_at[2]}')
|
||||
host('command', command=f'gamerule pvp {str(hit != "refused").lower()}')
|
||||
mob_id = None
|
||||
if kind == 'zombie':
|
||||
host('command', command=f'summon minecraft:zombie {target[0]} {y} {target[2]} '
|
||||
f'{{NoAI:1b,PersistenceRequired:1b,Invulnerable:{int(hit == "refused")}b,Tags:["{tag}"]}}')
|
||||
player.wait(20) # full attack charge and paired entities
|
||||
if kind == 'zombie':
|
||||
mob = next(m for m in player.raw('mobs', 16)['near']
|
||||
if m['kind'] == 'minecraft:zombie' and math.dist(m['pos'], target) < 0.1)
|
||||
mob_id = mob['id']
|
||||
assert mob_seen(other, mob_id), f'{case}: observer has not paired the zombie'
|
||||
health_before = mob_seen(player, mob_id)['health'] if mob_id is not None else hearts(other)[1]
|
||||
sound = 'minecraft:entity.player.attack.crit'
|
||||
sounds_before = {side: heard(g, sound) for side, g in (('own', player), ('other', other))}
|
||||
|
||||
def strike():
|
||||
if hit != 'grounded':
|
||||
player.raw('key', 'space', 'down')
|
||||
player.wait(1)
|
||||
player.raw('key', 'space', 'up')
|
||||
body = None
|
||||
for _ in range(15):
|
||||
body = player('state')['player']
|
||||
# Let the server record the fall before the attack packet.
|
||||
if not body['on_ground'] and body['velocity'][1] < -0.2:
|
||||
break
|
||||
player.wait(1)
|
||||
assert body and not body['on_ground'] and body['velocity'][1] < -0.2, \
|
||||
f'{case}: jump never reached its falling phase: {body}'
|
||||
player.raw('look-at', target[0], y + 1, target[2])
|
||||
player.raw('mouse', 'left', 'click')
|
||||
|
||||
particles = sparked(player, other, ['crit'], strike)
|
||||
player.shot(out, f'critical-hits-{kind}-{hit}-{label}')
|
||||
player.wait(10) # finish the three-tick emitter and health replication
|
||||
health_after = mob_seen(player, mob_id)['health'] if mob_id is not None else hearts(other)[1]
|
||||
sounds = {side: heard(g, sound) - sounds_before[side]
|
||||
for side, g in (('own', player), ('other', other))}
|
||||
seen[case] = {'particles': particles, 'crit_sounds': sounds,
|
||||
'health': [health_before, health_after]}
|
||||
host('command', command=f'kill @e[tag={tag}]')
|
||||
assert (health_after == health_before) if hit == 'refused' else (health_after < health_before), \
|
||||
f'{case}: unexpected damage: {seen[case]}'
|
||||
assert all(n == int(hit == 'critical') for n in sounds.values()), \
|
||||
f'{case}: the server did not recognize the expected crit: {seen[case]}'
|
||||
wrong = {case: result for case, result in seen.items()
|
||||
if any((n <= 0 if case.endswith('-critical') else n != 0)
|
||||
for n in result['particles'].values())}
|
||||
assert not wrong, f'critical-hit particles: {wrong}'
|
||||
return seen
|
||||
finally:
|
||||
host('command', command=f'kill @e[tag={tag}]')
|
||||
host('command', command='gamerule pvp true')
|
||||
host('command', command='gamerule natural_health_regeneration true')
|
||||
host('command', command='time set day')
|
||||
for game in (host, guest):
|
||||
game.raw('key', 'space', 'up')
|
||||
|
||||
|
||||
CHECKS += ['critical-hits']
|
||||
CHECK_FNS['critical-hits'] = check_critical_hits
|
||||
|
||||
|
||||
def check_sculk_container(host, guest, out):
|
||||
"""A real guest's container interaction emits a server game event. Both
|
||||
clients see the sensor and the non-summoning shrieker activate and reset.
|
||||
@@ -6591,5 +6971,183 @@ CHECKS += ['replant']
|
||||
CHECK_FNS['replant'] = check_replant
|
||||
|
||||
|
||||
def check_guardian_beams(host, guest, out):
|
||||
"""Guardian's synced target drives the same beam on each client (#1491).
|
||||
|
||||
Guardian.defineSynchedData/onSyncedDataUpdated/aiStep and
|
||||
GuardianRenderer.extractRenderState: charge, hit, then target loss.
|
||||
Run with both --server-thread and the in-frame host.
|
||||
"""
|
||||
x, y, z = map(math.floor, pos_of(host))
|
||||
host('command', command='difficulty normal')
|
||||
host('command', command='gamerule natural_health_regeneration false')
|
||||
host('command', command=f'fill {x - 10} {y - 2} {z - 10} {x + 10} {y + 4} {z + 10} minecraft:water')
|
||||
seen = {}
|
||||
try:
|
||||
for kind in ('guardian', 'elder_guardian'):
|
||||
for target, observer in ((host, guest), (guest, host)):
|
||||
for game in (host, guest):
|
||||
game('command', command='gamemode creative')
|
||||
game('command', command='effect give @s minecraft:water_breathing infinite')
|
||||
target('command', command=f'tp @s {x + 0.5} {y} {z + 0.5} 0 0')
|
||||
observer('command', command=f'tp @s {x + 4.5} {y} {z + 0.5} 0 0')
|
||||
target('command', command='effect give @s minecraft:instant_health 1 10')
|
||||
target('command', command='gamemode survival')
|
||||
host('command', command=f'summon minecraft:{kind} {x + 0.5} {y} {z + 6.5}')
|
||||
|
||||
def mob(game):
|
||||
return next(m for m in game.raw('mobs', 32)['near'] if m['kind'] == f'minecraft:{kind}')
|
||||
|
||||
def charging():
|
||||
for _ in range(60):
|
||||
target.wait(2)
|
||||
states = [mob(g) for g in (target, observer)]
|
||||
if all(m['guardian_beam'] is not None for m in states):
|
||||
return states
|
||||
raise Failed(f'{kind} never charged on both clients')
|
||||
|
||||
states = charging()
|
||||
assert states[0]['target'] == 'Player', states
|
||||
# The host reads the level that ticks the guardian (its own in-frame, the
|
||||
# server's on the server thread), where a targeted player is `Player`.
|
||||
if observer is host:
|
||||
assert states[1]['target'] == 'Player', states
|
||||
else:
|
||||
assert states[1]['target'].startswith('Mob('), states
|
||||
first = states[0]['guardian_beam'][0]
|
||||
target.wait(4)
|
||||
assert mob(target)['guardian_beam'][0] > first, 'client charge clock did not advance'
|
||||
for game in (target, observer):
|
||||
game.raw('look-at', x + 0.5, y + 0.5, z + 6.5)
|
||||
game.shot(out, f'{kind}-{target.name}-charge')
|
||||
# The beam must end after the first hit (before another charge).
|
||||
before = target('status')['player']['health']
|
||||
for _ in range(70):
|
||||
target.wait(2)
|
||||
if all(mob(g)['guardian_beam'] is None for g in (target, observer)):
|
||||
break
|
||||
else:
|
||||
raise Failed(f'{kind} beam did not end after its attack')
|
||||
after = target('status')['player']['health']
|
||||
assert after < before, f'{kind} beam ended without damage: {before} -> {after}'
|
||||
charging()
|
||||
target('command', command='gamemode creative')
|
||||
target.wait(10)
|
||||
assert all(mob(g)['guardian_beam'] is None for g in (target, observer)), 'beam survived target loss'
|
||||
seen[f'{kind}-{target.name}'] = {
|
||||
'charge': [{'target': m['target'], 'beam': m['guardian_beam']} for m in states],
|
||||
'health': [before, after]}
|
||||
host('command', command=f'kill @e[type=minecraft:{kind}]')
|
||||
host.wait(10)
|
||||
finally:
|
||||
for kind in ('guardian', 'elder_guardian'):
|
||||
host('command', command=f'kill @e[type=minecraft:{kind}]')
|
||||
for game in (host, guest):
|
||||
game('command', command='gamemode creative')
|
||||
game('command', command='effect clear @s')
|
||||
return seen
|
||||
|
||||
|
||||
CHECKS += ['guardian-beams']
|
||||
CHECK_FNS['guardian-beams'] = check_guardian_beams
|
||||
|
||||
|
||||
def check_sonic(host, guest, out):
|
||||
"""A real warden's ray reaches connected clients once, with normal damage.
|
||||
|
||||
Run with and without --server-thread to cover the window's local renderer too.
|
||||
The creative observer sees the same ray nearby and none outside sendParticles' range.
|
||||
"""
|
||||
x, y, z = (int(v // 1) for v in pos_of(host))
|
||||
result = {}
|
||||
guest('command', command='gamemode creative')
|
||||
host('command', command='difficulty normal')
|
||||
host('command', command='gamerule natural_health_regeneration false')
|
||||
try:
|
||||
host('command', command=f'fill {x - 3} {y - 1} {z - 3} {x + 85} {y - 1} {z + 14} minecraft:stone')
|
||||
host('command', command=f'fill {x - 3} {y} {z - 3} {x + 15} {y + 4} {z + 14} minecraft:air')
|
||||
host('command', command=f'fill {x - 2} {y} {z + 4} {x + 2} {y + 3} {z + 4} minecraft:stone')
|
||||
for near in (True, False):
|
||||
guest('command', command=f'tp @s {x + (3 if near else 80) + 0.5} {y} {z + 0.5}')
|
||||
host('command', command=f'tp @s {x + 0.5} {y} {z + 0.5} 0 0')
|
||||
host('command', command='gamemode survival')
|
||||
host('command', command='effect give @s minecraft:instant_health 1 5')
|
||||
host.wait(4)
|
||||
host('command', command=f'summon minecraft:warden {x + 0.5} {y} {z + 9.5} {{NoAI:1b,Tags:["sonic_test"]}}')
|
||||
host('command', command='attribute @e[tag=sonic_test,limit=1] minecraft:knockback_resistance base set 1')
|
||||
before = {side: made(g, 'sonic_boom') for side, g in (('host', host), ('guest', guest))}
|
||||
health = host('status')['player']['health']
|
||||
host('command', command='data merge entity @e[tag=sonic_test,limit=1] {NoAI:0b}')
|
||||
host('command', command='attribute @e[tag=sonic_test,limit=1] minecraft:movement_speed base set 0')
|
||||
host('command', command='damage @e[tag=sonic_test,limit=1] 1 minecraft:player_attack by @s')
|
||||
for _ in range(400):
|
||||
host.wait(2)
|
||||
if host('status')['player']['health'] < health:
|
||||
break
|
||||
host.wait(2) # let the observer process the same packet batch
|
||||
seen = {side: made(g, 'sonic_boom') - before[side] for side, g in (('host', host), ('guest', guest))}
|
||||
after = host('status')['player']['health']
|
||||
result['near' if near else 'far'] = {'particles': seen, 'health': [health, after]}
|
||||
host.shot(out, f'sonic-{"near" if near else "far"}')
|
||||
host('command', command='kill @e[tag=sonic_test]')
|
||||
assert after == health - 10, result
|
||||
assert seen['host'] == 15, result
|
||||
assert seen['guest'] == (15 if near else 0), result
|
||||
finally:
|
||||
host('command', command='kill @e[tag=sonic_test]')
|
||||
host('command', command='gamerule natural_health_regeneration true')
|
||||
return result
|
||||
|
||||
|
||||
CHECKS += ['sonic']
|
||||
CHECK_FNS['sonic'] = check_sonic
|
||||
|
||||
|
||||
def check_cushions(host, guest, out):
|
||||
"""#1935: place a colored cushion, consume it, track it, sit, dismount and break it."""
|
||||
seen = {}
|
||||
for label, player, color in (('host', host, 'red'), ('guest', guest, 'blue')):
|
||||
x, y, z = (int(v // 1) for v in pos_of(player))
|
||||
at = (x + 0.5, y, z + 2.5)
|
||||
host('command', command=f'fill {x - 1} {y} {z + 1} {x + 1} {y + 3} {z + 3} minecraft:air')
|
||||
host('command', command=f'setblock {x} {y - 1} {z + 2} minecraft:stone')
|
||||
player('command', command='gamemode survival')
|
||||
player('command', command=f'item replace entity @s weapon.mainhand with minecraft:{color}_cushion')
|
||||
player.wait(10)
|
||||
player.raw('look-at', *at)
|
||||
player.raw('mouse', 'right', 'click')
|
||||
player.wait(15)
|
||||
def cushions(game):
|
||||
return [o for o in game('status')['objects'] if o['kind'] == 'minecraft:cushion'
|
||||
and abs(o['position'][0] - at[0]) < .1 and abs(o['position'][2] - at[2]) < .1]
|
||||
server, client = cushions(host), cushions(player)
|
||||
seen[label] = {'server': server, 'client': client,
|
||||
'remaining': player('inventory')['counts'].get(f'minecraft:{color}_cushion', 0)}
|
||||
assert len(server) == len(client) == 1, seen
|
||||
assert server[0]['color'] == client[0]['color'] == color, seen
|
||||
assert seen[label]['remaining'] == 0, seen
|
||||
player.shot(out, 'cushion-placed')
|
||||
player.raw('look-at', at[0], at[1] + .125, at[2])
|
||||
player.raw('mouse', 'right', 'click')
|
||||
player.wait(10)
|
||||
seen[label]['riding'] = player('status').get('riding')
|
||||
assert seen[label]['riding'] == server[0]['id'], seen
|
||||
player.raw('key', 'shift', 'down')
|
||||
player.wait(5)
|
||||
player.raw('key', 'shift', 'up')
|
||||
player.wait(5)
|
||||
assert player('status').get('riding') is None, seen
|
||||
player('command', command='gamemode creative')
|
||||
player.raw('look-at', at[0], at[1] + .125, at[2])
|
||||
player.raw('mouse', 'left', 'click')
|
||||
player.wait(10)
|
||||
assert not cushions(host) and not cushions(player), seen
|
||||
return seen
|
||||
|
||||
|
||||
CHECKS += ['cushions']
|
||||
CHECK_FNS['cushions'] = check_cushions
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -9,13 +9,16 @@ import subprocess
|
||||
|
||||
try:
|
||||
from . import lab, test_rust_parity as base, test_model_baking_parity as baking
|
||||
from .integration_env import run_game
|
||||
except ImportError:
|
||||
import lab, test_rust_parity as base, test_model_baking_parity as baking
|
||||
from integration_env import run_game
|
||||
|
||||
|
||||
def run_logged(command, build, name, timeout=900, **kwargs):
|
||||
with (build / (name + '.log')).open('w') as log:
|
||||
subprocess.run([str(c) for c in command], cwd=lab.ROOT, check=True, timeout=timeout,
|
||||
runner = run_game if Path(command[0]).name == 'horizon-client' else subprocess.run
|
||||
runner([str(c) for c in command], cwd=lab.ROOT, check=True, timeout=timeout,
|
||||
stdout=log, stderr=subprocess.STDOUT, **kwargs)
|
||||
|
||||
|
||||
|
||||
+14
-1
@@ -11,6 +11,9 @@
|
||||
python3 tools/parity.py --list # what would run, without running it
|
||||
python3 tools/parity.py --status # last result of every harness
|
||||
|
||||
Harnesses in parity_hosts.json's "named_only" run only when named or with --all
|
||||
(the nightly audit): no automatic selection picks them.
|
||||
|
||||
Each harness runs unmodified, in parallel, under a tracer that records what it
|
||||
read: its Python modules, Java oracle sources, other repository files, and the
|
||||
Rust sources of every probe it executed (from Cargo's dep-info). A harness
|
||||
@@ -1306,6 +1309,12 @@ def platform_skips(config):
|
||||
return dict(config.get("linux_only", {}))
|
||||
|
||||
|
||||
def named_only(config):
|
||||
"""Harnesses tools/parity_hosts.json keeps out of every automatic selection (--changed, --failed, the default,
|
||||
--flake-check): they run only when named or with --all, the nightly audit. {name: reason}"""
|
||||
return dict(config.get("named_only", {}))
|
||||
|
||||
|
||||
def finished_run(failed):
|
||||
"""Record that this run completed, for tools/gate.py: a crashed runner never writes it."""
|
||||
STATE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
@@ -1390,9 +1399,13 @@ def main():
|
||||
for name in [name for name in chosen if base_name(name) in skips and not args.names]:
|
||||
print(f"skipped on {sys.platform}: {name}: {skips[base_name(name)]}", flush=True)
|
||||
chosen.remove(name)
|
||||
manual = {} if args.names or args.all else named_only(host_config())
|
||||
for name in [name for name in chosen if base_name(name) in manual]:
|
||||
print(f"not selected (runs when named, and nightly): {name}: {manual[base_name(name)]}", flush=True)
|
||||
chosen.remove(name)
|
||||
rounds = {name: args.repeat for name in chosen} if args.repeat > 1 else {}
|
||||
if args.flake_check:
|
||||
changed = changed_harnesses(found, records, args.flake_check)
|
||||
changed = {name for name in changed_harnesses(found, records, args.flake_check) if base_name(name) not in manual}
|
||||
for name in sorted(changed):
|
||||
# A pass counts for a changed harness only if it held over enough runs.
|
||||
if name not in chosen and records.get(name, {}).get("rounds", 1) < args.flake_rounds:
|
||||
|
||||
+14
-1
@@ -20,6 +20,16 @@
|
||||
"nice": 19,
|
||||
"note": "ludodesktop, the maintainer's own machine: only while nobody uses it (tools/ci/runner_pause.py: screen locked or untouched for 15 min, no game; a paused desktop refuses workers and stops the running ones, whose harnesses then run here); 8 jobs at most, in the CI runner's environment and slice"
|
||||
},
|
||||
"playhorizon": {
|
||||
"ssh": "ludovic@playhorizon",
|
||||
"root": ".actions-runners/horizon/parity-host",
|
||||
"shell": "systemd-run --user --scope --quiet --slice=horizon-ci.slice --unit=horizon-parity-worker-$$ bash -c",
|
||||
"setup": "test ! -e ~/.actions-runners/horizon/paused && set -a && . ~/.actions-runners/horizon/.env && set +a && export PATH=$(cat ~/.actions-runners/horizon/.path) && unset WAYLAND_DISPLAY && export DISPLAY=:$(cat ~/.actions-runners/horizon/display)",
|
||||
"python": "python3.13",
|
||||
"jobs": 6,
|
||||
"nice": 10,
|
||||
"note": "a partner's server (Ubuntu, 8 EPYC threads, 30 GB, Detroit; tailnet only), used by nothing else: 6 jobs, in the CI runner's environment, slice and Xvfb screen (tools/ci/linux-runner.sh); the light Linux checks that used to go to the ThinkPad go here"
|
||||
},
|
||||
"thinkpad": {
|
||||
"ssh": "thinkpad",
|
||||
"root": "code/horizon-parity",
|
||||
@@ -36,5 +46,8 @@
|
||||
"local_only": {
|
||||
"save_roundtrip": "runs the game on a virtual screen (vscreen) with a null ALSA device, or offscreen in the logged-in macOS session"
|
||||
},
|
||||
"linux_only": {}
|
||||
"linux_only": {},
|
||||
"named_only": {
|
||||
"lan_integration": "the whole lan_e2e suite: ~40 min a run on a loaded runner, and single checks flake under load; run it by name, or tools/lan_e2e.py"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,34 +78,35 @@ def bisect(since, timeout, comment):
|
||||
failed = json.loads(LAST_RUN.read_text(encoding="utf-8")).get("failed") or []
|
||||
if not failed:
|
||||
print("No failed harness recorded: nothing to bisect.")
|
||||
return 0
|
||||
return 1
|
||||
head = git("rev-parse", "HEAD").stdout.strip()
|
||||
commits = git("rev-list", "--first-parent", "--reverse", f"{since}..{head}").stdout.split()
|
||||
if not commits:
|
||||
print("No merge since the base.")
|
||||
return 0
|
||||
return 1
|
||||
|
||||
def fails(commit):
|
||||
print(f"--- {commit[:9]} {git('log', '-1', '--format=%s', commit).stdout.strip()}", flush=True)
|
||||
git("checkout", "-q", "--detach", commit)
|
||||
return run_harnesses(failed, timeout)
|
||||
|
||||
def blame_nobody(why):
|
||||
def blame_nobody(why, code):
|
||||
line = f"parity-main: {', '.join(failed)} {why}: no merge is named."
|
||||
print(line)
|
||||
if os.environ.get("GITHUB_STEP_SUMMARY"):
|
||||
with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as summary:
|
||||
summary.write(f"### {line}\n")
|
||||
return 0
|
||||
return code
|
||||
|
||||
# A merge is named only when the harnesses fail again at HEAD and pass at the base: otherwise the search would
|
||||
# end on the newest merge (a flake, or a runner missing files, passes everywhere now) or the oldest one (the
|
||||
# runner fails at every commit) and blame it for nothing.
|
||||
# runner fails at every commit) and blame it for nothing. The exit code is the run's verdict: 0 only when every
|
||||
# failed harness passes when run again at HEAD (the commit is good, so releases may follow it), 1 otherwise.
|
||||
try:
|
||||
if not fails(head):
|
||||
return blame_nobody(f"pass when run again at {head[:9]}: a flake or the runner")
|
||||
return blame_nobody(f"pass when run again at {head[:9]}: a flake, counted as a pass", 0)
|
||||
if fails(since):
|
||||
return blame_nobody(f"fail at the base {since[:9]} too: the runner or a flake")
|
||||
return blame_nobody(f"fail at the base {since[:9]} too: the runner or a flake", 1)
|
||||
culprit = first_bad(commits, fails) if len(commits) > 1 else commits[0]
|
||||
finally:
|
||||
git("checkout", "-q", "--detach", head)
|
||||
@@ -122,7 +123,7 @@ def bisect(since, timeout, comment):
|
||||
body = (f"🤖 Agent: parity-main found that this merge breaks {', '.join(f'`{name}`' for name in failed)} on main "
|
||||
f"(bisected over {len(commits)} merges: {url}). Releases wait until parity-main passes again.")
|
||||
subprocess.run(["gh", "pr", "comment", number.group(1), "--repo", REPO, "--body", body])
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Mods' quiet commands on Horizon's dedicated server, end to end (horizon_protocol::quiet).
|
||||
|
||||
Horizon's dedicated server (a flat world) and Horizon's headless client (`HORIZON_NET_REPORT`, the net
|
||||
harness), which joins, then sends a batch of quiet commands as a mod would (`HORIZON_NET_QUIET`):
|
||||
|
||||
- as a player who isn't an operator: `setblock` is refused (the block stays air), as it would be typed;
|
||||
- as an operator: `setblock` runs, a `fill` that changes nothing fails, and `say` is refused (a chat
|
||||
message needs the player's signature);
|
||||
- either way the player's chat gets nothing of them, and the server logs one line per batch: the player,
|
||||
the mod, how many ran and how many failed.
|
||||
|
||||
python3 tools/quiet_commands_e2e.py --bin-dir target/fast
|
||||
|
||||
The client runs with fresh HORIZON_HOME, launcher and XDG folders and without audio; the logs go to --out.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import lab # noqa: E402
|
||||
from integration_env import run_game # noqa: E402
|
||||
from test_dedicated_server_parity import Server # noqa: E402
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PLAYER = 'Tester'
|
||||
PROPERTIES = {
|
||||
'online-mode': 'false',
|
||||
'white-list': 'false',
|
||||
'level-type': 'minecraft\\:flat',
|
||||
'generate-structures': 'false',
|
||||
'spawn-protection': '0',
|
||||
'view-distance': '3',
|
||||
'simulation-distance': '3',
|
||||
'pause-when-empty-seconds': '-1',
|
||||
}
|
||||
BLOCK = '2 -55 2'
|
||||
# What a player would see of these commands, were they typed.
|
||||
FEEDBACK = ['Changed the block', 'No blocks were filled', 'Unknown or incomplete command', 'hi from a mod',
|
||||
'Could not set the block']
|
||||
|
||||
|
||||
def join(binary, port, out, label, lines):
|
||||
"""The headless client joins, sends `lines` as one quiet batch and leaves: its report."""
|
||||
home = Path(tempfile.mkdtemp(prefix=f'quiet-{label}-'))
|
||||
report = out / f'{label}-report.json'
|
||||
# run_game gives the game fresh home, launcher and XDG folders.
|
||||
env = dict(HORIZON_NET_REPORT=str(report), HORIZON_NET_QUIET=';'.join(lines))
|
||||
with (out / f'{label}-client.log').open('w') as log:
|
||||
run_game([str(binary), '--resources', str(lab.RESOURCES), '--render-distance', '2',
|
||||
'--server', f'127.0.0.1:{port}', '--name', PLAYER],
|
||||
cwd=home, env=dict(os.environ, **env), stdout=log, stderr=subprocess.STDOUT, timeout=300,
|
||||
check=True)
|
||||
shutil.rmtree(home, ignore_errors=True)
|
||||
return json.loads(report.read_text())
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('--bin-dir', help='a prebuilt horizon-client (default: build it with the fast profile)')
|
||||
parser.add_argument('--out', default=str(ROOT / '.local/quiet-commands-e2e'), help='logs go here')
|
||||
args = parser.parse_args()
|
||||
out = Path(args.out)
|
||||
shutil.rmtree(out, ignore_errors=True)
|
||||
out.mkdir(parents=True)
|
||||
if args.bin_dir:
|
||||
binary = Path(args.bin_dir) / 'horizon-client'
|
||||
else:
|
||||
subprocess.run(['cargo', 'build', '--profile', 'fast', '-p', 'horizon-client', '--bin', 'horizon-client'],
|
||||
cwd=ROOT, check=True)
|
||||
binary = Path(lab.cargo_target()) / 'fast' / 'horizon-client'
|
||||
port = lab.free_port()
|
||||
directory = out / 'server'
|
||||
directory.mkdir()
|
||||
props = dict(PROPERTIES, **{'server-port': str(port)})
|
||||
(directory / 'server.properties').write_text(''.join(f'{k}={v}\n' for k, v in props.items()),
|
||||
encoding='iso-8859-1')
|
||||
(directory / 'eula.txt').write_text('eula=true\n')
|
||||
server = Server([binary, '--resources', lab.RESOURCES, '--dedicated', '--nogui'], directory, 'server')
|
||||
failures = []
|
||||
|
||||
def check(what, ok, detail=''):
|
||||
print(('PASS ' if ok else 'FAIL ') + what + ('' if ok else f': {detail}'))
|
||||
if not ok:
|
||||
failures.append(what)
|
||||
|
||||
def test_block(want):
|
||||
"""The console's `execute if block`: 'Test passed' when the block is `want`."""
|
||||
before = len(server.lines)
|
||||
server.console(f'execute if block {BLOCK} {want}')
|
||||
deadline = time.time() + 30
|
||||
while time.time() < deadline:
|
||||
answer = [l for l in server.lines[before:] if 'Test passed' in l or 'Test failed' in l]
|
||||
if answer:
|
||||
return 'Test passed' in answer[0]
|
||||
time.sleep(0.2)
|
||||
raise AssertionError('the console never answered execute if block')
|
||||
|
||||
try:
|
||||
server.wait_for(r'Done \(')
|
||||
# Not an operator: the setblock is refused, as typed.
|
||||
got = join(binary, port, out, 'not-op', [f'setblock {BLOCK} minecraft:gold_block'])
|
||||
server.wait_for(rf'{PLAYER} ran 1 quiet command\(s\) from mod net_harness: 1 failed', timeout=30)
|
||||
check('not an operator: connected throughout', got['error'] is None, got['error'])
|
||||
check("not an operator: a quiet setblock is refused", not test_block('minecraft:gold_block'))
|
||||
heard = [c for c in got['chat'] if any(f in c for f in FEEDBACK)]
|
||||
check('not an operator: nothing in the chat', not heard, heard)
|
||||
server.wait_for(rf'{PLAYER} left the game', timeout=60)
|
||||
# An operator: it runs, quietly.
|
||||
server.console(f'op {PLAYER}')
|
||||
server.wait_for(rf'Made {PLAYER} a server operator', timeout=30)
|
||||
got = join(binary, port, out, 'op', [f'setblock {BLOCK} minecraft:gold_block',
|
||||
f'fill {BLOCK} {BLOCK} minecraft:gold_block', 'say hi from a mod'])
|
||||
server.wait_for(rf'{PLAYER} ran 3 quiet command\(s\) from mod net_harness: 2 failed', timeout=30)
|
||||
check('operator: connected throughout', got['error'] is None, got['error'])
|
||||
check('operator: the quiet setblock ran', test_block('minecraft:gold_block'))
|
||||
heard = [c for c in got['chat'] if any(f in c for f in FEEDBACK)]
|
||||
check('operator: nothing in the chat (no feedback, no failure, no say)', not heard, heard)
|
||||
said = [l for l in server.lines if 'hi from a mod' in l]
|
||||
check('operator: say is refused', not said, said)
|
||||
finally:
|
||||
server.stop()
|
||||
print(f'logs: {out}')
|
||||
sys.exit(1 if failures else 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -25,9 +25,11 @@ import sys
|
||||
|
||||
try:
|
||||
from . import lab, test_rust_parity as base
|
||||
from .integration_env import run_game
|
||||
from . import command_exec_corpus as corpus_module
|
||||
except ImportError:
|
||||
import lab
|
||||
from integration_env import run_game
|
||||
import test_rust_parity as base
|
||||
import command_exec_corpus as corpus_module
|
||||
|
||||
@@ -55,7 +57,8 @@ def main():
|
||||
|
||||
def run(command, name, **kw):
|
||||
with (build / (name + '.log')).open('w', encoding='utf-8') as log:
|
||||
result = subprocess.run(list(map(str, command)), stdout=log, stderr=subprocess.STDOUT, **kw)
|
||||
runner = run_game if Path(command[0]).name == 'horizon-client' else subprocess.run
|
||||
result = runner(list(map(str, command)), stdout=log, stderr=subprocess.STDOUT, **kw)
|
||||
if result.returncode:
|
||||
tail = (build / (name + '.log')).read_text(errors='replace')[-3000:]
|
||||
sys.exit(f'{name} failed ({result.returncode}):\n{tail}')
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare cushion support, burial and coverage against vanilla's real checks."""
|
||||
import json
|
||||
import random
|
||||
|
||||
try:
|
||||
from . import lab, oracle_harness as harness
|
||||
except ImportError:
|
||||
import lab, oracle_harness as harness
|
||||
|
||||
|
||||
def make_input(build):
|
||||
full = [[0, 0, 0, 1, 1, 1]]
|
||||
shapes = [[], full, [[0, 0, 0, 1, .5, 1]], [[0, .5, 0, 1, 1, 1]],
|
||||
[[.375, 0, .375, .625, 1.5, .625]], [[0, 0, 0, .5, 1, 1]],
|
||||
[[0, 0, 0, .5, 1, 1], [.5, 0, 0, 1, 1, 1]]]
|
||||
rows = []
|
||||
for x, z in ((0, 0), (-2, -3), (17, 31)):
|
||||
for y in (0, .125, .5, .875, 1, 1.00000001, 1.015625, 1.125):
|
||||
for outline in shapes:
|
||||
for collision in shapes:
|
||||
for suffocating in (False, True):
|
||||
rows.append(dict(pos=[x + .5, y, z + .5],
|
||||
cells=[[x, 0, z, outline, collision, suffocating]]))
|
||||
rng = random.Random(1935)
|
||||
for _ in range(500):
|
||||
cells = []
|
||||
for y in (-1, 0, 1):
|
||||
for x in (-1, 0, 1):
|
||||
for z in (-1, 0, 1):
|
||||
if rng.random() < .3:
|
||||
cells.append([x, y, z, rng.choice(shapes), rng.choice(shapes), bool(rng.randrange(2))])
|
||||
rows.append(dict(pos=[rng.choice((0, .5, 1)), rng.choice((0, .5, 1, 1.125)), rng.choice((0, .5, 1))], cells=cells))
|
||||
path = build / 'inputs.jsonl'
|
||||
path.write_text(''.join(json.dumps(row) + '\n' for row in rows))
|
||||
return path, len(rows)
|
||||
|
||||
|
||||
def main():
|
||||
harness.differential(
|
||||
'rust-cushion-placement-parity', 'VanillaCushionPlacementOracle',
|
||||
'cushion_placement_probe', make_input,
|
||||
'Actual Cushion.canBePlacedAt and wouldSurviveAt, with controlled outline, collision '
|
||||
'and suffocation queries. Includes partial supports, burial, complete coverage, '
|
||||
'overhanging outlines, negative coordinates and boundary heights. Item use, '
|
||||
'entity tracking, interaction and persistence are checked separately.',
|
||||
sources=[lab.ROOT / 'crates/horizon-client/src/cushion.rs'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -65,13 +65,16 @@ import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import tempfile
|
||||
import time
|
||||
import zlib
|
||||
|
||||
try:
|
||||
from . import lab, oracle_harness as oh, test_rust_parity as base
|
||||
from .integration_env import game_environment, run_game
|
||||
from .lab import free_port # the other server harnesses import it from here
|
||||
except ImportError:
|
||||
from integration_env import game_environment, run_game
|
||||
import lab
|
||||
import oracle_harness as oh
|
||||
import test_rust_parity as base
|
||||
@@ -124,9 +127,11 @@ class Server:
|
||||
self.log_path = directory.parent / f'{log_name}.log'
|
||||
self.log = self.log_path.open('w', encoding='utf-8')
|
||||
self.lines = []
|
||||
self.process = subprocess.Popen(list(map(str, command)), cwd=directory, stdin=subprocess.PIPE,
|
||||
self.scratch = tempfile.TemporaryDirectory(prefix='hz-server-')
|
||||
env = game_environment(os.environ, self.scratch.name)
|
||||
self.process = subprocess.Popen(list(map(str, command)), cwd=directory, env=env, stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
|
||||
encoding='utf-8', errors='replace', env=lab.game_env())
|
||||
encoding='utf-8', errors='replace')
|
||||
self.reader = threading.Thread(target=self._read, daemon=True)
|
||||
self.reader.start()
|
||||
|
||||
@@ -163,6 +168,7 @@ class Server:
|
||||
self.process.wait()
|
||||
self.reader.join(timeout=10)
|
||||
self.log.close()
|
||||
self.scratch.cleanup()
|
||||
|
||||
|
||||
def settle(server, ticks=600, timeout=600):
|
||||
@@ -200,6 +206,17 @@ def game_time(server, timeout=300):
|
||||
raise AssertionError(f'{server.log_path.name}: no game time in {timeout:.0f} s')
|
||||
|
||||
|
||||
def wait_ticks(server, count, timeout=300):
|
||||
"""Waits until the server's game clock has advanced `count` ticks: a server that stalls under load still gets
|
||||
as many ticks as an idle one, where a sleep gives it fewer. (Not while ticking is frozen.)"""
|
||||
deadline = time.time() + timeout
|
||||
until = game_time(server, timeout) + count
|
||||
while game_time(server, max(1.0, deadline - time.time())) < until:
|
||||
if time.time() > deadline:
|
||||
raise AssertionError(f'{server.log_path.name}: the game clock did not advance {count} ticks in {timeout} s')
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
def legacy_ping(port):
|
||||
"""The reply to a 1.6 client's 0xFE 0x01 0xFA MC|PingHost query (LegacyQueryHandler)."""
|
||||
host = 'localhost'
|
||||
@@ -327,7 +344,9 @@ def run_side(label, command, directory, client):
|
||||
joined.join()
|
||||
if failure:
|
||||
raise failure[0]
|
||||
time.sleep(1)
|
||||
# The client has gone; `list` must find no one, once the server has handled its leaving (a busy machine
|
||||
# took longer than a second).
|
||||
server.wait_for(rf'{PLAYER} left the game', timeout=60)
|
||||
server.console('list')
|
||||
server.console('say console says hi')
|
||||
server.wait_for(r'\[Server\] console says hi', timeout=30)
|
||||
@@ -359,7 +378,7 @@ def horizon_client_joins(vanilla_server, binary, world, build, reference):
|
||||
server.wait_for(r'Done \(')
|
||||
env = lab.game_env(HORIZON_NET_REPORT=report)
|
||||
with (build / 'horizon-client-run.log').open('w') as log:
|
||||
subprocess.run([str(c) for c in [binary, '--resources', lab.RESOURCES, '--render-distance', 2,
|
||||
run_game([str(c) for c in [binary, '--resources', lab.RESOURCES, '--render-distance', 2,
|
||||
'--server', f'127.0.0.1:{port}', '--name', PLAYER]],
|
||||
cwd=client_dir, env=env, stdout=log, stderr=subprocess.STDOUT, timeout=300, check=True)
|
||||
server.wait_for(r'left the game', timeout=30)
|
||||
|
||||
@@ -17,7 +17,9 @@ import random
|
||||
import subprocess
|
||||
try:
|
||||
from . import block_update_harness as h, lab, test_rust_parity as base
|
||||
from .integration_env import run_game
|
||||
except ImportError:
|
||||
from integration_env import run_game
|
||||
import block_update_harness as h
|
||||
import lab
|
||||
import test_rust_parity as base
|
||||
@@ -349,7 +351,8 @@ def voice(line):
|
||||
|
||||
|
||||
def run(command, **kwargs):
|
||||
done = subprocess.run(command, capture_output=True, text=True, **kwargs)
|
||||
runner = run_game if str(command[0]).endswith('/horizon-client') else subprocess.run
|
||||
done = runner(command, capture_output=True, text=True, **kwargs)
|
||||
if done.returncode:
|
||||
print((done.stdout + done.stderr)[-4000:])
|
||||
raise SystemExit(f'{command[0]} failed')
|
||||
|
||||
@@ -29,6 +29,15 @@ def corpus():
|
||||
if v[k] is not None:v[k]=[bits(n) for n in v[k]]
|
||||
return v
|
||||
def row(ops,player=False,order=(0,1,2)):return dict(ops=ops,player=player,order=order)
|
||||
# Dropped items: the 0.25-wide box is deflated by Entity before scanning.
|
||||
# Cover surface grazing, buoyancy depth, cell boundaries and repeated pushes.
|
||||
for x in [.5, 1.0, 15.99]:
|
||||
for y in [0, .1, .7, 8/9-.1, 8/9-.001, 8/9, 1]:
|
||||
for flow in [(0,0,0),(1,0,0),(-1,0,1),(0,-1,0)]:
|
||||
update=op(bounds=[x-.124,y+.001,.376,x+.124,y+.249,.624],
|
||||
base_y=y,eye=y+.2125,block=[int(x),int(y),0],
|
||||
default=cell(flow=flow))
|
||||
yield row([update,op(mode='apply'),update,op(mode='apply')])
|
||||
values=[-float('inf'),-1,-.0,0,.1,.39999998,.4,.40000004,8/9,1,2,float('inf'),float('nan')]
|
||||
for kind in range(5):
|
||||
for height in values:
|
||||
|
||||
@@ -164,6 +164,15 @@ def cases(layer, model=None):
|
||||
cases_out = [{**c, **DEFAULTS.get(name, {})} for c in cases_out]
|
||||
yield from cases_out
|
||||
yield from species_cases(layer, cases_out)
|
||||
# Exercise render-state extraction with a live walk clock, including the
|
||||
# first mounted frame. Existing setupAnim cases bypass anim::state.
|
||||
if name == 'skeleton':
|
||||
for passenger in [False, True]:
|
||||
for alive in [False, True]:
|
||||
for partial in [0.0, 0.5, 1.0]:
|
||||
yield {**cases_out[2], 'isPassenger': passenger,
|
||||
'@walkTicks': [0.5, 1.0, 0.75],
|
||||
'@alive': alive, '@partial': partial}
|
||||
part = model and scaled_part(model)
|
||||
if part:
|
||||
for index, scale in enumerate(PART_SCALES):
|
||||
@@ -276,6 +285,14 @@ def species_cases(layer, base_cases):
|
||||
for extra in SPECIES.get(name, []):
|
||||
for index in (2, 3, 6):
|
||||
yield {**base_cases[index], **extra}
|
||||
if name == 'bat':
|
||||
# Entity clocks, rather than injected render clocks: flight, rest, transitions and
|
||||
# unrelated flag bits. Exercise the in-frame tick and server-client visual update.
|
||||
for flags in ([0] * 4, [1] * 4, [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [2, 3, 2, 2]):
|
||||
for in_frame in (False, True):
|
||||
for partial in (0.0, 0.5):
|
||||
yield {**base_cases[0], 'ageInTicks': len(flags) + partial,
|
||||
'@batTicks': flags, '@batInFrame': in_frame}
|
||||
|
||||
|
||||
def compare_vertices(v, r, args, stats):
|
||||
@@ -379,6 +396,10 @@ def main():
|
||||
skipped.add(layer); continue
|
||||
checked += 1
|
||||
bad = []
|
||||
if 'walk' in v:
|
||||
for a, b in zip(v['walk'], r['walk']):
|
||||
if abs(a - b) > args.tolerance * (1.0 + abs(a)):
|
||||
bad.append(('@walk', f'{v["walk"]} != {r["walk"]}'))
|
||||
for path, expected in v['parts'].items():
|
||||
got = r['parts'].get(path)
|
||||
if got is None:
|
||||
|
||||
+31
-16
@@ -15,8 +15,9 @@ is off: nothing leaves the machine.
|
||||
|
||||
python3 tools/test_friends.py --client target/fast/horizon-client --relay target/fast/horizon-relay
|
||||
|
||||
`--server-thread` runs the host's world on its integrated server's own
|
||||
thread (the window is a client of it, as Open to LAN publishes it).
|
||||
The host runs on its integrated server thread by default (the window is a
|
||||
client of it). `--in-frame` compares the fallback; `--server-thread` is accepted
|
||||
for compatibility.
|
||||
|
||||
`--role host|guest` runs one side only (two machines, e.g. over a tailnet):
|
||||
the host prints the code, the guest takes it with `--code` (`--relay-url`
|
||||
@@ -36,8 +37,10 @@ import urllib.request
|
||||
|
||||
try:
|
||||
from . import lab
|
||||
from .integration_env import game_environment, require_server_reports
|
||||
except ImportError:
|
||||
import lab
|
||||
from integration_env import game_environment, require_server_reports
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -84,7 +87,7 @@ class Game:
|
||||
prefix = []
|
||||
extra = []
|
||||
# The host's world on its server thread (`--server-thread`), else in the window.
|
||||
server_thread = False
|
||||
server_thread = True
|
||||
|
||||
def __init__(self, client, resources, work, name, env):
|
||||
# Either way explicitly, whatever the game's default.
|
||||
@@ -96,7 +99,8 @@ class Game:
|
||||
self.process = subprocess.Popen(Game.prefix + [
|
||||
str(client), '--resources', str(resources), '--render-distance', '2', '--test-terrain',
|
||||
'--control-socket', str(self.endpoint), '--timeout-seconds', '600',
|
||||
] + Game.extra, cwd=self.home, env=lab.game_env(HORIZON_HOME=self.home, **env),
|
||||
] + Game.extra, cwd=self.home,
|
||||
env={**game_environment({**os.environ, **env}, self.home), 'HORIZON_HOME': str(self.home)},
|
||||
stdout=self.log, stderr=subprocess.STDOUT)
|
||||
wait_for(self.endpoint, 'screen', lambda v: v['screen'] == 'title', 120, f'{name} title')
|
||||
|
||||
@@ -149,10 +153,11 @@ def play_together(host, guest, name, round_index):
|
||||
before = guest_pos(host, name)
|
||||
guest('look 0 0')
|
||||
guest('key w down')
|
||||
time.sleep(1.5)
|
||||
guest('key w up')
|
||||
host.wait('lan status', lambda v: math.dist(before, next(g['position'] for g in v['guests'] if g['name'] == name)) > 1.0,
|
||||
20, 'guest movement on the host')
|
||||
try:
|
||||
host.wait('lan status', lambda v: math.dist(before, next(g['position'] for g in v['guests'] if g['name'] == name)) > 1.0,
|
||||
20, 'guest movement on the host')
|
||||
finally:
|
||||
guest('key w up')
|
||||
# The host moves; the guest sees the host's player there.
|
||||
hp = host('status')['player']['position']
|
||||
target = [hp[0] + 3.0, hp[1], hp[2] + 1.0]
|
||||
@@ -179,10 +184,11 @@ def play_together(host, guest, name, round_index):
|
||||
guest.wait('status', lambda v: v['target']['pos'] == block, 10, 'the guest aiming at the block')
|
||||
# Held for a few ticks, as a player clicks (creative breaks at once).
|
||||
guest('mouse left down')
|
||||
time.sleep(0.25)
|
||||
guest('mouse left up')
|
||||
host.wait(f'getblock {block[0]} {block[1]} {block[2]}', lambda v: v['block'] == 'minecraft:air', 20,
|
||||
'the guest breaking the block, on the host')
|
||||
try:
|
||||
host.wait(f'getblock {block[0]} {block[1]} {block[2]}', lambda v: v['block'] == 'minecraft:air', 20,
|
||||
'the guest breaking the block, on the host')
|
||||
finally:
|
||||
guest('mouse left up')
|
||||
guest.wait(f'getblock {block[0]} {block[1]} {block[2]}', lambda v: v['block'] == 'minecraft:air', 20,
|
||||
'the broken block on the guest')
|
||||
|
||||
@@ -250,7 +256,7 @@ def full(args, work):
|
||||
join(guest, code, 'Guest')
|
||||
play_together(host, guest, 'Guest', 1)
|
||||
assert host('friends status')['direct'] == 1, host('friends status')
|
||||
print('code alone: chat, movement and blocks both ways, no server involved')
|
||||
print('code alone: chat, movement and blocks both ways, no relay involved')
|
||||
leave(host, guest, 'Guest')
|
||||
host('friends stop')
|
||||
assert host('friends status')['code'] is None
|
||||
@@ -316,8 +322,8 @@ def one_side(args, work):
|
||||
if args.role == 'host':
|
||||
code = host_world(game)
|
||||
print(f'CODE {code}', flush=True)
|
||||
game.wait('lan status', lambda v: v['guests'], args.wait, 'a guest')
|
||||
game.wait('lan status', lambda v: not v['guests'], args.wait, 'the guest leaving')
|
||||
game.wait('lan status', lambda v: any(g['name'] == 'Remote' for g in v['guests']), args.wait, 'a guest')
|
||||
game.wait('lan status', lambda v: all(g['name'] != 'Remote' for g in v['guests']), args.wait, 'the guest leaving')
|
||||
print(f'host: {game("friends status")}')
|
||||
else:
|
||||
join(game, args.code, 'Remote')
|
||||
@@ -347,16 +353,25 @@ def main():
|
||||
parser.add_argument('--hold', type=float, default=0, help='guest: stay this many seconds before leaving')
|
||||
parser.add_argument('--baseline', action='store_true', help='first run the same checks over plain LAN')
|
||||
parser.add_argument('--offscreen', action='store_true', help='run the games without a window')
|
||||
parser.add_argument('--server-thread', action='store_true', help="the host's world on its server thread")
|
||||
mode = parser.add_mutually_exclusive_group()
|
||||
mode.add_argument('--server-thread', dest='server_thread', action='store_true', default=True,
|
||||
help='host on its server thread (default; retained for existing callers)')
|
||||
mode.add_argument('--in-frame', dest='server_thread', action='store_false',
|
||||
help='host the world in the window, for comparison')
|
||||
parser.add_argument('--xvfb', action='store_true', help='run the games under xvfb-run (headless Linux)')
|
||||
args = parser.parse_args()
|
||||
Game.prefix = ['xvfb-run', '-a'] if args.xvfb else []
|
||||
Game.extra = ['--offscreen'] if args.offscreen else []
|
||||
Game.server_thread = args.server_thread
|
||||
args.client, args.resources = args.client.resolve(), args.resources.resolve()
|
||||
try:
|
||||
require_server_reports(args.resources)
|
||||
except ValueError as error:
|
||||
parser.error(str(error))
|
||||
# Short: Unix socket paths are limited to about 100 bytes.
|
||||
with tempfile.TemporaryDirectory(prefix='hzf-', dir='/tmp') as directory:
|
||||
work = Path(directory)
|
||||
print(f'Friends host mode: {"server-thread" if Game.server_thread else "in-frame"}')
|
||||
if args.role:
|
||||
return one_side(args, work)
|
||||
assert args.relay, 'give --relay (the relay binary, run locally for the relay half)'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Real clients over LAN, direct invitations and a local relay, with a server-thread host.
|
||||
|
||||
Registered with parity.py so changes to the drivers and the game binary select
|
||||
this integration coverage in CI as well as the deterministic library probes.
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import lab
|
||||
import test_friends
|
||||
from integration_env import suite_lock
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
subprocess.run(['cargo', 'build', '--locked', '--profile', 'fast', '-p', 'horizon-client',
|
||||
'-p', 'horizon-relay', '--bin', 'horizon-client', '--bin', 'horizon-ctl',
|
||||
'--bin', 'horizon-relay'], cwd=lab.ROOT, check=True)
|
||||
metadata = json.loads(subprocess.check_output(
|
||||
['cargo', 'metadata', '--format-version', '1', '--no-deps'], cwd=lab.ROOT, text=True))
|
||||
bins = Path(metadata['target_directory']) / 'fast'
|
||||
sys.argv = [sys.argv[0], '--client', str(bins / 'horizon-client'),
|
||||
'--relay', str(bins / 'horizon-relay'), '--baseline',
|
||||
*(['--offscreen'] if sys.platform == 'darwin' else [])]
|
||||
with suite_lock():
|
||||
# The wrapper only selects binaries; test_friends isolates each game
|
||||
# through integration_env and lab.game_env.
|
||||
test_friends.main()
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Register the real-client LAN suite with parity.py's traced harness selection.
|
||||
|
||||
The assertions live in lan_e2e; this is integration coverage, alongside the
|
||||
fast vanilla differential probes. The host uses the normal server thread.
|
||||
Linux runners need a display (for example xvfb-run -a).
|
||||
"""
|
||||
import lan_e2e
|
||||
from integration_env import suite_lock
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
with suite_lock():
|
||||
lan_e2e.main()
|
||||
@@ -23,15 +23,14 @@ import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
try:
|
||||
from . import lab, test_rust_parity as base
|
||||
from .test_dedicated_server_parity import Server, free_port
|
||||
from .test_dedicated_server_parity import Server, free_port, wait_ticks
|
||||
except ImportError:
|
||||
import lab
|
||||
import test_rust_parity as base
|
||||
from test_dedicated_server_parity import Server, free_port
|
||||
from test_dedicated_server_parity import Server, free_port, wait_ticks
|
||||
|
||||
NAME = 'locator-bar-parity'
|
||||
PROPERTIES = {
|
||||
@@ -82,7 +81,7 @@ SCRIPT = [
|
||||
('creative', [], ['cmd Bob gamemode creative', 'cmd Bob tp @s 6.5 100 0.5']),
|
||||
('bob-leaves', [], ['quit Bob']),
|
||||
]
|
||||
STEP_SECONDS = 2.0
|
||||
STEP_TICKS = 40
|
||||
# Vanilla's server moves a player who just joined on their own first ticks (a tiny step and back), which tracks
|
||||
# them where they spawned; Horizon does not simulate its guests. These steps compare what the bar shows at
|
||||
# their end (Bob has moved by then) rather than every packet.
|
||||
@@ -147,6 +146,47 @@ def server_dir(directory, world=None):
|
||||
return port
|
||||
|
||||
|
||||
class Client:
|
||||
"""A LocatorBarClient process driven by a script on its stdin. A step ends by the server's clock, not the wall's:
|
||||
every script line has run (`sync`), the server has ticked `ticks` more times, and each client holds what the
|
||||
server sent until then (a last `sync`). A server that stalls under load still gets all its ticks in the step,
|
||||
where a fixed sleep filed a stalled server's packets under the next step."""
|
||||
|
||||
def __init__(self, command, port, out, log):
|
||||
self.log = log
|
||||
self.process = subprocess.Popen([*map(str, command), '127.0.0.1', str(port), str(out)], cwd=lab.ROOT,
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
text=True)
|
||||
|
||||
def tell(self, line):
|
||||
self.process.stdin.write(line + '\n')
|
||||
self.process.stdin.flush()
|
||||
|
||||
def sync(self, names):
|
||||
"""Every line told so far has run for these joined players, and they have received what the server sent
|
||||
before."""
|
||||
for name in names:
|
||||
self.tell(f'sync {name}')
|
||||
for name in names:
|
||||
while (line := self.process.stdout.readline()) != f'synced {name}\n':
|
||||
if not line:
|
||||
raise AssertionError(f'the client exited (see {self.log.name})')
|
||||
self.log.write(line)
|
||||
|
||||
def wait(self, server, names, ticks):
|
||||
self.sync(names)
|
||||
wait_ticks(server, ticks)
|
||||
self.sync(names)
|
||||
|
||||
def end(self):
|
||||
self.tell('end')
|
||||
self.log.write(self.process.communicate(timeout=60)[0])
|
||||
|
||||
def kill(self):
|
||||
if self.process.poll() is None:
|
||||
self.process.kill()
|
||||
|
||||
|
||||
def generate_world(server_command, build):
|
||||
"""The flat world both servers load, made once by vanilla: players appear at its spawn itself
|
||||
(respawn_radius 0), on the ground at 0 -60 0, and the chunks around it are saved."""
|
||||
@@ -176,28 +216,26 @@ def run_side(label, server_command, client_command, build, world):
|
||||
try:
|
||||
server.wait_for(r'Done \(')
|
||||
with (build / f'{label}-client.log').open('w') as log:
|
||||
client = subprocess.Popen([*map(str, client_command), '127.0.0.1', str(port), str(out)],
|
||||
cwd=lab.ROOT, stdin=subprocess.PIPE, stdout=log, stderr=subprocess.STDOUT,
|
||||
text=True)
|
||||
client = Client(client_command, port, out, log)
|
||||
joined = []
|
||||
try:
|
||||
for step, console, actions in SCRIPT:
|
||||
client.stdin.write(f'step {step}\n')
|
||||
client.stdin.flush()
|
||||
client.tell(f'step {step}')
|
||||
for command in console:
|
||||
server.console(command)
|
||||
for action in actions:
|
||||
client.stdin.write(action + '\n')
|
||||
client.stdin.flush()
|
||||
if action.startswith('join'):
|
||||
client.tell(action)
|
||||
verb, *rest = action.split()
|
||||
if verb == 'join':
|
||||
# Joining takes the world's first chunks: wait for the server to place the player.
|
||||
server.wait_for(rf'{action.split()[1]} joined the game', timeout=120)
|
||||
time.sleep(STEP_SECONDS)
|
||||
client.stdin.write('end\n')
|
||||
client.stdin.flush()
|
||||
client.wait(timeout=60)
|
||||
server.wait_for(rf'{rest[0]} joined the game', timeout=120)
|
||||
joined.append(rest[0])
|
||||
elif verb == 'quit':
|
||||
joined.remove(rest[0])
|
||||
client.wait(server, joined, STEP_TICKS)
|
||||
client.end()
|
||||
finally:
|
||||
if client.poll() is None:
|
||||
client.kill()
|
||||
client.kill()
|
||||
finally:
|
||||
server.stop()
|
||||
if not out.exists():
|
||||
@@ -234,10 +272,11 @@ def sides(name):
|
||||
|
||||
def one_player(name, script, shown, check, scope, step_seconds=4.0):
|
||||
"""A harness of one player, Alice: on each server she joins, then runs `script`, a list of (step, client
|
||||
actions) `step_seconds` apart. The lines `shown(transcript)` keeps must match vanilla's exactly, and
|
||||
actions) that each last `step_seconds` of the server's time (20 ticks a second). The lines `shown(transcript)` keeps must match vanilla's exactly, and
|
||||
`check(vanilla's shown lines, vanilla's transcript)` returns why vanilla's run is no proof (the script did
|
||||
not run), or None."""
|
||||
lock, build, vanilla_server, horizon_server, client = sides(name)
|
||||
ticks = round(step_seconds * 20)
|
||||
|
||||
def run(label, server_command, world):
|
||||
directory = build / label
|
||||
@@ -248,27 +287,20 @@ def one_player(name, script, shown, check, scope, step_seconds=4.0):
|
||||
try:
|
||||
server.wait_for(r'Done \(')
|
||||
with (build / f'{label}-client.log').open('w') as log:
|
||||
process = subprocess.Popen([*map(str, client), '127.0.0.1', str(port), str(out)], cwd=lab.ROOT,
|
||||
stdin=subprocess.PIPE, stdout=log, stderr=subprocess.STDOUT, text=True)
|
||||
|
||||
def tell(line):
|
||||
process.stdin.write(line + '\n')
|
||||
process.stdin.flush()
|
||||
session = Client(client, port, out, log)
|
||||
try:
|
||||
for line in ['players on', 'state on', 'step joins', 'join Alice']:
|
||||
tell(line)
|
||||
session.tell(line)
|
||||
server.wait_for(r'Alice joined the game', timeout=120)
|
||||
time.sleep(step_seconds)
|
||||
session.wait(server, ['Alice'], ticks)
|
||||
for step, actions in script:
|
||||
tell(f'step {step}')
|
||||
session.tell(f'step {step}')
|
||||
for action in actions:
|
||||
tell(action)
|
||||
time.sleep(step_seconds)
|
||||
tell('end')
|
||||
process.wait(timeout=60)
|
||||
session.tell(action)
|
||||
session.wait(server, ['Alice'], ticks)
|
||||
session.end()
|
||||
finally:
|
||||
if process.poll() is None:
|
||||
process.kill()
|
||||
session.kill()
|
||||
finally:
|
||||
server.stop()
|
||||
if not out.exists():
|
||||
|
||||
@@ -311,6 +311,23 @@ def scenarios():
|
||||
add('villager_golem_panic', 100, ['fill -2 -60 -3 4 -60 4 minecraft:oak_fence', 'fill -1 -60 -2 3 -60 3 minecraft:air',
|
||||
'player 14.5 -60 0.5'] + golem_callers[:3]
|
||||
+ ['mob minecraft:zombie 6.5 -60 0.5 90 86 persistent noai'], 'time=18000')
|
||||
# Mob.checkDespawn removes disallowed types before persistence/NoAI checks.
|
||||
# Keep the non-Peaceful controls and the allowed hostile/neutral exceptions.
|
||||
for difficulty in range(4):
|
||||
for flags in ('', 'persistent', 'named', 'noai', 'persistent noai'):
|
||||
suffix = flags.replace(' ', '_') or 'ordinary'
|
||||
add(f'peaceful_zombie_{difficulty}_{suffix}', 1, [
|
||||
'player 6.5 -60 0.5',
|
||||
f'mob minecraft:zombie 0.5 -60 0.5 0 1 {flags}',
|
||||
], f'difficulty={difficulty} time=18000')
|
||||
# Not slime, piglin or bee: a slime made without finalizeSpawn keeps 20 health, the probe
|
||||
# doesn't model a piglin's brain, and a NoAI bee's flower cooldown differs (none of it Peaceful).
|
||||
for species in ('skeleton', 'creeper', 'warden', 'wither', 'shulker', 'wolf', 'iron_golem', 'cow'):
|
||||
add(f'peaceful_type_{species}', 1, [
|
||||
'player 6.5 -60 0.5',
|
||||
f'mob minecraft:{species} 0.5 -60 0.5 0 1 persistent noai',
|
||||
], 'difficulty=0 time=18000')
|
||||
|
||||
return s
|
||||
|
||||
|
||||
@@ -502,7 +519,9 @@ def main():
|
||||
# The oracle's server world: cleared before each run, never left in /tmp.
|
||||
world = build / 'world'
|
||||
shutil.rmtree(world, ignore_errors=True)
|
||||
oracle_harness.run_logged(['java', '-Xmx3g', '-Djava.awt.headless=true', '-cp', str(classes) + os.pathsep + dependencies,
|
||||
# Each scenario forces 9x9 chunks 512 blocks past the last one, so a run generates ~80 chunks per scenario;
|
||||
# 3g ran out of heap in PoiManager.tick on a busy runner (#2160's CI, 143 scenarios).
|
||||
oracle_harness.run_logged(['java', '-Xmx4g', '-Djava.awt.headless=true', '-cp', str(classes) + os.pathsep + dependencies,
|
||||
'dev.horizonlab.parity.VanillaMobAiOracle', inputs, build / 'vanilla.txt', world],
|
||||
build, 'vanilla', timeout=3600)
|
||||
if not args.java_only:
|
||||
|
||||
@@ -50,11 +50,13 @@ import urllib.parse
|
||||
try:
|
||||
from . import lab, oracle_harness as oh, test_rust_parity as base
|
||||
from .test_dedicated_server_parity import Server, free_port
|
||||
from .integration_env import run_game
|
||||
except ImportError:
|
||||
import lab
|
||||
import oracle_harness as oh
|
||||
import test_rust_parity as base
|
||||
from test_dedicated_server_parity import Server, free_port
|
||||
from integration_env import run_game
|
||||
|
||||
NAME = 'online-mode-parity'
|
||||
PLAYER = 'Tester'
|
||||
@@ -185,7 +187,7 @@ def run_client(binary, build, port, label, token, discovery):
|
||||
if token:
|
||||
command += ['--session-file', session_file(directory, token)]
|
||||
with (build / f'client-{label}.log').open('w') as log:
|
||||
subprocess.run([str(c) for c in command], cwd=directory, env=env, stdout=log, stderr=subprocess.STDOUT,
|
||||
run_game([str(c) for c in command], cwd=directory, env=env, stdout=log, stderr=subprocess.STDOUT,
|
||||
timeout=300, check=True)
|
||||
got = json.loads(report.read_text())
|
||||
got['session file left'] = (directory / 'session.json').exists()
|
||||
|
||||
@@ -147,7 +147,7 @@ def main():
|
||||
run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-nowarn', '-cp', dependencies, '-d', classes,
|
||||
*(PARITY / f'{n}.java' for n in ('ParityData', 'ParityFont', 'VanillaPackScreenOracle'))], 'compile-java')
|
||||
run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaPackScreenOracle',
|
||||
inputs, build / 'vanilla.jsonl'], 'vanilla')
|
||||
inputs, build / 'vanilla.jsonl', lab.RESOURCES / 'assets'], 'vanilla')
|
||||
lib.cargo_example('horizon-client', 'pack_screen_fixture', lib.RESOURCES, inputs, build / 'rust.jsonl')
|
||||
vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()]
|
||||
rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()]
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
"""FireworkRocketEntity event 17 renders the configured burst before tracked removal.
|
||||
|
||||
Exercise both hosting paths and subsequent trail/fade frames through real clients.
|
||||
"""
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
import lab
|
||||
import lan_e2e as lan
|
||||
|
||||
|
||||
def main():
|
||||
subprocess.run(['cargo', 'build', '--locked', '--profile', 'fast', '-p', 'horizon-client',
|
||||
'--bin', 'horizon-client', '--bin', 'horizon-ctl'], cwd=lab.ROOT, check=True)
|
||||
metadata = json.loads(subprocess.check_output(
|
||||
['cargo', 'metadata', '--format-version', '1', '--no-deps'], cwd=lab.ROOT, text=True))
|
||||
ctl = lab.ROOT / metadata['target_directory'] / 'fast' / 'horizon-ctl'
|
||||
# CI supplies the display; each game still gets fresh scratch homes.
|
||||
lan.game_env = lambda _screen, home: lab.game_env(
|
||||
HORIZON_HOME=home, HORIZON_TELEMETRY_URL='off')
|
||||
reports = {}
|
||||
for threaded in (True, False):
|
||||
lan.SERVER_THREAD = threaded
|
||||
mode = 'server-thread' if threaded else 'in-frame'
|
||||
out = lab.LOCAL / 'remote-fireworks-parity' / mode
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
reports[mode] = lan.run(ctl, out, lab.RESOURCES.resolve(), ['fireworks'])
|
||||
lab.write_json(lab.LOCAL / 'remote-fireworks-parity' / 'report.json', reports)
|
||||
assert all(r['pass'] for mode in reports.values() for r in mode.values()), reports
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -80,6 +80,8 @@ IGNORED = {
|
||||
# chunk generation first), so counters and positions of live things move on.
|
||||
r'^chunk\.block_entities\.\(2, -60, 5\)\.(cooking_time_spent|lit_time_remaining|Items\[\]\.count)$':
|
||||
'the lit furnace keeps smelting',
|
||||
r'^chunk\.block_entities\.\(14, -60, 5\)\.CookingTimes$':
|
||||
'the lit campfire keeps cooking',
|
||||
r'^chunk\.block_entities\..*\.(ticks_since_song_started|Age|BrewTime|warning_level|ticks_in_hive|last_vibration_frequency|listener\..*|RecipesUsed\..*|'
|
||||
r'server_data\.state_updating_resumes_at)$':
|
||||
'block entity timers advance',
|
||||
|
||||
@@ -16,17 +16,16 @@ import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
try:
|
||||
from . import lab, test_rust_parity as base
|
||||
from .test_dedicated_server_parity import Server
|
||||
from .test_locator_bar_parity import generate_world, server_dir
|
||||
from .test_locator_bar_parity import Client, generate_world, server_dir
|
||||
except ImportError:
|
||||
import lab
|
||||
import test_rust_parity as base
|
||||
from test_dedicated_server_parity import Server
|
||||
from test_locator_bar_parity import generate_world, server_dir
|
||||
from test_locator_bar_parity import Client, generate_world, server_dir
|
||||
|
||||
NAME = 'server-dimension-players-parity'
|
||||
NETHER, END, OVERWORLD = 'minecraft:the_nether', 'minecraft:the_end', 'minecraft:overworld'
|
||||
@@ -41,8 +40,14 @@ SCRIPT = [
|
||||
# Through an End portal (Entity.handlePortal), and back by command.
|
||||
('bob-portal', ['cmd Bob setblock 2 101 3 minecraft:end_portal', 'cmd Bob tp @s 2.5 101 3.5']),
|
||||
('bob-portal-back', [f'cmd Bob execute in {OVERWORLD} run tp @s 2.5 100 0.5']),
|
||||
# Sent far into the Nether, then teleported within it before the far chunks load: a portal there
|
||||
# still takes him (the abandoned arrival does not hold him).
|
||||
('bob-retarget', [f'cmd Bob execute in {NETHER} run tp @s 8192.5 100 0.5', 'cmd Bob tp @s 0.5 100 0.5']),
|
||||
('bob-retarget-portal', ['cmd Bob setblock 0 101 3 minecraft:end_portal', 'cmd Bob tp @s 0.5 101 3.5']),
|
||||
('bob-retarget-back', [f'cmd Bob execute in {OVERWORLD} run tp @s 2.5 100 0.5']),
|
||||
]
|
||||
STEP_SECONDS = 5.0
|
||||
PLAYERS = ('Alice', 'Bob')
|
||||
STEP_TICKS = 100
|
||||
|
||||
|
||||
def run_side(label, server_command, client_command, build, world):
|
||||
@@ -54,38 +59,30 @@ def run_side(label, server_command, client_command, build, world):
|
||||
try:
|
||||
server.wait_for(r'Done \(')
|
||||
with (build / f'{label}-client.log').open('w') as log:
|
||||
client = subprocess.Popen([*map(str, client_command), '127.0.0.1', str(port), str(out)],
|
||||
cwd=lab.ROOT, stdin=subprocess.PIPE, stdout=log, stderr=subprocess.STDOUT,
|
||||
text=True)
|
||||
|
||||
def tell(line):
|
||||
client.stdin.write(line + '\n')
|
||||
client.stdin.flush()
|
||||
client = Client(client_command, port, out, log)
|
||||
try:
|
||||
tell('players on')
|
||||
tell('step joins')
|
||||
for name, x in (('Alice', 0.5), ('Bob', 2.5)):
|
||||
tell(f'join {name}')
|
||||
client.tell('players on')
|
||||
client.tell('step joins')
|
||||
for name, x in zip(PLAYERS, (0.5, 2.5)):
|
||||
client.tell(f'join {name}')
|
||||
server.wait_for(rf'{name} joined the game', timeout=120)
|
||||
tell(f'fly {name} on')
|
||||
tell(f'cmd {name} tp @s {x} 100 0.5')
|
||||
time.sleep(STEP_SECONDS)
|
||||
client.tell(f'fly {name} on')
|
||||
client.tell(f'cmd {name} tp @s {x} 100 0.5')
|
||||
client.wait(server, PLAYERS, STEP_TICKS)
|
||||
for step, actions in SCRIPT:
|
||||
tell(f'step {step}')
|
||||
client.tell(f'step {step}')
|
||||
for action in actions:
|
||||
tell(action)
|
||||
client.tell(action)
|
||||
# Standing still, a client still sends its position every 20 ticks
|
||||
# (LocalPlayer.sendPosition): the server then tracks to it what it has sent the
|
||||
# chunks of since (ChunkMap.move).
|
||||
time.sleep(STEP_SECONDS / 2)
|
||||
tell('still Alice')
|
||||
tell('still Bob')
|
||||
time.sleep(STEP_SECONDS / 2)
|
||||
tell('end')
|
||||
client.wait(timeout=60)
|
||||
client.wait(server, PLAYERS, STEP_TICKS // 2)
|
||||
for name in PLAYERS:
|
||||
client.tell(f'still {name}')
|
||||
client.wait(server, PLAYERS, STEP_TICKS // 2)
|
||||
client.end()
|
||||
finally:
|
||||
if client.poll() is None:
|
||||
client.kill()
|
||||
client.kill()
|
||||
finally:
|
||||
server.stop()
|
||||
if not out.exists():
|
||||
|
||||
@@ -18,6 +18,11 @@ players made of vanilla's protocol code, joins them both and runs one script on
|
||||
travelled a tick (the mob's hit, then ServerPlayer's travel, then ServerEntity.sendChanges). It is night, so
|
||||
that no zombie burns (a burning mob is in its hurt cooldown).
|
||||
|
||||
The script waits on the server, not on the wall: `ticks N` is N ticks of its game clock (with a `sync` round trip
|
||||
before and after, so each client holds what the server sent), `tickstep` is one `/tick step` that has run, `frozen`
|
||||
a frozen game that has stopped, and `hit` a hit that has landed (a frozen server still ticks its players, so a hit
|
||||
lands in Alice's next tick). A server that stalls under load gets the same ticks as an idle one.
|
||||
|
||||
Each case is compared on its own. KNOWN lists the cases Horizon still gets wrong and why; one that matches
|
||||
again is reported, and should leave the list.
|
||||
"""
|
||||
@@ -32,15 +37,16 @@ import time
|
||||
|
||||
try:
|
||||
from . import lab, test_rust_parity as base
|
||||
from .test_dedicated_server_parity import Server, free_port
|
||||
from .test_dedicated_server_parity import Server, free_port, game_time, wait_ticks
|
||||
from .test_locator_bar_parity import generate_world, ops_json
|
||||
except ImportError:
|
||||
import lab
|
||||
import test_rust_parity as base
|
||||
from test_dedicated_server_parity import Server, free_port
|
||||
from test_dedicated_server_parity import Server, free_port, game_time, wait_ticks
|
||||
from test_locator_bar_parity import generate_world, ops_json
|
||||
|
||||
NAME = 'server-knockback-parity'
|
||||
PLAYERS = ('Alice', 'Bob')
|
||||
PROPERTIES = {
|
||||
'online-mode': 'false',
|
||||
'white-list': 'false',
|
||||
@@ -82,18 +88,17 @@ def mob_case(kind, weapon=SWORD, sprint=False, crit=False, air=False):
|
||||
f'cmd Alice effect give {mob} minecraft:slowness 100000 127 true']
|
||||
lines = ['cmd Alice kill @e[type=!player]', 'cmd Alice gamemode creative', 'cmd Bob gamemode creative',
|
||||
f'cmd Alice item replace entity @s weapon.mainhand with {weapon}', 'cmd Alice tp Bob 2.5 -60 12.5',
|
||||
*stand('Alice', A, -90), 'sleep 1.2']
|
||||
*stand('Alice', A, -90), 'ticks 24']
|
||||
# In the air: frozen before its first tick, so it has not landed.
|
||||
lines += ['cmd Alice tick freeze', *summon] if air else [*summon, 'sleep 1.5', 'cmd Alice tick freeze']
|
||||
lines += ['sleep 0.3', f'cmd Alice data get entity {mob} Pos']
|
||||
lines += ['cmd Alice tick freeze', 'frozen', *summon] if air else [*summon, 'ticks 30', 'cmd Alice tick freeze', 'frozen']
|
||||
lines += [f'cmd Alice data get entity {mob} Pos']
|
||||
if sprint:
|
||||
lines.append('sprint Alice on')
|
||||
if crit:
|
||||
lines += falling(0.8)
|
||||
lines += ['sleep 0.2', f'attack Alice {kind}', 'sleep 0.2', f'cmd Alice data get entity {mob} Motion']
|
||||
lines += [f'hit {kind}', f'cmd Alice data get entity {mob} Motion']
|
||||
for _ in range(20):
|
||||
lines += ['cmd Alice tick step 1', 'sleep 0.25', f'cmd Alice data get entity {mob} Pos',
|
||||
f'cmd Alice data get entity {mob} Motion']
|
||||
lines += ['tickstep', f'cmd Alice data get entity {mob} Pos', f'cmd Alice data get entity {mob} Motion']
|
||||
lines += ['cmd Alice tick unfreeze', 'cmd Alice kill @e[type=!player]']
|
||||
if sprint:
|
||||
lines.append('sprint Alice off')
|
||||
@@ -114,7 +119,7 @@ def pvp_case(weapon=SWORD, sprint=False, crit=False, shield=False, armour=False,
|
||||
if shield:
|
||||
# A shield blocks from five ticks after it is raised.
|
||||
lines += ['cmd Bob item replace entity @s weapon.mainhand with minecraft:shield', 'use Bob']
|
||||
lines += ['sleep 1.5', *stand('Bob', V, 90, ticks=1)]
|
||||
lines += ['ticks 30', *stand('Bob', V, 90, ticks=1)]
|
||||
if sprint:
|
||||
lines.append('sprint Alice on')
|
||||
if crit:
|
||||
@@ -124,10 +129,12 @@ def pvp_case(weapon=SWORD, sprint=False, crit=False, shield=False, armour=False,
|
||||
if cooldown:
|
||||
# A swing at the air first: the hit is weak, and the stronger one four ticks later lands inside Bob's hurt
|
||||
# cooldown (LivingEntity.hurtServer: it hurts by the difference, with no knockback and no motion packet).
|
||||
lines += ['sleep 0.2', 'punch Alice', 'attack Alice Bob']
|
||||
lines += ['sleep 0.2', 'attack Alice Bob', 'sleep 0.3']
|
||||
lines += ['ticks 4', 'punch Alice', 'attack Alice Bob']
|
||||
# The gap between those two hits is an upper bound on the server's ticks, so a stalled server (which gets
|
||||
# fewer in a wall's 0.2 s) still lands the second inside the cooldown; the rest is to have the server's ticks.
|
||||
lines += ['sleep 0.2' if cooldown else 'ticks 4', 'attack Alice Bob', 'ticks 6']
|
||||
if twice:
|
||||
lines += [*stand('Bob', V, 90, ticks=20), 'sleep 1.5', 'attack Alice Bob', 'sleep 0.3']
|
||||
lines += [*stand('Bob', V, 90, ticks=20), 'ticks 30', 'attack Alice Bob', 'ticks 6']
|
||||
if sprint:
|
||||
lines.append('sprint Alice off')
|
||||
lines += stand('Alice', A, -90)
|
||||
@@ -144,7 +151,7 @@ def mob_hits_case(kind):
|
||||
hit = ['mark Bob', f'cmd Alice summon minecraft:{kind} {V[0] + 1} {V[1]} {V[2]} {{Rotation:[90f,0f]}}',
|
||||
f'cmd Alice effect give {mob} minecraft:slowness 100000 127 true', 'await Bob', f'cmd Alice kill {mob}']
|
||||
return ['cmd Bob clear @s', 'cmd Bob effect give @s minecraft:resistance 1000 4 true', 'cmd Alice gamemode creative',
|
||||
*stand('Bob', V, 90), *hit, 'sleep 2', *stand('Bob', V, 90), *hit, 'sleep 1',
|
||||
*stand('Bob', V, 90), *hit, 'ticks 40', *stand('Bob', V, 90), *hit, 'ticks 20',
|
||||
'cmd Alice kill @e[type=!player]', 'cmd Alice gamemode survival']
|
||||
|
||||
|
||||
@@ -173,7 +180,20 @@ CASES = {
|
||||
}
|
||||
SETUP = ['cmd Alice gamerule spawn_mobs false', 'cmd Alice gamerule spawn_monsters false',
|
||||
'cmd Alice kill @e[type=!player]', 'cmd Alice gamerule advance_time false', 'cmd Alice time set midnight',
|
||||
f'cmd Alice tp Alice {A[0]} {A[1]} {A[2]} -90 0', f'cmd Alice tp Bob {V[0]} {V[1]} {V[2]} 90 0', 'sleep 2']
|
||||
f'cmd Alice tp Alice {A[0]} {A[1]} {A[2]} -90 0', f'cmd Alice tp Bob {V[0]} {V[1]} {V[2]} 90 0', 'ticks 40']
|
||||
|
||||
|
||||
def server_data(server, selector, path, timeout=120):
|
||||
"""An entity's data, asked from the console (its reply stays in the server's log, out of the clients')."""
|
||||
deadline = time.time() + timeout
|
||||
start = len(server.lines)
|
||||
server.console(f'data get entity {selector} {path}')
|
||||
while time.time() < deadline:
|
||||
for line in server.lines[start:]:
|
||||
if 'has the following entity data' in line:
|
||||
return line.split('data: ', 1)[-1]
|
||||
time.sleep(0.02)
|
||||
raise AssertionError(f'{server.log_path.name}: no entity data in {timeout} s')
|
||||
|
||||
|
||||
def server_dir(directory, world):
|
||||
@@ -201,29 +221,72 @@ def run_side(label, server_command, client_command, build, world):
|
||||
server.wait_for(r'Done \(')
|
||||
with (build / f'{label}-client.log').open('w') as log:
|
||||
client = subprocess.Popen([*map(str, client_command), '127.0.0.1', str(port), str(out)],
|
||||
cwd=lab.ROOT, stdin=subprocess.PIPE, stdout=log, stderr=subprocess.STDOUT,
|
||||
text=True)
|
||||
cwd=lab.ROOT, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT, text=True)
|
||||
|
||||
def sync():
|
||||
"""Every script line sent so far has run, and each client holds what its server sent before."""
|
||||
for name in PLAYERS:
|
||||
client.stdin.write(f'sync {name}\n')
|
||||
client.stdin.flush()
|
||||
for name in PLAYERS:
|
||||
while (reply := client.stdout.readline()) != f'synced {name}\n':
|
||||
if not reply:
|
||||
raise AssertionError(f'{label}: the client exited (see {build}/{label}-client.log)')
|
||||
log.write(reply)
|
||||
|
||||
def send(line):
|
||||
if line.startswith('sleep '):
|
||||
"""A script line for the client, or one of ours: the waits are on the server's game clock, not the
|
||||
wall's, so a server that stalls under load still gets the ticks each case needs."""
|
||||
word = line.split()[0]
|
||||
if word == 'sleep':
|
||||
time.sleep(float(line.split()[1]))
|
||||
elif word == 'ticks':
|
||||
sync()
|
||||
wait_ticks(server, int(line.split()[1]))
|
||||
sync()
|
||||
elif word == 'frozen':
|
||||
# The tick in flight when ticking was frozen has finished: the clock reads the same twice.
|
||||
sync()
|
||||
while game_time(server) != game_time(server):
|
||||
pass
|
||||
elif word == 'hit':
|
||||
# Alice hits the mob. A frozen server still ticks its players, and the hit lands in Alice's
|
||||
# next tick, not when the packet arrives: the mob's motion says when it has.
|
||||
sync()
|
||||
mob = f'@e[type=minecraft:{line.split()[1]},limit=1]'
|
||||
before = server_data(server, mob, 'Motion')
|
||||
client.stdin.write(f'attack Alice {line.split()[1]}\n')
|
||||
client.stdin.flush()
|
||||
while server_data(server, mob, 'Motion') == before:
|
||||
time.sleep(0.05)
|
||||
sync()
|
||||
elif word == 'tickstep':
|
||||
# `/tick step 1` answers at once and the tick runs after: the clock says when it has.
|
||||
sync()
|
||||
before = game_time(server)
|
||||
client.stdin.write('cmd Alice tick step 1\n')
|
||||
client.stdin.flush()
|
||||
while game_time(server) == before:
|
||||
time.sleep(0.05)
|
||||
sync()
|
||||
else:
|
||||
client.stdin.write(line + '\n')
|
||||
client.stdin.flush()
|
||||
try:
|
||||
for name in ('Alice', 'Bob'):
|
||||
for name in PLAYERS:
|
||||
send(f'join {name}')
|
||||
server.wait_for(rf'{name} joined the game', timeout=120)
|
||||
time.sleep(2)
|
||||
wait_ticks(server, 40)
|
||||
for line in SETUP:
|
||||
send(line)
|
||||
for case, lines in CASES.items():
|
||||
send(f'step {case}')
|
||||
for line in lines:
|
||||
send(line)
|
||||
time.sleep(0.5)
|
||||
send('ticks 10')
|
||||
send('end')
|
||||
client.wait(timeout=60)
|
||||
log.write(client.communicate(timeout=60)[0])
|
||||
finally:
|
||||
if client.poll() is None:
|
||||
client.kill()
|
||||
|
||||
@@ -19,17 +19,16 @@ import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
try:
|
||||
from . import lab, test_rust_parity as base
|
||||
from .test_dedicated_server_parity import Server
|
||||
from .test_locator_bar_parity import generate_world, server_dir
|
||||
from .test_dedicated_server_parity import Server, game_time
|
||||
from .test_locator_bar_parity import Client, generate_world, server_dir
|
||||
except ImportError:
|
||||
import lab
|
||||
import test_rust_parity as base
|
||||
from test_dedicated_server_parity import Server
|
||||
from test_locator_bar_parity import generate_world, server_dir
|
||||
from test_dedicated_server_parity import Server, game_time
|
||||
from test_locator_bar_parity import Client, generate_world, server_dir
|
||||
|
||||
NAME = 'server-ops-feedback-parity'
|
||||
# (label, what the console does, what the players do).
|
||||
@@ -53,7 +52,11 @@ QUIET = [
|
||||
('alice', [], ['cmd Alice time set 3000']),
|
||||
]
|
||||
CASES = {'broadcast': ({}, BROADCAST), 'quiet': ({'broadcast-console-to-ops': 'false'}, QUIET)}
|
||||
STEP_SECONDS = 2.0
|
||||
STEP_TICKS = 40
|
||||
# A step ends by the server's clock (Client.wait): after a round trip of Alice's (Bob is deopped for a while, so
|
||||
# his is not used). While send_command_feedback is off a command has no reply for her, so those steps wait for
|
||||
# the ticks alone.
|
||||
NO_SYNC = {'feedback-off', 'console-feedback-off'}
|
||||
# Steps whose reply can take longer than a step: the next step waits for this console line first. A loaded machine
|
||||
# took 2 s to save vanilla's world, and the transcript ended before "Saved the game".
|
||||
WAIT_FOR = {'console-save': r'System chat: Saved the game'}
|
||||
@@ -72,33 +75,26 @@ def run_side(label, case, server_command, client_command, build, world):
|
||||
try:
|
||||
server.wait_for(r'Done \(')
|
||||
with (build / f'{label}-{case}-client.log').open('w') as log:
|
||||
client = subprocess.Popen([*map(str, client_command), '127.0.0.1', str(port), str(out)],
|
||||
cwd=lab.ROOT, stdin=subprocess.PIPE, stdout=log, stderr=subprocess.STDOUT,
|
||||
text=True)
|
||||
|
||||
def tell(line):
|
||||
client.stdin.write(line + '\n')
|
||||
client.stdin.flush()
|
||||
client = Client(client_command, port, out, log)
|
||||
try:
|
||||
for name in ('Alice', 'Bob'):
|
||||
tell(f'join {name}')
|
||||
client.tell(f'join {name}')
|
||||
server.wait_for(rf'{name} joined the game', timeout=120)
|
||||
time.sleep(STEP_SECONDS)
|
||||
tell('chat on')
|
||||
client.wait(server, ['Alice'], STEP_TICKS)
|
||||
client.tell('chat on')
|
||||
for step, console, actions in script:
|
||||
tell(f'step {step}')
|
||||
client.tell(f'step {step}')
|
||||
for command in console:
|
||||
server.console(command)
|
||||
game_time(server) # the console runs its queue in order: these commands have run
|
||||
for action in actions:
|
||||
tell(action)
|
||||
client.tell(action)
|
||||
if step in WAIT_FOR:
|
||||
server.wait_for(WAIT_FOR[step], timeout=120)
|
||||
time.sleep(STEP_SECONDS)
|
||||
tell('end')
|
||||
client.wait(timeout=60)
|
||||
client.wait(server, [] if step in NO_SYNC else ['Alice'], STEP_TICKS)
|
||||
client.end()
|
||||
finally:
|
||||
if client.poll() is None:
|
||||
client.kill()
|
||||
client.kill()
|
||||
finally:
|
||||
server.stop()
|
||||
if not out.exists():
|
||||
|
||||
@@ -55,6 +55,12 @@ KNOWN = {
|
||||
"Better Dungeons' own structure types (spec-betterdungeons §5, §6; OPEN-B14, B15) are not "
|
||||
'implemented yet',
|
||||
},
|
||||
'ctov': {
|
||||
r'^ctov:': "Lithostitched's random is not known (spec-lithostitched OPEN-L6): per-block road and palette "
|
||||
'choices match by share, not by block; and decoration (grass, trees) differs where the village '
|
||||
'changed the terrain',
|
||||
r'^minecraft:village_plains$': 'decoration (grass, trees) differs where the village changed the terrain',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare the structure starts Horizon saves with the tags vanilla's StructureStart.createTag writes.
|
||||
|
||||
The oracle (VanillaStructureStartOracle with HORIZON_START_NBT) generates the start of each case's chunk with the
|
||||
pinned server's own classes and prints its tag; the probe (world_probe structure_start_nbt) prints the tag
|
||||
Horizon saves for the same chunk. Both print sorted keys and typed numbers, and the lines must be identical.
|
||||
The cases are the start chunks of one site of every structure kind (seed 12345, and a badlands mineshaft of seed
|
||||
-7777), which between them use every StructurePieceType.
|
||||
"""
|
||||
import argparse
|
||||
import collections
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import platform
|
||||
import subprocess
|
||||
try:
|
||||
from . import lab, test_rust_parity as base
|
||||
except ImportError:
|
||||
import lab
|
||||
import test_rust_parity as base
|
||||
|
||||
# (seed, dimension, chunk x, chunk z): the start chunk of one site of each structure kind.
|
||||
CASES = [
|
||||
(12345, 'overworld', -9, -52), (12345, 'overworld', -146, 37), (12345, 'overworld', -66, -98),
|
||||
(12345, 'overworld', 91, 75), (12345, 'overworld', 75, -23), (12345, 'overworld', 17, -60),
|
||||
(12345, 'overworld', 11, -11), (12345, 'overworld', 91, -90), (12345, 'overworld', 8, -33),
|
||||
(12345, 'overworld', 2, -71), (12345, 'overworld', 39, -28), (12345, 'overworld', -90, -60),
|
||||
(12345, 'the_nether', 11, -16),
|
||||
(12345, 'overworld', 291, 441), (12345, 'overworld', 36, 41), (12345, 'overworld', -8, 2),
|
||||
(12345, 'overworld', 114, -133), (12345, 'overworld', -16, 5), (12345, 'overworld', -109, 91),
|
||||
(12345, 'overworld', 0, -18), (12345, 'overworld', -150, 51), (12345, 'overworld', 61, 49),
|
||||
(12345, 'the_nether', 0, -18), (12345, 'the_nether', -22, 6), (12345, 'the_end', -15, -76),
|
||||
(12345, 'overworld', 38, -115), (12345, 'overworld', -238, -313), (12345, 'overworld', -95, 2),
|
||||
(12345, 'overworld', -126, -106), (12345, 'overworld', 47, 25), (12345, 'overworld', 110, 23),
|
||||
(12345, 'overworld', 4, -1), (12345, 'the_nether', -13, -37), (-7777, 'overworld', 75, 84),
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.parse_args()
|
||||
build = lab.LOCAL / 'rust-structure-start-nbt-parity'
|
||||
build.mkdir(parents=True, exist_ok=True)
|
||||
report_path = build / 'report.json'
|
||||
report_path.unlink(missing_ok=True)
|
||||
lock, jars, libraries = base.verify_artifacts()
|
||||
oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaStructureStartOracle.java'
|
||||
probe = lab.ROOT / 'crates/horizon-world/examples/probe/structure_start_nbt.rs'
|
||||
sources = [oracle, probe, Path(__file__), lab.ROOT / 'tools/test_rust_parity.py', lab.ROOT / 'tools/lab.py',
|
||||
lab.ROOT / 'Cargo.toml', lab.ROOT / 'Cargo.lock', lab.ROOT / 'crates/horizon-world/Cargo.toml',
|
||||
*sorted((lab.ROOT / 'crates/horizon-core/src').rglob('*.rs')),
|
||||
*sorted((lab.ROOT / 'crates/horizon-world/src').rglob('*.rs'))]
|
||||
tested_sources = base.source_hashes(sources)
|
||||
|
||||
def run(command, name, env=None):
|
||||
with (build / (name + '.log')).open('w', encoding='utf-8') as log:
|
||||
base.run(list(map(str, command)), stdout=log, stderr=subprocess.STDOUT, env=env)
|
||||
|
||||
classes = build / 'classes'
|
||||
classes.mkdir(exist_ok=True)
|
||||
dependencies = os.pathsep.join(map(str, [jars['client'], *libraries]))
|
||||
run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-sourcepath',
|
||||
lab.ROOT / 'mods/horizon/src/test/java', '-cp', dependencies, '-d', classes, oracle], 'compile-java')
|
||||
run(['cargo', 'build', '--release', '-p', 'horizon-world', '--example', 'world_probe'], 'compile-rust')
|
||||
metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'],
|
||||
cwd=lab.ROOT, text=True))
|
||||
binary = Path(metadata['target_directory']) / 'release/examples' / (
|
||||
'world_probe.exe' if os.name == 'nt' else 'world_probe')
|
||||
resources = lab.LOCAL / 'horizon-client' / lock['minecraft']['version']
|
||||
groups = collections.defaultdict(list)
|
||||
for seed, dimension, cx, cz in CASES:
|
||||
groups[(seed, dimension)].append((cx, cz))
|
||||
vanilla, horizon = [], []
|
||||
for (seed, dimension), chunks in sorted(groups.items()):
|
||||
name = f'{seed}-{dimension}'
|
||||
out = build / f'client-{name}.txt'
|
||||
env = dict(os.environ, HORIZON_START_NBT='1', HORIZON_DIMENSION=dimension,
|
||||
HORIZON_CHUNKS=';'.join(f'{x},{z}' for x, z in chunks))
|
||||
run(['java', '-Xmx2g', '-cp', str(classes) + os.pathsep + dependencies,
|
||||
'dev.horizonlab.parity.VanillaStructureStartOracle', out, seed, 0, 0, 0, 0], 'client-' + name, env)
|
||||
vanilla += sorted(l for l in out.read_text(encoding='utf-8').splitlines() if l.startswith('nbt '))
|
||||
probe_out = subprocess.check_output([str(binary), 'structure_start_nbt', str(resources), str(seed), dimension,
|
||||
*(f'{x},{z}' for x, z in chunks)], text=True)
|
||||
horizon += sorted(probe_out.splitlines())
|
||||
(build / 'client.txt').write_text(''.join(l + '\n' for l in vanilla), encoding='utf-8')
|
||||
(build / 'rust.txt').write_text(''.join(l + '\n' for l in horizon), encoding='utf-8')
|
||||
if len(vanilla) != len(CASES):
|
||||
raise AssertionError(f'the oracle found {len(vanilla)} starts for {len(CASES)} cases')
|
||||
matched = base.compare(build / 'client.txt', build / 'rust.txt')
|
||||
base.ensure_sources_unchanged(sources, tested_sources)
|
||||
lab.write_json(report_path, dict(
|
||||
schema=1, minecraft=lock['minecraft']['version'], platform=platform.platform(), units=len(CASES),
|
||||
sources_sha256=tested_sources, matched_output_lines=matched,
|
||||
output_sha256=lab.digest(build / 'rust.txt', 'sha256'), client_jar_sha256=lab.digest(jars['client'], 'sha256')))
|
||||
print(f'{len(CASES)} structure starts save as vanilla ({matched} lines): {report_path}', flush=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -240,7 +240,7 @@ def main():
|
||||
run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-nowarn', '-cp', dependencies, '-d', classes,
|
||||
*(PARITY / f'{n}.java' for n in ('ParityData', 'ParityFont', 'VanillaTabListOracle', 'VanillaSkinImageOracle'))], 'compile-java')
|
||||
run(['java', '-Xmx2G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaTabListOracle',
|
||||
inputs, build / 'vanilla.jsonl'], 'vanilla')
|
||||
inputs, build / 'vanilla.jsonl', resources / 'assets'], 'vanilla')
|
||||
run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'client_probe', '--',
|
||||
'tab_list_fixture', resources, inputs, build / 'rust.jsonl'], 'rust')
|
||||
images = build / 'skins.txt'; images.write_text(''.join(i + '\n' for i in skin_images(args.images)))
|
||||
|
||||
Reference in New Issue
Block a user