Skip to content

Commit cf3a578

Browse files
committed
convert each #[test] in the futures-time files to a test-program and run it
i saw one flaky failure from debounce_no_debounces_hit thread 'main' panicked at test-programs/src/bin/debounce_no_debounces_hit.rs:17:5: assertion `left == right` failed left: 9 right: 10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace test debounce_no_debounces_hit ... FAILED test http_first_byte_timeout ... ok test tcp_echo_server ... ok test throttle_smoke ... ok failures: ---- debounce_no_debounces_hit stdout ---- testing /Users/pat/src/wstd/target/debug/build/test-programs-artifacts-208b828c32f0bad1/out/wasm32-wasip2/debug/debounce_no_debounces_hit.wasm entering wasm... Error: error while executing at wasm backtrace: 0: 0x21b54 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!__rust_start_panic 1: 0x219a2 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!rust_panic 2: 0x218d0 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!std::panicking::rust_panic_with_hook::h6e665b71c8f50b27 3: 0x20a0a - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!std::panicking::begin_panic_handler::{{closure}}::hb63ceb92de73cef0 4: 0x20970 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!std::sys::backtrace::__rust_end_short_backtrace::hf18948010daec5d9 5: 0x211ac - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!rust_begin_unwind 6: 0x26754 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!core::panicking::panic_fmt::h7916dc01f99baff2 7: 0x27d7d - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!core::panicking::assert_failed_inner::h636831bd2590e950 8: 0x16ca1 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!core::panicking::assert_failed::h0b25b4e081d12bca 9: 0x26b3 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!debounce_no_debounces_hit::main::__run::{{closure}}::hb8541acc2b0cb2ac 10: 0x28ac - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!debounce_no_debounces_hit::main::{{closure}}::h254a3ed57087816f 11: 0x2c2c - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!wstd::runtime::block_on::block_on::hb9ae51e568813b8f 12: 0x132f - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!debounce_no_debounces_hit::main::h5e51c8cbf2739770 13: 0x1fd4 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!core::ops::function::FnOnce::call_once::h755fe407d0481799 14: 0x3457 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!std::sys::backtrace::__rust_begin_short_backtrace::h89d457ff90c86c52 15: 0x33d0 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!std::rt::lang_start::{{closure}}::h062583bc0223ec5b 16: 0x1fc6a - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!std::rt::lang_start_internal::h00f1a3877f58021e 17: 0x336c - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!std::rt::lang_start::h365de7c23ff17921 18: 0x1383 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!__main_void 19: 0x1092 - debounce_no_debounces_hit-10b636a0d9796e1a.wasm!_start 20: 0x4f31af - wit-component:adapter:wasi_snapshot_preview1!wasi:cli/[email protected]#run note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information Caused by: wasm trap: wasm `unreachable` instruction executed failures: debounce_no_debounces_hit
1 parent e885063 commit cf3a578

File tree

8 files changed

+166
-0
lines changed

8 files changed

+166
-0
lines changed

test-programs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ edition = "2021"
55
publish = false
66

77
[dependencies]
8+
futures-lite.workspace = true
89
serde_json.workspace = true
910
wstd.workspace = true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use futures_lite::prelude::*;
2+
use wstd::prelude::*;
3+
use wstd::time::Duration;
4+
5+
#[wstd::main]
6+
async fn main() {
7+
let interval = Duration::from_millis(5);
8+
let buffer = Duration::from_millis(20);
9+
10+
let mut counter = 0;
11+
wstd::stream::interval(interval)
12+
.take(10)
13+
.buffer(buffer)
14+
.for_each(|buf| counter += buf.len())
15+
.await;
16+
17+
assert_eq!(counter, 10);
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use futures_lite::prelude::*;
2+
use wstd::prelude::*;
3+
use wstd::time::Duration;
4+
5+
#[wstd::main]
6+
async fn main() {
7+
let interval = Duration::from_millis(20);
8+
let buffer = Duration::from_millis(10);
9+
10+
let mut counter = 0;
11+
wstd::stream::interval(interval)
12+
.take(10)
13+
.buffer(buffer)
14+
.for_each(|buf| counter += buf.len())
15+
.await;
16+
17+
assert_eq!(counter, 10);
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use futures_lite::prelude::*;
2+
use wstd::prelude::*;
3+
use wstd::time::Duration;
4+
5+
#[wstd::main]
6+
async fn main() {
7+
let interval = Duration::from_millis(10);
8+
let debounce = Duration::from_millis(20);
9+
10+
let mut counter = 0;
11+
wstd::stream::interval(interval)
12+
.take(10)
13+
.debounce(debounce)
14+
.for_each(|_| counter += 1)
15+
.await;
16+
17+
assert_eq!(counter, 1);
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use futures_lite::prelude::*;
2+
use wstd::prelude::*;
3+
use wstd::time::Duration;
4+
5+
#[wstd::main]
6+
async fn main() {
7+
let interval = Duration::from_millis(40);
8+
let debounce = Duration::from_millis(10);
9+
10+
let mut counter = 0;
11+
wstd::stream::interval(interval)
12+
.take(10)
13+
.debounce(debounce)
14+
.for_each(|_| counter += 1)
15+
.await;
16+
17+
assert_eq!(counter, 10);
18+
}

test-programs/src/bin/sample_smoke.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use futures_lite::prelude::*;
2+
use wstd::prelude::*;
3+
use wstd::time::Duration;
4+
5+
#[wstd::main]
6+
async fn main() {
7+
let interval = Duration::from_millis(100);
8+
let throttle = Duration::from_millis(200);
9+
10+
let take = 4;
11+
let expected = 2;
12+
13+
let mut counter = 0;
14+
wstd::stream::interval(interval)
15+
.take(take)
16+
.sample(throttle)
17+
.for_each(|_| counter += 1)
18+
.await;
19+
20+
assert_eq!(counter, expected);
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
use futures_lite::prelude::*;
3+
use wstd::prelude::*;
4+
use wstd::time::Duration;
5+
6+
#[wstd::main]
7+
async fn main() {
8+
let interval = Duration::from_millis(100);
9+
let throttle = Duration::from_millis(300);
10+
11+
let take = 4;
12+
let expected = 2;
13+
14+
let mut counter = 0;
15+
wstd::stream::interval(interval)
16+
.take(take)
17+
.throttle(throttle)
18+
.for_each(|_| counter += 1)
19+
.await;
20+
21+
assert_eq!(counter, expected);
22+
}

tests/test-programs.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,53 @@ fn http_first_byte_timeout() -> Result<()> {
144144
std::fs::read(test_programs_artifacts::HTTP_FIRST_BYTE_TIMEOUT).context("read wasm")?;
145145
run_in_wasmtime(&wasm, None)
146146
}
147+
148+
#[test]
149+
fn buffer_all_values() -> Result<()> {
150+
println!("testing {}", test_programs_artifacts::BUFFER_ALL_VALUES);
151+
let wasm = std::fs::read(test_programs_artifacts::BUFFER_ALL_VALUES).context("read wasm")?;
152+
run_in_wasmtime(&wasm, None)
153+
}
154+
155+
#[test]
156+
fn buffer_no_debounces_hit() -> Result<()> {
157+
println!(
158+
"testing {}",
159+
test_programs_artifacts::BUFFER_NO_DEBOUNCES_HIT
160+
);
161+
let wasm =
162+
std::fs::read(test_programs_artifacts::BUFFER_NO_DEBOUNCES_HIT).context("read wasm")?;
163+
run_in_wasmtime(&wasm, None)
164+
}
165+
166+
#[test]
167+
fn debounce_all_values() -> Result<()> {
168+
println!("testing {}", test_programs_artifacts::DEBOUNCE_ALL_VALUES);
169+
let wasm = std::fs::read(test_programs_artifacts::DEBOUNCE_ALL_VALUES).context("read wasm")?;
170+
run_in_wasmtime(&wasm, None)
171+
}
172+
173+
#[test]
174+
fn debounce_no_debounces_hit() -> Result<()> {
175+
println!(
176+
"testing {}",
177+
test_programs_artifacts::DEBOUNCE_NO_DEBOUNCES_HIT
178+
);
179+
let wasm =
180+
std::fs::read(test_programs_artifacts::DEBOUNCE_NO_DEBOUNCES_HIT).context("read wasm")?;
181+
run_in_wasmtime(&wasm, None)
182+
}
183+
184+
#[test]
185+
fn sample_smoke() -> Result<()> {
186+
println!("testing {}", test_programs_artifacts::SAMPLE_SMOKE);
187+
let wasm = std::fs::read(test_programs_artifacts::SAMPLE_SMOKE).context("read wasm")?;
188+
run_in_wasmtime(&wasm, None)
189+
}
190+
191+
#[test]
192+
fn throttle_smoke() -> Result<()> {
193+
println!("testing {}", test_programs_artifacts::THROTTLE_SMOKE);
194+
let wasm = std::fs::read(test_programs_artifacts::THROTTLE_SMOKE).context("read wasm")?;
195+
run_in_wasmtime(&wasm, None)
196+
}

0 commit comments

Comments
 (0)