Skip to content

Commit 70b7aeb

Browse files
authored
Migrate type_section_suffix test to wit-bindgen test (#1228)
This is a rust-specific test to put it in the `rust` folder and shuffle around some definitions/things to modernize syntax (put all the WITs into one file) and work around limitations of `wasm-compose` (no top-level functions).
1 parent 761ef55 commit 70b7aeb

File tree

11 files changed

+95
-114
lines changed

11 files changed

+95
-114
lines changed

crates/test-rust-wasm/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ test = false
8080
name = "resource_borrow_simple"
8181
test = false
8282

83-
[[bin]]
84-
name = "type_section_suffix"
85-
test = false
86-
8783
[[bin]]
8884
name = "rust_xcrate"
8985
test = false

crates/test-rust-wasm/src/bin/type_section_suffix.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
include!(env!("BINDINGS"));
2+
3+
// generate bindings once here
4+
mod a {
5+
wit_bindgen::generate!({
6+
world: "available-imports",
7+
path: "./test.wit",
8+
generate_all,
9+
});
10+
}
11+
12+
// generate bindings again for the same world, this time using a different
13+
// suffix
14+
mod b {
15+
wit_bindgen::generate!({
16+
world: "available-imports",
17+
path: "./test.wit",
18+
type_section_suffix: "hello i am a suffix how are you doing today",
19+
generate_all,
20+
});
21+
}
22+
23+
mod c {
24+
wit_bindgen::generate!({
25+
world: "test:a/imports",
26+
path: "./test.wit",
27+
});
28+
}
29+
mod d {
30+
wit_bindgen::generate!({
31+
world: "test:b/imports",
32+
path: "./test.wit",
33+
});
34+
}
35+
36+
fn main() {
37+
a::test::suffix::imports::foo();
38+
b::test::suffix::imports::foo();
39+
c::foo::f();
40+
d::bar::f();
41+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
include!(env!("BINDINGS"));
2+
3+
struct Component;
4+
5+
export!(Component);
6+
7+
impl exports::bar::Guest for Component {
8+
fn f() {}
9+
}
10+
11+
impl exports::foo::Guest for Component {
12+
fn f() {}
13+
}
14+
15+
impl exports::test::suffix::imports::Guest for Component {
16+
fn foo() {}
17+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package test:suffix;
2+
3+
interface imports {
4+
foo: func();
5+
}
6+
7+
world available-imports {
8+
import imports;
9+
include test:a/imports;
10+
include test:b/imports;
11+
}
12+
13+
world runner {
14+
include available-imports;
15+
}
16+
17+
world test {
18+
export imports;
19+
export foo: interface { f: func(); }
20+
export bar: interface { f: func(); }
21+
}
22+
23+
package test:a {
24+
world imports {
25+
import foo: interface {
26+
f: func();
27+
}
28+
}
29+
}
30+
31+
package test:b {
32+
world imports {
33+
import bar: interface {
34+
f: func();
35+
}
36+
}
37+
}

tests/runtime/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mod resource_with_lists;
2929
mod resources;
3030
mod results;
3131
mod rust_xcrate;
32-
mod type_section_suffix;
3332
mod variants;
3433
mod versions;
3534

tests/runtime/type_section_suffix.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/runtime/type_section_suffix/deps/a.wit

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/runtime/type_section_suffix/deps/b.wit

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/runtime/type_section_suffix/wasm.rs

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)