File tree Expand file tree Collapse file tree 20 files changed +300
-0
lines changed
tests/runtime-async/async
future-cancel-write-then-read
future-close-after-coming-back
future-close-then-receive-read
future-write-then-read-comes-back
future-write-then-read-remote Expand file tree Collapse file tree 20 files changed +300
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,33 @@ jobs:
111
111
--artifacts target/artifacts \
112
112
--rust-wit-bindgen-path ./crates/guest-rust
113
113
114
+ # While we're working on getting wasip3-prototyping upstream in wasmtime
115
+ # itself run tests here in separate async job. Note that this job is NOT
116
+ # required for merging but it reports its status anyway to alert folks to at
117
+ # least the "big red X" status. The goal here is that this is known to be a
118
+ # bit unstable as the async foundations are shifting over time but this at
119
+ # least enables testing async things in this repository more easily.
120
+ async :
121
+ name : Test Async
122
+ runs-on : ubuntu-latest
123
+ steps :
124
+ - uses : actions/checkout@v4
125
+ with :
126
+ submodules : true
127
+ - name : Install Rust
128
+ run : rustup update stable --no-self-update && rustup default stable
129
+ - run : rustup target add wasm32-wasip1
130
+ - uses : ./.github/actions/install-wasi-sdk
131
+ - run : |
132
+ curl -L https://github.com/bytecodealliance/wasip3-prototyping/releases/download/dev/wasmtime-dev-x86_64-linux.tar.xz | tar xJvf -
133
+ echo "WASMTIME=`pwd`/wasmtime-dev-x86_64-linux/wasmtime" >> $GITHUB_ENV
134
+ - run : |
135
+ cargo run test --languages rust tests/runtime-async \
136
+ --artifacts target/artifacts \
137
+ --rust-wit-bindgen-path ./crates/guest-rust \
138
+ --rust-target wasm32-wasip1 \
139
+ --runner "$WASMTIME -W component-model-async"
140
+
114
141
test_unit :
115
142
name : Crate Unit Tests
116
143
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change
1
+ //@ args = '--async=-all'
2
+
3
+ include ! ( env!( "BINDINGS" ) ) ;
4
+
5
+ use crate :: a:: b:: the_test:: f;
6
+
7
+ fn main ( ) {
8
+ let ( tx, rx) = wit_future:: new ( ) ;
9
+
10
+ drop ( tx. write ( ( ) ) ) ;
11
+
12
+ f ( rx) ;
13
+ }
Original file line number Diff line number Diff line change
1
+ include ! ( env!( "BINDINGS" ) ) ;
2
+
3
+ struct Component ;
4
+
5
+ export ! ( Component ) ;
6
+
7
+ use crate :: exports:: a:: b:: the_test:: Guest ;
8
+
9
+ use wit_bindgen:: rt:: async_support:: FutureReader ;
10
+
11
+ impl Guest for Component {
12
+ async fn f ( future : FutureReader < ( ) > ) {
13
+ assert ! ( future. await . is_none( ) ) ;
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ package a : b ;
2
+
3
+ interface the-test {
4
+ f : async func (param : future );
5
+ }
6
+
7
+ world test {
8
+ export the-test ;
9
+ }
10
+ world runner {
11
+ import the-test ;
12
+ }
Original file line number Diff line number Diff line change
1
+ include ! ( env!( "BINDINGS" ) ) ;
2
+
3
+ use crate :: a:: b:: the_test:: f;
4
+
5
+ fn main ( ) {
6
+ let ( tx, rx) = wit_future:: new ( ) ;
7
+
8
+ let rx = f ( rx) ;
9
+ drop ( tx) ;
10
+ drop ( rx) ;
11
+ }
Original file line number Diff line number Diff line change
1
+ include ! ( env!( "BINDINGS" ) ) ;
2
+
3
+ struct Component ;
4
+
5
+ export ! ( Component ) ;
6
+
7
+ use crate :: exports:: a:: b:: the_test:: Guest ;
8
+
9
+ use wit_bindgen:: rt:: async_support:: FutureReader ;
10
+
11
+ impl Guest for Component {
12
+ fn f ( future : FutureReader < ( ) > ) -> FutureReader < ( ) > {
13
+ future
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ package a : b ;
2
+
3
+ interface the-test {
4
+ f : func (param : future ) -> future ;
5
+ }
6
+
7
+ world test {
8
+ export the-test ;
9
+ }
10
+ world runner {
11
+ import the-test ;
12
+ }
Original file line number Diff line number Diff line change
1
+ include ! ( env!( "BINDINGS" ) ) ;
2
+
3
+ use crate :: a:: b:: the_test:: { get, set} ;
4
+
5
+ fn main ( ) {
6
+ let ( tx, rx) = wit_future:: new ( ) ;
7
+
8
+ set ( rx) ;
9
+ let rx = get ( ) ;
10
+ drop ( tx) ;
11
+ drop ( rx) ;
12
+
13
+ wit_future:: new :: < ( ) > ( ) ;
14
+ }
Original file line number Diff line number Diff line change
1
+ include ! ( env!( "BINDINGS" ) ) ;
2
+
3
+ use crate :: exports:: a:: b:: the_test:: Guest ;
4
+ use std:: cell:: Cell ;
5
+ use wit_bindgen:: rt:: async_support:: FutureReader ;
6
+
7
+ struct Component ;
8
+
9
+ export ! ( Component ) ;
10
+
11
+ std:: thread_local!(
12
+ static SLOT : Cell <Option <FutureReader <( ) >>> = const { Cell :: new( None ) } ;
13
+ ) ;
14
+
15
+ impl Guest for Component {
16
+ fn set ( future : FutureReader < ( ) > ) {
17
+ SLOT . with ( |s| s. set ( Some ( future) ) ) ;
18
+ }
19
+ fn get ( ) -> FutureReader < ( ) > {
20
+ SLOT . with ( |s| s. replace ( None ) . unwrap ( ) )
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ package a : b ;
2
+
3
+ interface the-test {
4
+ set : func (param : future );
5
+ get : func () -> future ;
6
+ }
7
+
8
+ world test {
9
+ export the-test ;
10
+ }
11
+ world runner {
12
+ import the-test ;
13
+ }
You can’t perform that action at this time.
0 commit comments