@@ -1,14 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Keep verify's Rust steps for any change beyond documentation."""
|
||||
"""Keep verify's Rust steps for any change beyond documentation.
|
||||
|
||||
--launcher: whether the change is built into the launcher, its own workspace (release_train.LAUNCHER_PATHS).
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# The repository root, appended so a script run finds `tools` without shadowing anything already importable.
|
||||
sys.path.append(str(Path(__file__).resolve().parents[2]))
|
||||
from tools import release_train # noqa: E402
|
||||
|
||||
# The root workspace's manifest and toolchain files: the launcher's path crates inherit from them.
|
||||
ROOT_RUST = {"Cargo.toml", "Cargo.lock", "rust-toolchain.toml", "rustfmt.toml", "clippy.toml"}
|
||||
# The check itself: a change to it runs it.
|
||||
LAUNCHER_CHECK = {".github/workflows/ci.yml", "tools/ci/rust_changes.py", "tools/release_train.py"}
|
||||
|
||||
|
||||
def needs_rust(paths):
|
||||
return any(not (path.startswith("docs/") or path.endswith(".md")) for path in paths)
|
||||
|
||||
|
||||
def needs_launcher(paths):
|
||||
return any(path in ROOT_RUST or path in LAUNCHER_CHECK or (
|
||||
path.startswith(tuple(release_train.LAUNCHER_PATHS))
|
||||
and not path.startswith(tuple(release_train.LAUNCHER_IGNORED))
|
||||
and not path.endswith(".md")
|
||||
) for path in paths)
|
||||
|
||||
|
||||
def changed_paths(base, head):
|
||||
# Renames must include deletions too: moving source into docs still affects Rust.
|
||||
output = subprocess.check_output([
|
||||
@@ -21,5 +43,7 @@ if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("base")
|
||||
parser.add_argument("head")
|
||||
parser.add_argument("--launcher", action="store_true", help="answer for the launcher instead")
|
||||
args = parser.parse_args()
|
||||
print(f"required={str(needs_rust(changed_paths(args.base, args.head))).lower()}")
|
||||
needs = needs_launcher if args.launcher else needs_rust
|
||||
print(f"required={str(needs(changed_paths(args.base, args.head))).lower()}")
|
||||
|
||||
@@ -91,6 +91,8 @@ address. The script then checks, from both sides, what a guest's game used to ge
|
||||
places a log in the inventory's crafting grid (the server places it).
|
||||
- recipe_removal: the host and guest each forget all and individual recipes while the book
|
||||
is open; it stays empty when reopened, and a later grant appears (#1495).
|
||||
- recipe_targets: `/recipe give|take <other player>` changes that player's book, the host's
|
||||
for the guest and (server thread) the guest's for the host; their open book shows it.
|
||||
- feedback: the guest's command feedback names the guest and shows the numbers, and the host (an
|
||||
operator) is told of it as `[Guest: ...]`.
|
||||
- clicks: with real mouse presses (not click-slot, which skips the screen's press and drag
|
||||
@@ -6232,6 +6234,62 @@ CHECKS += ['recipe_removal']
|
||||
CHECK_FNS.update(recipe_removal=check_recipe_removal)
|
||||
|
||||
|
||||
def check_recipe_targets(host, guest, out):
|
||||
"""RecipeCommand gives and takes the recipes of each target's own ServerRecipeBook: a
|
||||
`/recipe give|take <other player>` changes that player's book and reaches their client,
|
||||
not the book of the player who typed it. An in-frame host isn't one of the players a guest's
|
||||
command can name (`command_players` lists the guests), so the guest gives the host a recipe
|
||||
only when the host is a client of its server thread."""
|
||||
host_name = host.raw('lan', 'status').get('host', 'Player')
|
||||
books = {}
|
||||
for game in (host, guest):
|
||||
back_to_game(game)
|
||||
game('command', command='clear @s')
|
||||
game('command', command='recipe take @s *')
|
||||
host.wait(20)
|
||||
for game in (host, guest):
|
||||
game.raw('key', 'e', 'tap')
|
||||
game.wait(5)
|
||||
book = game('screen').get('recipe_book')
|
||||
assert book, f'{game.name}: the inventory has no recipe book'
|
||||
if len(book['targets']) == 1:
|
||||
game.raw('click-at', *centre(book['targets'][0]))
|
||||
game.wait(5)
|
||||
|
||||
def known():
|
||||
return {game.name: game('screen')['recipe_book']['known'] for game in (host, guest)}
|
||||
|
||||
try:
|
||||
books['empty'] = known()
|
||||
assert books['empty'] == {host.name: 0, guest.name: 0}, books
|
||||
host('command', command=f'recipe give {GUEST_NAME} minecraft:oak_planks')
|
||||
host('command', command=f'recipe give {GUEST_NAME} minecraft:stick')
|
||||
host.wait(20)
|
||||
books['host gives guest'] = known()
|
||||
if SERVER_THREAD:
|
||||
guest('command', command=f'recipe give {host_name} minecraft:stick')
|
||||
guest.wait(20)
|
||||
books['guest gives host'] = known()
|
||||
host('command', command=f'recipe take {GUEST_NAME} minecraft:stick')
|
||||
host.wait(20)
|
||||
books['host takes from guest'] = known()
|
||||
host.shot(out, 'recipe-targets-host')
|
||||
guest.shot(out, 'recipe-targets-guest')
|
||||
by_guest = int(SERVER_THREAD)
|
||||
expected = {'empty': (0, 0), 'host gives guest': (0, 2), 'guest gives host': (by_guest, 2),
|
||||
'host takes from guest': (by_guest, 1)}
|
||||
for step, (in_host, in_guest) in expected.items():
|
||||
assert books[step] == {host.name: in_host, guest.name: in_guest}, (step, books)
|
||||
finally:
|
||||
back_to_game(host)
|
||||
back_to_game(guest)
|
||||
return books
|
||||
|
||||
|
||||
CHECKS += ['recipe_targets']
|
||||
CHECK_FNS.update(recipe_targets=check_recipe_targets)
|
||||
|
||||
|
||||
def check_shulker_bullets(host, guest, out):
|
||||
"""ShulkerAttackGoal's bullets reach ClientPacketListener.handleAddEntity, then the existing
|
||||
projectile renderer and interpolation, with distinct ids from the server's entity counter."""
|
||||
|
||||
Reference in New Issue
Block a user