Merge main into fix/trident-client-flight
- trident.rs: main's thrower guest (player_hurt_entity) beside the owner id a server sends. - remote.rs: the trident and main's firework rocket both take a server move at once; both take its velocity. - remote_projectiles.rs: main's smoke trails stay; the trident flies by its own client tick instead of main's interpolation step. - tests/test_remote_motion.py: both fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
"""Cushion particles must reach clients even when the server has no sprite atlas."""
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which("rustc"), "requires Rust")
|
||||
class CushionParticlesTests(unittest.TestCase):
|
||||
def test_headless_server_records_break_effect_before_sprite_lookup(self):
|
||||
source = (ROOT / "crates/horizon-client/src/game/cushions.rs").read_text()
|
||||
start = source.index(" fn cushion_break_particles(")
|
||||
end = source.index(" /// `BlockAttachedEntity.tick`", start)
|
||||
fixture = r'''
|
||||
#![allow(dead_code)]
|
||||
#[derive(Clone, Copy)]
|
||||
struct Vec3 { x: f64, y: f64, z: f64 }
|
||||
struct Cushion { position: Vec3 }
|
||||
impl Cushion { fn color_name(&self) -> &str { "blue" } }
|
||||
struct Registry;
|
||||
impl Registry {
|
||||
fn default_state(&self, name: &str) -> Option<u32> {
|
||||
assert_eq!(name, "minecraft:blue_wool"); Some(123)
|
||||
}
|
||||
}
|
||||
struct Assets { registry: Registry }
|
||||
struct Pack { assets: Assets }
|
||||
struct Audio { capture: Option<()> }
|
||||
mod horizon_client { pub mod particles {
|
||||
pub enum ParticleType { Block }
|
||||
pub struct ParticleOptions;
|
||||
impl ParticleOptions {
|
||||
pub fn block(_: ParticleType, _: String, _: u32) -> Self { Self }
|
||||
}
|
||||
} }
|
||||
#[derive(Default)]
|
||||
struct Particles { count: u32 }
|
||||
impl Particles {
|
||||
fn send_particles(&mut self, _: &horizon_client::particles::ParticleOptions,
|
||||
at: [f64; 3], spread: [f64; 3], speed: f64, count: u32) {
|
||||
assert!((at[1] - (10.0 + 1.0/6.0)).abs() < 1e-12);
|
||||
assert_eq!(spread, [0.25, 0.0625, 0.25]);
|
||||
assert_eq!(speed, 0.05); assert_eq!(count, 10); self.count += count;
|
||||
}
|
||||
}
|
||||
struct Game {
|
||||
pack: Pack, audio: Audio, particles: Particles, headless: bool,
|
||||
lan_cushion_breaks: Vec<(u32, [f64; 3])>,
|
||||
}
|
||||
impl Game {
|
||||
fn particle_sprite(&self, _: u32, _: [i32; 3]) -> Option<(String, u32)> {
|
||||
(!self.headless).then(|| ("block/blue_wool".into(), 0xffffff))
|
||||
}
|
||||
METHOD
|
||||
}
|
||||
fn main() {
|
||||
let cushion = Cushion { position: Vec3 { x: 1.5, y: 10.0, z: 2.5 } };
|
||||
for headless in [true, false] {
|
||||
for serving in [true, false] {
|
||||
let mut game = Game {
|
||||
pack: Pack { assets: Assets { registry: Registry } },
|
||||
audio: Audio { capture: serving.then_some(()) },
|
||||
particles: Particles::default(), headless, lan_cushion_breaks: vec![],
|
||||
};
|
||||
game.cushion_break_particles(&cushion);
|
||||
assert_eq!(game.lan_cushion_breaks.len(), usize::from(serving));
|
||||
if serving {
|
||||
let (state, at) = game.lan_cushion_breaks[0];
|
||||
assert_eq!(state, 123);
|
||||
assert_eq!([at[0], at[2]], [1.5, 2.5]);
|
||||
assert!((at[1] - (10.0 + 1.0/6.0)).abs() < 1e-12);
|
||||
}
|
||||
assert_eq!(game.particles.count, if headless { 0 } else { 10 });
|
||||
}
|
||||
}
|
||||
}
|
||||
'''.replace("METHOD", source[start:end])
|
||||
with tempfile.TemporaryDirectory(prefix="cushion-particles-") as directory:
|
||||
path = Path(directory)
|
||||
(path / "main.rs").write_text(fixture)
|
||||
subprocess.run(["rustc", "--edition=2024", str(path / "main.rs"), "-o", str(path / "probe")],
|
||||
check=True, capture_output=True, text=True)
|
||||
result = subprocess.run([str(path / "probe")], capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
@@ -111,6 +111,26 @@ class ReachTests(unittest.TestCase):
|
||||
self.assertIn("crates/a/src/display.rs", full)
|
||||
self.assertTrue(graph.results)
|
||||
|
||||
def test_a_module_moved_to_a_new_crate_counts_through_its_reexport(self):
|
||||
# used.rs moves to crate b after the harness was recorded; a re-exports it under its old path. Crate c is
|
||||
# a dependency nothing reached names: its items stay out even where their names match.
|
||||
(self.root / "crates/a/src/used.rs").unlink()
|
||||
workspace(self.root, {
|
||||
"crates/a/Cargo.toml": (self.root / "crates/a/Cargo.toml").read_text()
|
||||
+ '\n[dependencies]\nb = { path = "../b" }\nc = { path = "../c" }\n',
|
||||
"crates/a/src/lib.rs": "pub use b::used;\npub mod unused;\nmod methods;\nmod display;\n",
|
||||
"crates/b/Cargo.toml": '[package]\nname = "b"\n',
|
||||
"crates/b/src/lib.rs": "pub mod used;\n",
|
||||
"crates/b/src/used.rs": "pub struct Thing;\npub fn helper() -> u32 { 1 }\n",
|
||||
"crates/c/Cargo.toml": '[package]\nname = "c"\n',
|
||||
"crates/c/src/lib.rs": "pub fn helper() -> u32 { 3 }\n",
|
||||
})
|
||||
changed = {"crates/b/src/used.rs", "crates/c/src/lib.rs"}
|
||||
self.assertEqual(parity_reach.unrecorded(self.root, self.dependencies, changed), changed)
|
||||
kept = self.narrowed(changed=changed)
|
||||
self.assertIn("crates/b/src/used.rs", kept)
|
||||
self.assertNotIn("crates/c/src/lib.rs", kept)
|
||||
|
||||
def test_unknown_probes_keep_everything(self):
|
||||
self.assertEqual(set(self.narrowed(artifacts=[])), set(self.dependencies))
|
||||
self.assertEqual(set(self.narrowed(artifacts=[["example", "missing", "release", ["-p", "a"], True]])),
|
||||
|
||||
+175
-3
@@ -290,9 +290,6 @@ class OracleReuseTests(unittest.TestCase):
|
||||
self.assertEqual(self.output.read_text(), "b")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class LargeOutputTests(unittest.TestCase):
|
||||
def test_a_pass_clears_only_its_own_directory(self):
|
||||
@@ -323,3 +320,178 @@ class LargeOutputTests(unittest.TestCase):
|
||||
listing.write_text(f"{own / 'server.txt'}\n{own / 'client.txt'}\n")
|
||||
parity.clear_large_outputs("state_provider#2", trace)
|
||||
self.assertEqual(sorted(path.name for path in own.iterdir()), ["report.json", "server.txt"])
|
||||
|
||||
|
||||
class FakeExecutor:
|
||||
"""Runs nothing: each start of a harness takes the next status from its script, a list."""
|
||||
name, dead, max_peak = "fake", False, None
|
||||
|
||||
def __init__(self):
|
||||
self.started, self.finished = [], []
|
||||
|
||||
def free(self):
|
||||
return 1
|
||||
|
||||
def accepts(self, name):
|
||||
return True
|
||||
|
||||
def fits(self, expected, only_here=True):
|
||||
return True
|
||||
|
||||
def start(self, label, script, reuse, expected, shard=None):
|
||||
self.started.append((label, reuse))
|
||||
self.finished.append((label, {"status": script.pop(0), "seconds": 1.0, "dependencies": []}))
|
||||
return True
|
||||
|
||||
def poll(self):
|
||||
finished, self.finished = self.finished, []
|
||||
return finished
|
||||
|
||||
|
||||
class KnownFlakyTests(unittest.TestCase):
|
||||
def run_harnesses(self, scripts, flaky, rounds=None):
|
||||
executor = FakeExecutor()
|
||||
state = {"harnesses": {name: {"status": "pass", "oracle_reuse": True} for name in scripts}}
|
||||
with tempfile.TemporaryDirectory() as tmp, mock.patch.multiple(parity, STATE_DIR=Path(tmp), SHARED=Path(tmp)), \
|
||||
mock.patch.object(parity, "save_state"), mock.patch.object(parity, "time") as clock:
|
||||
clock.monotonic.return_value = 0.0
|
||||
results, _ = parity.run(scripts, state, None, "env", [executor], True, rounds, flaky)
|
||||
return results, executor.started
|
||||
|
||||
def test_a_known_flaky_failure_runs_once_more_from_scratch_and_says_so(self):
|
||||
results, started = self.run_harnesses({"dedicated_server": ["fail", "pass"]}, {"dedicated_server": "timer"})
|
||||
self.assertEqual(results["dedicated_server"]["status"], "pass")
|
||||
self.assertEqual(results["dedicated_server"]["retried"], "known flaky")
|
||||
# The first run reused oracle results; a known flaky harness doesn't lose that by flaking.
|
||||
self.assertTrue(results["dedicated_server"]["oracle_reuse"])
|
||||
self.assertEqual(started, [("dedicated_server", True), ("dedicated_server", False)])
|
||||
|
||||
def test_only_once(self):
|
||||
results, started = self.run_harnesses({"dedicated_server": ["fail", "fail"]}, {"dedicated_server": "timer"})
|
||||
self.assertEqual(results["dedicated_server"]["status"], "fail")
|
||||
self.assertEqual(len(started), 2)
|
||||
|
||||
def test_other_harnesses_keep_only_the_reused_oracle_retry(self):
|
||||
results, started = self.run_harnesses({"food": ["fail", "pass"]}, {"dedicated_server": "timer"})
|
||||
self.assertEqual((results["food"]["status"], results["food"]["retried"]), ("pass", "reused oracle results"))
|
||||
self.assertEqual(started, [("food", True), ("food", False)])
|
||||
self.assertFalse(results["food"]["oracle_reuse"])
|
||||
|
||||
def test_repeated_runs_get_no_retry(self):
|
||||
results, started = self.run_harnesses({"dedicated_server": ["pass", "fail"]}, {"dedicated_server": "timer"},
|
||||
rounds={"dedicated_server": 2})
|
||||
self.assertEqual((results["dedicated_server"]["status"], len(started)), ("fail", 2))
|
||||
|
||||
def test_retries_reach_the_job_summary(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
summary = Path(tmp) / "summary.md"
|
||||
with mock.patch.dict(os.environ, {"GITHUB_STEP_SUMMARY": str(summary)}), \
|
||||
mock.patch("builtins.print"):
|
||||
parity.report_retries({"dedicated_server": {"status": "pass", "retried": "known flaky"},
|
||||
"food": {"status": "pass"}}, {"dedicated_server": "timer"})
|
||||
text = summary.read_text()
|
||||
self.assertIn("RETRIED dedicated_server: failed, then passed on its one retry (known flaky: timer", text)
|
||||
self.assertNotIn("food", text)
|
||||
|
||||
def test_the_known_flaky_list_has_a_reason_per_harness(self):
|
||||
flaky = parity.known_flaky(parity.host_config())
|
||||
self.assertTrue(all(isinstance(reason, str) and len(reason) > 20 for reason in flaky.values()))
|
||||
self.assertTrue(set(flaky) <= {parity.base_name(name) for name in parity.harnesses()})
|
||||
|
||||
|
||||
|
||||
class SoloTests(unittest.TestCase):
|
||||
"""Harnesses driving game windows run alone on a small machine (playhorizon's 4-CPU runner)."""
|
||||
|
||||
def executor(self, running):
|
||||
with tempfile.TemporaryDirectory() as tmp, mock.patch.object(parity, "STATE_DIR", Path(tmp)):
|
||||
local = parity.LocalExecutor(4, 1 << 40, 60)
|
||||
local.solo = {"remote_fireworks"}
|
||||
local.running = {label: {} for label in running}
|
||||
return local
|
||||
|
||||
def test_a_solo_harness_waits_for_an_empty_machine_and_then_holds_it(self):
|
||||
busy = self.executor(["food"])
|
||||
self.assertFalse(busy.accepts("remote_fireworks"))
|
||||
self.assertTrue(busy.accepts("light"))
|
||||
self.assertEqual(busy.free(), 3)
|
||||
self.assertTrue(self.executor([]).accepts("remote_fireworks"))
|
||||
alone = self.executor(["remote_fireworks~2"])
|
||||
self.assertEqual(alone.free(), 0)
|
||||
|
||||
def test_only_small_machines_and_listed_harnesses(self):
|
||||
config = {"solo": {"remote_fireworks": "two game windows"}}
|
||||
with mock.patch.dict(os.environ, {"PARITY_SOLO": "1"}):
|
||||
self.assertEqual(parity.solo_harnesses(config), {"remote_fireworks"})
|
||||
with mock.patch.dict(os.environ, {"PARITY_SOLO": "0"}):
|
||||
self.assertEqual(parity.solo_harnesses(config), set())
|
||||
with mock.patch.dict(os.environ, {"PARITY_SOLO": ""}), mock.patch.object(parity, "SOLO_CPUS", 10 ** 6):
|
||||
self.assertEqual(parity.solo_harnesses(config), {"remote_fireworks"})
|
||||
solo = parity.host_config().get("solo", {})
|
||||
self.assertTrue(solo and set(solo) <= {parity.base_name(name) for name in parity.harnesses()})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class WorkspaceManifestTests(unittest.TestCase):
|
||||
"""A crate split's Cargo.toml and Cargo.lock changes don't select every harness; a dependency change still does."""
|
||||
CLIENT = '[package]\nname = "horizon-client"\n\n[dependencies]\nserde = "1"\nwgpu = { version = "27", features = ["x"] }\n'
|
||||
LOCK = ('version = 4\n\n[[package]]\nname = "horizon-client"\nversion = "0.1.0"\ndependencies = [\n "serde",\n]\n\n'
|
||||
'[[package]]\nname = "serde"\nversion = "1.0.1"\nsource = "registry+https://github.com/rust-lang/crates.io-index"\n')
|
||||
|
||||
def verdict(self, base, head):
|
||||
"""base, head: {path: text or None}; the manifests workspace_only_manifests leaves out."""
|
||||
with tempfile.TemporaryDirectory() as temp, \
|
||||
mock.patch.object(parity, "ROOT", Path(temp)), \
|
||||
mock.patch.object(parity, "git_show", lambda _base, path: base.get(path)):
|
||||
for path, text in head.items():
|
||||
if text is not None:
|
||||
Path(temp, path).parent.mkdir(parents=True, exist_ok=True)
|
||||
Path(temp, path).write_text(text)
|
||||
return parity.workspace_only_manifests(set(head) | set(base), "base")
|
||||
|
||||
def test_a_crate_split_is_left_out(self):
|
||||
command = '[package]\nname = "horizon-command"\n\n[dependencies]\nserde = "1"\nhorizon-core = { path = "../horizon-core" }\n'
|
||||
client = self.CLIENT + 'horizon-command = { path = "../horizon-command" }\n'
|
||||
lock = self.LOCK.replace('[[package]]\nname = "serde"', '[[package]]\nname = "horizon-command"\nversion = "0.1.0"\n\n'
|
||||
'[[package]]\nname = "serde"')
|
||||
base = {"Cargo.toml": '[workspace]\nmembers = ["crates/horizon-client"]\nresolver = "2"\n',
|
||||
"crates/horizon-client/Cargo.toml": self.CLIENT, "Cargo.lock": self.LOCK}
|
||||
head = {"Cargo.toml": '[workspace]\nmembers = ["crates/horizon-client", "crates/horizon-command"]\nresolver = "2"\n',
|
||||
"crates/horizon-client/Cargo.toml": client, "crates/horizon-command/Cargo.toml": command, "Cargo.lock": lock}
|
||||
self.assertEqual(self.verdict(base, head), set(head))
|
||||
|
||||
def test_a_dependency_change_still_counts(self):
|
||||
base = {"crates/horizon-client/Cargo.toml": self.CLIENT, "Cargo.lock": self.LOCK}
|
||||
bumped = {"crates/horizon-client/Cargo.toml": self.CLIENT, "Cargo.lock": self.LOCK.replace("1.0.1", "1.0.2")}
|
||||
self.assertEqual(self.verdict(base, bumped), set())
|
||||
feature = {"crates/horizon-client/Cargo.toml": self.CLIENT.replace('["x"]', '["x", "y"]')}
|
||||
self.assertEqual(self.verdict({"crates/horizon-client/Cargo.toml": self.CLIENT}, feature), set())
|
||||
resolver = {"Cargo.toml": '[workspace]\nmembers = ["a"]\nresolver = "3"\n'}
|
||||
self.assertEqual(self.verdict({"Cargo.toml": '[workspace]\nmembers = ["a"]\nresolver = "2"\n'}, resolver), set())
|
||||
|
||||
def test_a_feature_of_a_workspace_crate_counts_through_its_sources(self):
|
||||
items = '[package]\nname = "horizon-items"\n\n[features]\ntest-support = []\n'
|
||||
client = self.CLIENT + '\n[dev-dependencies]\nhorizon-items = { path = "../horizon-items", features = ["test-support"] }\n'
|
||||
head = {"crates/horizon-items/Cargo.toml": items, "crates/horizon-client/Cargo.toml": client,
|
||||
"crates/horizon-items/src/lib.rs": '#[cfg(feature = "test-support")]\npub fn for_tests() {}\n'}
|
||||
base = {"crates/horizon-client/Cargo.toml": self.CLIENT}
|
||||
# The new crate's files are all changed, the code the feature gates with them.
|
||||
self.assertEqual(self.verdict(base, head), {"crates/horizon-items/Cargo.toml", "crates/horizon-client/Cargo.toml"})
|
||||
# Turning on a feature of a crate whose gated code didn't change selects as before.
|
||||
world = '[package]\nname = "horizon-world"\n\n[features]\nextra = ["more"]\nmore = []\n'
|
||||
with tempfile.TemporaryDirectory() as temp, mock.patch.object(parity, "ROOT", Path(temp)):
|
||||
Path(temp, "crates/horizon-world/src").mkdir(parents=True)
|
||||
Path(temp, "crates/horizon-world/Cargo.toml").write_text(world)
|
||||
Path(temp, "crates/horizon-world/src/lib.rs").write_text('#[cfg(feature = "more")]\nfn x() {}\n')
|
||||
self.assertFalse(parity.feature_sources_changed("horizon-world", "extra", {"crates/horizon-client/Cargo.toml"}))
|
||||
self.assertTrue(parity.feature_sources_changed("horizon-world", "extra", {"crates/horizon-world/src/lib.rs"}))
|
||||
self.assertFalse(parity.feature_sources_changed("horizon-nothing", "extra", set()))
|
||||
# A feature that reaches an external package counts.
|
||||
optional = {"crates/horizon-client/Cargo.toml": self.CLIENT + '\n[features]\nfast = ["wgpu/x"]\n'}
|
||||
self.assertEqual(self.verdict({"crates/horizon-client/Cargo.toml": self.CLIENT}, optional), set())
|
||||
|
||||
def test_without_a_base_everything_counts(self):
|
||||
self.assertEqual(parity.workspace_only_manifests({"Cargo.lock"}, None), set())
|
||||
|
||||
+42
-12
@@ -9,7 +9,8 @@ PACKAGES = {"horizon-core": "crates/horizon-core", "horizon-client": "crates/hor
|
||||
"horizon-theme": "crates/horizon-theme", "xtask": "xtask"}
|
||||
LIBRARIES = set(PACKAGES) - {"xtask"}
|
||||
DEPENDENCIES = {"horizon-client": {"horizon-core"}}
|
||||
MODS = " --features horizon-mods/runtime,horizon-mods/pack,horizon-client/mods"
|
||||
MODS = " --features horizon-client/mods,horizon-mods/pack"
|
||||
CLIPPY = pr_ready.CI_CLIPPY + " && " + pr_ready.CI_CLIPPY_SERVER
|
||||
|
||||
|
||||
def args(host="local", quick=False):
|
||||
@@ -35,6 +36,9 @@ class PrReadyTests(unittest.TestCase):
|
||||
self.assertFalse(pr_ready.workspace_rust("crates/horizon-client/README.md"))
|
||||
self.assertFalse(pr_ready.workspace_rust("launcher/src/main.rs"))
|
||||
self.assertTrue(pr_ready.launcher_rust("launcher/src/main.rs"))
|
||||
# CI's launcher job also runs for the root workspace's manifests and for its own check.
|
||||
self.assertTrue(pr_ready.launcher_rust("Cargo.lock"))
|
||||
self.assertTrue(pr_ready.launcher_rust("tools/ci/rust_changes.py"))
|
||||
self.assertTrue(pr_ready.launcher_rust("crates/horizon-prepare/src/lib.rs"))
|
||||
self.assertTrue(pr_ready.launcher_rust("crates/horizon-theme/src/lib.rs"))
|
||||
self.assertTrue(pr_ready.launcher_rust("crates/horizon-telemetry/src/lib.rs"))
|
||||
@@ -46,24 +50,48 @@ class PrReadyTests(unittest.TestCase):
|
||||
with mock.patch.object(pr_ready, "affected_here", return_value=[]):
|
||||
steps = pr_ready.plan(args(quick=True), "origin/main", {"crates/horizon-client/src/game.rs"}, PACKAGES, LIBRARIES, DEPENDENCIES)
|
||||
by_name = {step.name: step for step in steps}
|
||||
self.assertEqual(by_name["clippy"].command,
|
||||
"cargo clippy -p horizon-client --all-targets --locked -- -D warnings")
|
||||
self.assertEqual(by_name["clippy"].command, CLIPPY)
|
||||
self.assertEqual(by_name["tests: horizon-client"].command,
|
||||
"cargo test --locked -p horizon-client --tests")
|
||||
"cargo test --locked -p horizon-client --features horizon-client/mods --tests")
|
||||
self.assertEqual(by_name["doc tests"].command, "cargo test --locked -p horizon-client --doc")
|
||||
self.assertIsNone(by_name["doc tests"].status)
|
||||
|
||||
def test_content_root_tests_run_only_when_what_they_load_changes(self):
|
||||
def content_step(path):
|
||||
with mock.patch.object(pr_ready, "affected_here", return_value=[]):
|
||||
steps = pr_ready.plan(args(quick=True), "origin/main", {path}, PACKAGES, LIBRARIES, DEPENDENCIES)
|
||||
return {step.name: step for step in steps}["content root tests"]
|
||||
self.assertEqual(content_step("crates/horizon-client/src/game.rs").skip, "content root untouched")
|
||||
for path in ["crates/horizon-client/src/mod_content.rs", "crates/horizon-client/src/mod_content_tests.rs",
|
||||
"crates/horizon-mods/src/content.rs", "crates/horizon-assets/src/lib.rs", "Cargo.lock"]:
|
||||
with self.subTest(path=path):
|
||||
step = content_step(path)
|
||||
self.assertIsNone(step.skip)
|
||||
self.assertEqual(step.command, pr_ready.CONTENT_ROOT_TESTS)
|
||||
|
||||
def test_shared_rust_configuration_keeps_workspace_coverage(self):
|
||||
for path in sorted(pr_ready.ROOT_RUST | {".cargo/config.toml", "crates/unknown/src/lib.rs"}):
|
||||
with self.subTest(path=path), mock.patch.object(pr_ready, "affected_here", return_value=[]):
|
||||
steps = pr_ready.plan(args(quick=True), "origin/main", {path}, PACKAGES, LIBRARIES, DEPENDENCIES)
|
||||
by_name = {step.name: step for step in steps}
|
||||
self.assertEqual(by_name["clippy"].command,
|
||||
"cargo clippy --workspace" + MODS + " --all-targets --locked -- -D warnings")
|
||||
self.assertEqual(by_name["clippy"].command, CLIPPY)
|
||||
self.assertEqual(by_name["tests: workspace"].command,
|
||||
"cargo test --locked --workspace" + MODS + " --tests")
|
||||
self.assertEqual(by_name["doc tests"].command, "cargo test --locked --workspace --doc")
|
||||
|
||||
def test_tests_get_the_features_ci_s_workspace_run_gives_them(self):
|
||||
self.assertEqual(pr_ready.mod_features(["horizon-world"]), "")
|
||||
self.assertEqual(pr_ready.mod_features(["horizon-client"]), " --features horizon-client/mods")
|
||||
self.assertEqual(pr_ready.mod_features(["horizon-mods"]),
|
||||
" --features horizon-mods/runtime,horizon-mods/pack,horizon-mods/index")
|
||||
self.assertEqual(pr_ready.mod_features(None), MODS)
|
||||
|
||||
def test_python_tests_always_run(self):
|
||||
with mock.patch.object(pr_ready, "affected_here", return_value=[]):
|
||||
steps = pr_ready.plan(args(quick=True), "origin/main", {"crates/horizon-core/src/lib.rs"},
|
||||
PACKAGES, LIBRARIES, DEPENDENCIES)
|
||||
self.assertIsNone({step.name: step for step in steps}["Python tests"].status)
|
||||
|
||||
def test_non_rust_changes_skip_workspace_checks(self):
|
||||
for path in ("README.md", "tools/pr_ready.py", "launcher/src/main.rs"):
|
||||
with self.subTest(path=path), mock.patch.object(pr_ready, "affected_here", return_value=[]):
|
||||
@@ -77,7 +105,7 @@ class PrReadyTests(unittest.TestCase):
|
||||
steps = pr_ready.plan(args(), "origin/main",
|
||||
{"crates/horizon-core/src/lib.rs", "crates/horizon-client/examples/probe.rs"}, PACKAGES, LIBRARIES, DEPENDENCIES)
|
||||
for step in steps:
|
||||
if step.name in ("clippy", "tests: horizon-client, horizon-core", "doc tests"):
|
||||
if step.name in ("tests: horizon-client, horizon-core", "doc tests"):
|
||||
self.assertIn("-p horizon-client -p horizon-core", step.command)
|
||||
self.assertIsNone(step.status)
|
||||
|
||||
@@ -94,15 +122,17 @@ class PrReadyTests(unittest.TestCase):
|
||||
by_name = {step.name: step for step in steps}
|
||||
self.assertEqual(by_name["doc tests"].command, "cargo test --locked -p horizon-core --doc")
|
||||
|
||||
def test_clippy_checks_transitive_consumers_but_tests_only_touched_crates(self):
|
||||
packages = {name: f"crates/{name}" for name in ("core", "world", "client", "unrelated")}
|
||||
dependencies = {"world": {"core"}, "client": {"world"}, "unrelated": set()}
|
||||
def test_clippy_is_ci_s_and_the_server_build_when_the_game_is_affected(self):
|
||||
packages = {name: f"crates/{name}" for name in ("core", "world", "horizon-client", "unrelated")}
|
||||
dependencies = {"world": {"core"}, "horizon-client": {"world"}, "unrelated": set()}
|
||||
with mock.patch.object(pr_ready, "affected_here", return_value=[]):
|
||||
steps = pr_ready.plan(args(), "origin/main", {"crates/core/src/lib.rs"},
|
||||
packages, set(packages), dependencies)
|
||||
unrelated = pr_ready.plan(args(), "origin/main", {"crates/unrelated/src/lib.rs"},
|
||||
packages, set(packages), dependencies)
|
||||
self.assertEqual({step.name: step for step in unrelated}["clippy"].command, pr_ready.CI_CLIPPY)
|
||||
by_name = {step.name: step for step in steps}
|
||||
self.assertEqual(by_name["clippy"].command,
|
||||
"cargo clippy -p client -p core -p world --all-targets --locked -- -D warnings")
|
||||
self.assertEqual(by_name["clippy"].command, CLIPPY)
|
||||
self.assertEqual(by_name["tests: core"].command, "cargo test --locked -p core --tests")
|
||||
self.assertEqual(by_name["doc tests"].command, "cargo test --locked -p core --doc")
|
||||
|
||||
|
||||
@@ -240,10 +240,34 @@ class ReleaseTrainTests(unittest.TestCase):
|
||||
def test_known_issues_are_the_bullets_of_the_file(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
path = Path(temp, "known-issues.md")
|
||||
path.write_text("# Known issues\n\nSome text.\n\n- One.\n- Two, with **bold**.\n continued\n")
|
||||
self.assertEqual(train.known_issues(path), ["- One.", "- Two, with **bold**."])
|
||||
path.write_text("# Known issues\n\nSome text.\n\n- One.\n- Two, with **bold**. \n"
|
||||
" continued with `code`\n\tand a [link](https://example.com). \n- Three.\n")
|
||||
self.assertEqual(train.known_issues(path),
|
||||
["- One.", "- Two, with **bold**. continued with `code` and a [link](https://example.com).",
|
||||
"- Three."])
|
||||
self.assertEqual(train.known_issues(Path(temp, "missing.md")), [])
|
||||
|
||||
def test_known_issues_do_not_include_unrelated_text(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
path = Path(temp, "known-issues.md")
|
||||
for separator in ["\n", " \n", "# Heading\n", "Some text.\n"]:
|
||||
with self.subTest(separator=separator):
|
||||
path.write_text(" Intro.\n- One.\n continued.\n" + separator + " Not an issue.\n- Two.\n")
|
||||
self.assertEqual(train.known_issues(path), ["- One. continued.", "- Two."])
|
||||
path.write_text("# Known issues\n\nNo issues.\n")
|
||||
self.assertEqual(train.known_issues(path), [])
|
||||
path.write_text("")
|
||||
self.assertEqual(train.known_issues(path), [])
|
||||
|
||||
def test_notes_keep_the_wrapped_shaderpacks_issue(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
path = Path(temp, "known-issues.md")
|
||||
path.write_text("- Shader packs have been removed for now. Packs in your\n"
|
||||
" `shaderpacks` folder are left where they are.\n")
|
||||
_, body = train.notes("game", "v0.2.70", [pr(1)], train.known_issues(path))
|
||||
self.assertIn("### Known issues\n- Shader packs have been removed for now. Packs in your "
|
||||
"`shaderpacks` folder are left where they are.\n", body)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -90,6 +90,7 @@ impl Game {
|
||||
fn predict_break(&mut self, pos: [i32; 3], _: u32, _: i32) { self.world.broken.push(pos); }
|
||||
fn send(&mut self, S::PlayerAction(packet): S) { self.packets.push(packet); }
|
||||
fn crack_particle(&mut self, _: [i32; 3], _: u8, _: u32) {}
|
||||
fn breaking_block_effects(&mut self, _: [i32; 3], _: u8, _: bool) {}
|
||||
METHOD
|
||||
}
|
||||
fn main() {
|
||||
|
||||
@@ -35,7 +35,8 @@ impl End { fn remote_eye_motion(&mut self, _id: u32, _v: [f64; 3]) {} }
|
||||
#[derive(Default)]
|
||||
struct Game {
|
||||
mobs: Vec<Entity>, dropped: Vec<Entity>, falling: Vec<Entity>, tnts: Vec<Entity>,
|
||||
creatures: Creatures, dragon_fireballs: Vec<Entity>, tridents: Vec<Entity>, remote: Option<Remote>,
|
||||
creatures: Creatures, dragon_fireballs: Vec<Entity>, tridents: Vec<Entity>,
|
||||
rockets: Vec<Entity>, remote: Option<Remote>,
|
||||
potions: Potions, end: End,
|
||||
}
|
||||
impl Game {
|
||||
|
||||
Reference in New Issue
Block a user