Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ jobs:
- run: |
cargo run test --languages rust,c,go tests/runtime-async \
--artifacts target/artifacts \
--rust-wit-bindgen-path ./crates/guest-rust \
--runner "wasmtime -W component-model-async -W component-model-threading -W component-model-async-stackful"
--rust-wit-bindgen-path ./crates/guest-rust

test_unit:
name: Crate Unit Tests
Expand Down
5 changes: 5 additions & 0 deletions crates/test/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ pub struct RuntimeTestConfig<T = HashMap<String, toml::Value>> {
#[serde(default)]
pub args: StringList,

/// Extra command line arguments to to pass to Wasmtime, such as enabling
/// extra wasm features.
#[serde(default)]
pub wasmtime_flags: StringList,

/// Language-specific configuration
//
// Note that this is an `Option<T>` where `T` defaults to a catch-all hash
Expand Down
7 changes: 3 additions & 4 deletions crates/test/src/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ impl LanguageMethods for Go {

fn package_name(package: &str) -> &str {
package
.split_once('\n')
.unwrap()
.0
.strip_prefix("package ")
.lines()
.filter_map(|l| l.strip_prefix("package "))
.next()
.unwrap()
.trim()
}
Expand Down
16 changes: 15 additions & 1 deletion crates/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ struct Component {

/// The contents of the test file itself.
lang_config: Option<HashMap<String, toml::Value>>,

/// Runtime flags to wasmtime.
wasmtime_flags: config::StringList,
}

#[derive(Clone)]
Expand Down Expand Up @@ -467,6 +470,7 @@ impl Runner {
kind,
contents,
lang_config: config.lang,
wasmtime_flags: config.wasmtime_flags,
})
}

Expand Down Expand Up @@ -911,7 +915,17 @@ impl Runner {
let composed_wasm = dst.join(filename);
write_if_different(&composed_wasm, &composed)?;

self.run_command(self.test_runner.command().arg(&composed_wasm))?;
let mut cmd = self.test_runner.command();
for component in [runner]
.into_iter()
.chain(test_components.iter().map(|(c, _)| c))
{
for flag in Vec::from(component.wasmtime_flags.clone()) {
cmd.arg(flag);
}
}
cmd.arg(&composed_wasm);
self.run_command(&mut cmd)?;
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/cancel-import/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/cancel-import/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::*;
Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/future-cancel-read/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/future-cancel-read/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::a::b::the_test::f;
Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/future-cancel-write/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/future-cancel-write/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::{read_and_drop, take_then_drop};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::a::b::the_test::f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::a::b::the_test::{get, set};
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/future-closes-with-error/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::a::b::the_test::f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::a::b::the_test::f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--async=-all'
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--async=-all'
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/incomplete-writes/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import (
Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/pending-import/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/pending-import/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::*;
Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/ping-pong/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <string.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/ping-pong/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/ping-pong/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::{ping, pong};
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/rust-cross-task-wakeup/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/rust-lowered-send/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::a::b::i::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-call-import/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ args = '--rename a:b/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>

Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-call-import/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import test "wit_component/a_b_i"
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-call-import/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

struct Component;
Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/simple-future/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <runner.h>
#include <assert.h>
Expand Down
6 changes: 4 additions & 2 deletions tests/runtime-async/async/simple-future/runner.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
Expand Down Expand Up @@ -29,7 +31,7 @@ public static Task Run()

writer.Dispose();
set.Dispose();
}
}

{
var (reader, writer) = IIImports.FutureNew();
Expand Down Expand Up @@ -61,4 +63,4 @@ public static int RunCallback()
{
throw new NotImplementedException();
}
}
}
14 changes: 8 additions & 6 deletions tests/runtime-async/async/simple-future/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import (
Expand Down Expand Up @@ -54,9 +56,9 @@ func Run() {
close(syncBarrier)

go func() {
// If this is omitted, the host will see that the "rx.Read" operations aren't paired with
// a "tx.Write" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// If this is omitted, the host will see that the "rx.Read" operations aren't paired with
// a "tx.Write" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// concurrent reads, and not from other scenarios that result in a nil handle.
tx.Write(wit_types.Unit{})
}()
Expand Down Expand Up @@ -85,9 +87,9 @@ func Run() {
close(syncBarrier)

go func() {
// If this is omitted, the host will see that the "tx.Write" operations aren't paired with
// an "rx.Read" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// If this is omitted, the host will see that the "tx.Write" operations aren't paired with
// an "rx.Read" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// concurrent writes, and not from other scenarios that result in a nil handle.
rx.Read()
}()
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-future/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename a:b/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::a::b::i::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-pending-import/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ args = '--rename a:b/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>

Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-pending-import/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import test "wit_component/a_b_i"
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-pending-import/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

struct Component;
Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/simple-stream-payload/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <runner.h>
#include <assert.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-stream-payload/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import (
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-stream-payload/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::*;
Expand Down
1 change: 1 addition & 0 deletions tests/runtime-async/async/simple-stream/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ args = '--rename my:test/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <runner.h>
#include <assert.h>
Expand Down
14 changes: 8 additions & 6 deletions tests/runtime-async/async/simple-stream/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

package export_wit_world

import (
Expand Down Expand Up @@ -53,9 +55,9 @@ func Run() {
close(syncBarrier)

go func() {
// If this is omitted, the host will see that the "rx.Read" operations aren't paired with
// a "tx.WriteAll" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// If this is omitted, the host will see that the "rx.Read" operations aren't paired with
// a "tx.WriteAll" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// concurrent reads, and not from other scenarios that result in a nil handle.
tx.WriteAll([]wit_types.Unit{wit_types.Unit{}})
}()
Expand Down Expand Up @@ -84,9 +86,9 @@ func Run() {
close(syncBarrier)

go func() {
// If this is omitted, the host will see that the "tx.WriteAll" operations aren't paired with
// an "rx.Read" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// If this is omitted, the host will see that the "tx.WriteAll" operations aren't paired with
// an "rx.Read" and will result in a "wasm trap: deadlock detected" error. Additionally,
// this is placed after "close(syncBarrier)" to ensure that the panics are resulting from
// concurrent writes, and not from other scenarios that result in a nil handle.
result := make([]wit_types.Unit, 1)
rx.Read(result)
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-stream/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ wasmtime-flags = '-Wcomponent-model-async'

include!(env!("BINDINGS"));

use crate::my::test::i::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/runtime-async/async/simple-yield/runner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ args = '--rename a:b/i=test --async=-run'
//@ wasmtime-flags = '-Wcomponent-model-async'

#include <assert.h>
#include <runner.h>

Expand Down
Loading
Loading