The Nix package, the dev shell, and the test check set CC_wasm32_wasip2 and AR_wasm32_wasip2 to the clang of pkgsCross.wasi32 (wasi-libc), so build scripts with the cc crate work, for example rusqlite with bundled SQLite. The runtime-toolchain check links C into a probe with the packaged host and an empty PATH.
This commit is contained in:
@@ -769,6 +769,22 @@ async fn cargo_actor_runs_unit_tests_by_default_and_can_skip_them() {
|
||||
host.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cargo_actor_compiles_c_code_for_wasi() {
|
||||
let world = create_world("cargo-c");
|
||||
let (host, mut mailbox) = start(&world).await;
|
||||
let source = cargo_source("cargo-c");
|
||||
let id = host.broker.send("console", Some("cargo"), None, None, json!({"type": "build", "source": source.display().to_string()}));
|
||||
let built = receive_reply(&mut mailbox, &id, Duration::from_secs(300)).await;
|
||||
assert_eq!(built.body["type"], "built", "{built:?}");
|
||||
assert_eq!(built.body["tests"]["passed"], 1, "{built:?}");
|
||||
let wasm = host.world.resolve("console", built.body["wasm"].as_str().unwrap()).unwrap();
|
||||
spawn_type(&host, &mut mailbox, "c-add", &wasm, &source).await;
|
||||
let sum = ask_type(&host, &mut mailbox, "c-add", json!({"type": "add", "a": 2, "b": 3}), "sum").await;
|
||||
assert_eq!(sum.body["value"], 5);
|
||||
host.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rejects_invalid_actor_ids() {
|
||||
let world = create_world("invalid-id");
|
||||
|
||||
Reference in New Issue
Block a user