Note
Zig Version Update 0.13
This release updates the Zig version to 0.13, as our current release strategy is to closely follow the latest Zig progress.
🚢 New feature: Mock Input
Configure your test with dynamic input provided by a CLI or xtp.toml
file. Read runtime-provided input that mocks the actual input when a plugin is called:
export fn @"test"() i32 {
const xtp_test = Test.init(std.heap.wasm_allocator);
const not_empty = xtp_test.call("count_vowels", xtp_test.mockInput() orelse "") catch unreachable;
xtp_test.assert("with mock, not empty", !std.mem.eql(u8, not_empty, ""), "expected non-empty string");
// ...
}
CLI supports args --mock-input-data
and --mock-input-file
to pass text or load a file.
xtp.toml
supports syntax such as:
bin = "https://raw.githubusercontent.com/extism/extism/main/wasm/code.wasm"
[[test]]
name = "basic"
build = "zig build basic_test"
with = "zig-out/bin/basic-test.wasm"
mock_input = { data = "this is my mock input data" }
[[test]]
name = "basic - file input"
build = "zig build basic_test"
with = "zig-out/bin/basic-test.wasm"
mock_input = { file = "examples/basic/basic.zig" }
Usage in tests
The xtp-test-zig
library provides mockInput()
and mockInputJson()
functions to dynamically read input from the host, mocked out by the supported options above.
(see examples used in examples/basic
and examples/json
)
Update your XTP CLI
xtp self update
To install the latest version of `xtp`, run:
curl https://static.dylibso.com/cli/install.sh | sudo sh
What's Changed
- feat: add support for mock input by @zshipko in #2
- feat: add mock input json helper by @nilslice in #3
New Contributors
Full Changelog: v0.0.2...v0.1.0