The console reads a line, runs it to the end, and prints the result, with and without a terminal. Notifications print while a command runs. Ctrl-C during a command stops only the wait. 314 lines (was 480). All host integration tests are modules of cli/tests/host/, so they run in one parallel pool, and the probes build once. Warm, the 184 host tests take 24 s (was about 45 s as seven binaries in sequence), and cargo test --workspace takes 45 s.
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
//! Persistent caches and guest builds shared by the host integration modules.
|
|
use std::{
|
|
path::{Path, PathBuf},
|
|
sync::OnceLock,
|
|
};
|
|
|
|
pub const CACHE: &str = concat!(env!("CARGO_TARGET_TMPDIR"), "/cache");
|
|
|
|
pub fn build(package: &str, binary: &str) -> PathBuf {
|
|
let root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();
|
|
let target = Path::new(concat!(env!("CARGO_TARGET_TMPDIR"), "/guests"));
|
|
assert!(
|
|
std::process::Command::new("cargo")
|
|
.args([
|
|
"build",
|
|
"--offline",
|
|
"--target",
|
|
"wasm32-wasip2",
|
|
"--manifest-path"
|
|
])
|
|
.arg(root.join(package).join("Cargo.toml"))
|
|
.arg("--target-dir")
|
|
.arg(target)
|
|
.status()
|
|
.unwrap()
|
|
.success()
|
|
);
|
|
target
|
|
.join("wasm32-wasip2/debug")
|
|
.join(format!("{binary}.wasm"))
|
|
}
|
|
|
|
pub fn probe() -> PathBuf {
|
|
static WASM: OnceLock<PathBuf> = OnceLock::new();
|
|
WASM.get_or_init(|| build("cli/tests/plugins/probe", "probe"))
|
|
.clone()
|
|
}
|
|
|
|
pub fn sdk_probe() -> PathBuf {
|
|
static WASM: OnceLock<PathBuf> = OnceLock::new();
|
|
WASM.get_or_init(|| build("sdk/tests/plugins/probe", "sdk-probe"))
|
|
.clone()
|
|
}
|