Skip to content

Commit 2920a8c

Browse files
authored
Migrate the other-dependencies test to wit-bindgen test (#1227)
This is a bit different from the other tests, it's mostly just a test for Rust's behavior of the `generate!` macro.
1 parent eeabd5e commit 2920a8c

File tree

10 files changed

+55
-42
lines changed

10 files changed

+55
-42
lines changed

crates/test-rust-wasm/src/bin/other-dependencies.rs

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

crates/test/src/rust.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ path = 'lib.rs'
157157
compile.output.with_extension("core.wasm")
158158
};
159159

160-
cmd.env("CARGO_MANIFEST_DIR", ".")
160+
let manifest_dir = compile.component.path.parent().unwrap();
161+
cmd.env("CARGO_MANIFEST_DIR", manifest_dir)
161162
.env(
162163
"BINDINGS",
163164
compile
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package other:test;
2+
3+
interface test {
4+
f: func();
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
wit_bindgen::generate!({
2+
inline: r#"
3+
package test:deps;
4+
5+
world test {
6+
import other:test/test;
7+
}
8+
"#,
9+
path: "./other.wit",
10+
with: {
11+
"other:test/test": generate,
12+
}
13+
});
14+
15+
fn main() {
16+
other::test::test::f();
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
wit_bindgen::generate!({
2+
inline: r#"
3+
package test:deps;
4+
5+
world test {
6+
export other:test/test;
7+
}
8+
"#,
9+
path: "./other.wit",
10+
with: {
11+
"other:test/test": generate,
12+
}
13+
});
14+
15+
use crate::exports::other::test::test::Guest;
16+
17+
struct Component;
18+
19+
export!(Component);
20+
21+
impl Guest for Component {
22+
fn f() {}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// note that this isn't actually used since the auto-generated bindings are
2+
// ignored and the `generate!` macro is customized for this test as it's
3+
// specifically testing behavior of the `generate!` macro.
4+
5+
package a:b;
6+
7+
world test {}
8+
world runner {}

tests/runtime/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use wit_parser::{Resolve, WorldId, WorldItem};
1515

1616
mod flavorful;
1717
mod options;
18-
mod other_dependencies;
1918
mod ownership;
2019
mod records;
2120
mod resource_alias;

tests/runtime/other-dependencies/other/world.wit

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

tests/runtime/other-dependencies/wasm.rs

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

tests/runtime/other_dependencies.rs

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

0 commit comments

Comments
 (0)