Skip to content

v0.1.0

Latest
Compare
Choose a tag to compare
@nilslice nilslice released this 22 May 22:04

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

New Contributors

Full Changelog: v0.0.2...v0.1.0