Skip to main content

Module test_host

Module test_host 

Source
Expand description

In-memory host context for yosh-plugin run / yosh-plugin test.

Mirrors the precedent of metadata_extract::MetadataCtx: a self-contained wasmtime store data type with an empty WasiCtx plus per-capability yosh:plugin/* import implementations backed by TestState. Per-capability impls live in submodules.

See docs/superpowers/specs/2026-05-12-plugin-dev-test-runner-design.md §3 for the architectural rationale (third host context alongside HostContext and MetadataCtx).

Modules§

commands
In-memory yosh:plugin/commands host import — spawns real subprocesses, gated by CAP_COMMANDS_EXEC and an allowlist of CommandPattern (reused from yosh-plugin-api).
files
In-memory and sandboxed yosh:plugin/files host imports.
filesystem
In-memory yosh:plugin/filesystem host imports backed by TestState.cwd. Gated on CAP_FILESYSTEM. The cwd is virtual — changing it does not call std::env::set_current_dir.
io
In-memory yosh:plugin/io host import backed by TestState.stdout / TestState.stderr. Gated on CAP_IO.
variables
In-memory yosh:plugin/variables host imports backed by TestState.vars / TestState.exported. Gated on CAP_VARIABLES_READ and CAP_VARIABLES_WRITE.

Structs§

ExecRecord
Record of one external command spawn (commands:exec). One entry per host call, in invocation order.
TestCtx
Per-store wrapper. state is the shared in-memory backend; wasi is an empty WasiCtx to absorb cargo-component’s transitive WASI imports (same rationale as MetadataCtx §Sandboxing).
TestState
In-memory state behind every TestCtx host import. The runner constructs this from CLI flags or a scenario file, then reads it back after the guest call to format results / evaluate expectations.

Functions§

build_linker
Construct a Linker<TestCtx> with WASI registered. Per-capability yosh:plugin/* imports are added by register_imports (Task 9).
register_imports
Register every yosh:plugin/* import. The per-capability host functions enforce their own capability checks; the linker unconditionally points each WIT name at its real implementation.