diff --git a/.gitignore b/.gitignore index d59c72e..5acc1bb 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Cargo.lock b/Cargo.lock index 8bfb5fe..fe89d03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,7 +477,7 @@ dependencies = [ [[package]] name = "componentize-py" -version = "0.20.0" +version = "0.21.0" dependencies = [ "anyhow", "assert_cmd", diff --git a/examples/cli-p3/app.py b/examples/cli-p3/app.py index fd4184e..caf22c7 100644 --- a/examples/cli-p3/app.py +++ b/examples/cli-p3/app.py @@ -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!") diff --git a/tests/bindings.rs b/tests/bindings.rs index 2b583d8..51e92db 100644 --- a/tests/bindings.rs +++ b/tests/bindings.rs @@ -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()?; diff --git a/tests/componentize.rs b/tests/componentize.rs index e1fa63c..383b405 100644 --- a/tests/componentize.rs +++ b/tests/componentize.rs @@ -14,13 +14,22 @@ 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) @@ -28,7 +37,7 @@ fn cli_example() -> anyhow::Result<()> { "-d", "../wit", "-w", - "wasi:cli/command@0.2.0", + world, "componentize", "app", "-o", @@ -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");