Skip to content

Commit b3adeb7

Browse files
authored
add cli-p3 test (#203)
* test `cli-p3` example Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> * add `cli-p3` Wasm to gitignore Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> * update `Cargo.lock` version Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> * cli-p3: add `-> None` Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> --------- Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 07d0afb commit b3adeb7

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ examples/http/proxy
1414
examples/http/poll_loop.py
1515
examples/tcp/tcp.wasm
1616
examples/tcp/command
17+
examples/cli-p3/cli.wasm
1718
examples/cli/cli.wasm
1819
examples/cli/command
1920
examples/sandbox/sandbox

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/cli-p3/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from wit_world import exports
22

33
class Run(exports.Run):
4-
async def run(self):
4+
async def run(self) -> None:
55
print("Hello, world!")

tests/bindings.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ fn lint_cli_bindings() -> anyhow::Result<()> {
2929
Ok(())
3030
}
3131

32+
#[test]
33+
fn lint_cli_p3_bindings() -> anyhow::Result<()> {
34+
let dir = tempfile::tempdir()?;
35+
fs_extra::copy_items(
36+
&["./examples/cli-p3", "./wit"],
37+
dir.path(),
38+
&CopyOptions::new(),
39+
)?;
40+
let path = dir.path().join("cli-p3");
41+
42+
generate_bindings(&path, "wasi:cli/command@0.3.0-rc-2026-01-06")?;
43+
44+
assert!(predicate::path::is_dir().eval(&path.join("wit_world")));
45+
46+
_ = dir.keep();
47+
48+
mypy_check(&path, ["--strict", "-m", "app"]);
49+
50+
Ok(())
51+
}
52+
3253
#[test]
3354
fn lint_http_bindings() -> anyhow::Result<()> {
3455
let dir = tempfile::tempdir()?;

tests/componentize.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,30 @@ use tar::Archive;
1414

1515
#[test]
1616
fn cli_example() -> anyhow::Result<()> {
17+
test_cli_example("cli", "wasi:cli/command@0.2.0")
18+
}
19+
20+
#[test]
21+
fn cli_p3_example() -> anyhow::Result<()> {
22+
test_cli_example("cli-p3", "wasi:cli/command@0.3.0-rc-2026-01-06")
23+
}
24+
25+
fn test_cli_example(name: &str, world: &str) -> anyhow::Result<()> {
1726
let dir = tempfile::tempdir()?;
1827
fs_extra::copy_items(
19-
&["./examples/cli", "./wit"],
28+
&[format!("./examples/{name}").as_str(), "./wit"],
2029
dir.path(),
2130
&CopyOptions::new(),
2231
)?;
23-
let path = dir.path().join("cli");
32+
let path = dir.path().join(name);
2433

2534
cargo::cargo_bin_cmd!("componentize-py")
2635
.current_dir(&path)
2736
.args([
2837
"-d",
2938
"../wit",
3039
"-w",
31-
"wasi:cli/command@0.2.0",
40+
world,
3241
"componentize",
3342
"app",
3443
"-o",
@@ -40,7 +49,7 @@ fn cli_example() -> anyhow::Result<()> {
4049

4150
Command::new("wasmtime")
4251
.current_dir(&path)
43-
.args(["run", "cli.wasm"])
52+
.args(["run", "-Sp3", "-Wcomponent-model-async", "cli.wasm"])
4453
.assert()
4554
.success()
4655
.stdout("Hello, world!\n");

0 commit comments

Comments
 (0)