Skip to content

Commit 84c1a25

Browse files
committed
Specify extra runtime flags in tests, not CI
This enables keeping runtime/wasmtime flags scoped to just one test rather than requiring it for all tests. For example `-Wcomponent-model-threading` is scoped to just one test right now.
1 parent 90b5013 commit 84c1a25

File tree

48 files changed

+114
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+114
-17
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ jobs:
160160
- run: |
161161
cargo run test --languages rust,c,go tests/runtime-async \
162162
--artifacts target/artifacts \
163-
--rust-wit-bindgen-path ./crates/guest-rust \
164-
--runner "wasmtime -W component-model-async -W component-model-threading -W component-model-async-stackful"
163+
--rust-wit-bindgen-path ./crates/guest-rust
165164
166165
test_unit:
167166
name: Crate Unit Tests

crates/test/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ pub struct RuntimeTestConfig<T = HashMap<String, toml::Value>> {
6464
#[serde(default)]
6565
pub args: StringList,
6666

67+
/// Extra command line arguments to to pass to Wasmtime, such as enabling
68+
/// extra wasm features.
69+
#[serde(default)]
70+
pub wasmtime_flags: StringList,
71+
6772
/// Language-specific configuration
6873
//
6974
// Note that this is an `Option<T>` where `T` defaults to a catch-all hash

crates/test/src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ struct Component {
193193

194194
/// The contents of the test file itself.
195195
lang_config: Option<HashMap<String, toml::Value>>,
196+
197+
/// Runtime flags to wasmtime.
198+
wasmtime_flags: config::StringList,
196199
}
197200

198201
#[derive(Clone)]
@@ -467,6 +470,7 @@ impl Runner {
467470
kind,
468471
contents,
469472
lang_config: config.lang,
473+
wasmtime_flags: config.wasmtime_flags,
470474
})
471475
}
472476

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

914-
self.run_command(self.test_runner.command().arg(&composed_wasm))?;
918+
let mut cmd = self.test_runner.command();
919+
for component in [runner]
920+
.into_iter()
921+
.chain(test_components.iter().map(|(c, _)| *c))
922+
{
923+
for flag in Vec::from(component.wasmtime_flags.clone()) {
924+
cmd.arg(flag);
925+
}
926+
}
927+
cmd.arg(&composed_wasm);
928+
self.run_command(&mut cmd)?;
915929
Ok(())
916930
}
917931

tests/runtime-async/async/cancel-import/runner.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ args = '--rename my:test/i=test --async=-run'
2+
//@ wasmtime-flags = '-Wcomponent-model-async'
23

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

tests/runtime-async/async/cancel-import/runner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ wasmtime-flags = '-Wcomponent-model-async'
2+
13
include!(env!("BINDINGS"));
24

35
use crate::my::test::i::*;

tests/runtime-async/async/future-cancel-read/runner.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ args = '--rename my:test/i=test --async=-run'
2+
//@ wasmtime-flags = '-Wcomponent-model-async'
23

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

tests/runtime-async/async/future-cancel-read/runner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ wasmtime-flags = '-Wcomponent-model-async'
2+
13
include!(env!("BINDINGS"));
24

35
use crate::my::test::i::*;

tests/runtime-async/async/future-cancel-write-then-read/runner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ wasmtime-flags = '-Wcomponent-model-async'
2+
13
include!(env!("BINDINGS"));
24

35
use crate::a::b::the_test::f;

tests/runtime-async/async/future-cancel-write/runner.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ args = '--rename my:test/i=test --async=-run'
2+
//@ wasmtime-flags = '-Wcomponent-model-async'
23

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

tests/runtime-async/async/future-cancel-write/runner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ wasmtime-flags = '-Wcomponent-model-async'
2+
13
include!(env!("BINDINGS"));
24

35
use crate::my::test::i::{read_and_drop, take_then_drop};

0 commit comments

Comments
 (0)