cargo-horizon-mod: trial runs behind feature full, so a packing-only tool skips wasmtime
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,14 @@ license.workspace = true
|
||||
rust-version = "1.86"
|
||||
description = "cargo horizon-mod new/build/run/check: make Horizon mods in Rust (docs/mods.md)"
|
||||
|
||||
[features]
|
||||
default = ["full"]
|
||||
# The trial runs (`check`, `test`) and the registry's CI need wasmtime. Without this feature the
|
||||
# tool is new, build and run only, and builds in a fraction of the time (CI that only packs mods).
|
||||
full = ["horizon-mods/runtime", "horizon-mods/index"]
|
||||
|
||||
[dependencies]
|
||||
horizon-mods = { path = "../horizon-mods", default-features = false, features = ["pack", "runtime", "index"] }
|
||||
horizon-mods = { path = "../horizon-mods", default-features = false, features = ["pack"] }
|
||||
serde_json = "1.0.151"
|
||||
|
||||
[lints]
|
||||
|
||||
@@ -11,12 +11,15 @@
|
||||
//! - `check <file> [--json]`: what the registry checks of a submission
|
||||
//! (`.hmod`, `.hpack`, resource pack `.zip`), with a trial run for a mod.
|
||||
//! - `registry build|review|check|list`: the registry repository's CI.
|
||||
#[cfg(feature = "full")]
|
||||
use horizon_mods::testing::{Script, TestGame};
|
||||
use horizon_mods::{
|
||||
Capability, Content, Manifest, Package,
|
||||
manifest::{MANIFEST, component_imports, componentize},
|
||||
testing::{Script, TestGame},
|
||||
};
|
||||
#[cfg(feature = "full")]
|
||||
mod check;
|
||||
#[cfg(feature = "full")]
|
||||
mod registry;
|
||||
|
||||
use std::{
|
||||
@@ -39,9 +42,16 @@ fn main() -> ExitCode {
|
||||
println!("Built {}", p.display());
|
||||
}),
|
||||
Some("run") => run(&args[1..]),
|
||||
#[cfg(feature = "full")]
|
||||
Some("test") => test(&args[1..]),
|
||||
#[cfg(feature = "full")]
|
||||
Some("check") => check(&args[1..]),
|
||||
#[cfg(feature = "full")]
|
||||
Some("registry") => registry::main(&args[1..]),
|
||||
#[cfg(not(feature = "full"))]
|
||||
Some("test" | "check" | "registry") => {
|
||||
Err("this cargo-horizon-mod was built without trial runs (feature `full`)".into())
|
||||
}
|
||||
_ => Err("usage: cargo horizon-mod new <path> [--template code|content] | build [--debug] | run [--game <horizon-client>] [-- <game args>] | test [--debug] [--hmod <file>] [<name>] | check <file> [--kind <kind>] [--key <public key> --signature <file.minisig>] [--json] | registry build|review|check|list".into()),
|
||||
};
|
||||
match result {
|
||||
@@ -249,6 +259,7 @@ fn compile(root: &Path, release: bool) -> Result<(Vec<u8>, PathBuf), String> {
|
||||
|
||||
/// `check <file>`: the registry's checks of a submission, printed; fails
|
||||
/// when one does.
|
||||
#[cfg(feature = "full")]
|
||||
fn check(args: &[String]) -> Result<(), String> {
|
||||
let file = args
|
||||
.first()
|
||||
@@ -280,6 +291,7 @@ fn check(args: &[String]) -> Result<(), String> {
|
||||
|
||||
/// `test`: every `tests/*.toml` script (those whose name holds `<name>`)
|
||||
/// against the built mod, or the `.hmod` given with `--hmod`.
|
||||
#[cfg(feature = "full")]
|
||||
fn test(args: &[String]) -> Result<(), String> {
|
||||
let hmod = match flag(args, "--hmod") {
|
||||
Some(p) => PathBuf::from(p),
|
||||
@@ -360,7 +372,7 @@ fn run(args: &[String]) -> Result<(), String> {
|
||||
.ok_or_else(|| format!("the game exited with {status}"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "full"))]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user