Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ examples/http/proxy
examples/http/poll_loop.py
examples/tcp/tcp.wasm
examples/tcp/command
examples/cli-p3/cli.wasm
examples/cli/cli.wasm
examples/cli/command
examples/sandbox/sandbox
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/cli-p3/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from wit_world import exports

class Run(exports.Run):
async def run(self):
async def run(self) -> None:
print("Hello, world!")
21 changes: 21 additions & 0 deletions tests/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ fn lint_cli_bindings() -> anyhow::Result<()> {
Ok(())
}

#[test]
fn lint_cli_p3_bindings() -> anyhow::Result<()> {
let dir = tempfile::tempdir()?;
fs_extra::copy_items(
&["./examples/cli-p3", "./wit"],
dir.path(),
&CopyOptions::new(),
)?;
let path = dir.path().join("cli-p3");

generate_bindings(&path, "wasi:cli/command@0.3.0-rc-2026-01-06")?;

assert!(predicate::path::is_dir().eval(&path.join("wit_world")));

_ = dir.keep();

mypy_check(&path, ["--strict", "-m", "app"]);

Ok(())
}

#[test]
fn lint_http_bindings() -> anyhow::Result<()> {
let dir = tempfile::tempdir()?;
Expand Down
17 changes: 13 additions & 4 deletions tests/componentize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,30 @@ use tar::Archive;

#[test]
fn cli_example() -> anyhow::Result<()> {
test_cli_example("cli", "wasi:cli/command@0.2.0")
}

#[test]
fn cli_p3_example() -> anyhow::Result<()> {
test_cli_example("cli-p3", "wasi:cli/command@0.3.0-rc-2026-01-06")
}

fn test_cli_example(name: &str, world: &str) -> anyhow::Result<()> {
let dir = tempfile::tempdir()?;
fs_extra::copy_items(
&["./examples/cli", "./wit"],
&[format!("./examples/{name}").as_str(), "./wit"],
dir.path(),
&CopyOptions::new(),
)?;
let path = dir.path().join("cli");
let path = dir.path().join(name);

cargo::cargo_bin_cmd!("componentize-py")
.current_dir(&path)
.args([
"-d",
"../wit",
"-w",
"wasi:cli/command@0.2.0",
world,
"componentize",
"app",
"-o",
Expand All @@ -40,7 +49,7 @@ fn cli_example() -> anyhow::Result<()> {

Command::new("wasmtime")
.current_dir(&path)
.args(["run", "cli.wasm"])
.args(["run", "-Sp3", "-Wcomponent-model-async", "cli.wasm"])
.assert()
.success()
.stdout("Hello, world!\n");
Expand Down