From f7f385a389dea5f54a98c85c2490465939120412 Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Wed, 11 May 2022 16:19:38 +0800 Subject: [PATCH] [WIP] Enable timers in Node.js environment --- Cargo.toml | 3 +++ tests/combine.rs | 20 ++++---------------- tests/concat.rs | 20 ++++---------------- tests/filter.rs | 10 ++-------- tests/flatten.rs | 25 +++++-------------------- tests/for_each.rs | 5 +---- tests/interval.rs | 15 +++------------ tests/map.rs | 10 ++-------- tests/merge.rs | 35 +++++++---------------------------- tests/scan.rs | 10 ++-------- tests/share.rs | 15 +++------------ tests/skip.rs | 20 ++++---------------- tests/take.rs | 15 +++------------ 13 files changed, 43 insertions(+), 160 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7a32564..b29704a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,3 +141,6 @@ required-features = ["skip"] [[test]] name = "take" required-features = ["take"] + +[patch.crates-io] +gloo-timers = { version = "0.2.4", git = "https://github.com/ctm/gloo", branch = "js_sys-experiment" } diff --git a/tests/combine.rs b/tests/combine.rs index eadff30..f78ae2e 100644 --- a/tests/combine.rs +++ b/tests/combine.rs @@ -50,10 +50,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_combines_1_async_finite_listenable_source() { @@ -158,10 +155,7 @@ async fn it_combines_1_async_finite_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_combines_2_async_finite_listenable_sources() { @@ -350,10 +344,7 @@ async fn it_combines_2_async_finite_listenable_sources() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() { @@ -475,10 +466,7 @@ async fn it_returns_a_source_that_disposes_upon_upwards_end() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_combines_two_infinite_listenable_sources() { diff --git a/tests/concat.rs b/tests/concat.rs index 84660d4..0765907 100644 --- a/tests/concat.rs +++ b/tests/concat.rs @@ -44,10 +44,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_concats_1_async_finite_listenable_source() { @@ -152,10 +149,7 @@ async fn it_concats_1_async_finite_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_concats_2_async_finite_listenable_sources() { @@ -530,10 +524,7 @@ fn it_concats_2_sync_finite_pullable_sources() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() { @@ -655,10 +646,7 @@ async fn it_returns_a_source_that_disposes_upon_upwards_end() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_propagates_source_error_to_sink_and_doesnt_subscribe_to_next_source() { diff --git a/tests/filter.rs b/tests/filter.rs index 857933b..7cd9274 100644 --- a/tests/filter.rs +++ b/tests/filter.rs @@ -164,10 +164,7 @@ fn it_filters_a_pullable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_filters_an_async_finite_listenable_source() { @@ -300,10 +297,7 @@ async fn it_filters_an_async_finite_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() { diff --git a/tests/flatten.rs b/tests/flatten.rs index 5fc2e3e..1b50178 100644 --- a/tests/flatten.rs +++ b/tests/flatten.rs @@ -50,10 +50,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_flattens_a_two_layer_async_infinite_listenable_sources() { @@ -460,10 +457,7 @@ fn it_flattens_a_two_layer_finite_pullable_sources() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_errors_sink_and_unsubscribe_from_inner_when_outer_throws() { @@ -671,10 +665,7 @@ async fn it_errors_sink_and_unsubscribe_from_inner_when_outer_throws() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_errors_sink_and_unsubscribe_from_outer_when_inner_throws() { @@ -869,10 +860,7 @@ async fn it_errors_sink_and_unsubscribe_from_outer_when_inner_throws() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_should_not_try_to_unsubscribe_from_completed_source_when_waiting_for_inner_completion() @@ -990,10 +978,7 @@ async fn it_should_not_try_to_unsubscribe_from_completed_source_when_waiting_for #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_should_not_try_to_unsubscribe_from_completed_source_when_for_inner_errors() { diff --git a/tests/for_each.rs b/tests/for_each.rs index 22b5e4c..372d8ad 100644 --- a/tests/for_each.rs +++ b/tests/for_each.rs @@ -137,10 +137,7 @@ fn it_iterates_a_finite_pullable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_observes_an_async_finite_listenable_source() { diff --git a/tests/interval.rs b/tests/interval.rs index 1cdf484..fc547b7 100644 --- a/tests/interval.rs +++ b/tests/interval.rs @@ -15,10 +15,7 @@ use { tracing_futures::Instrument, }; -#[cfg(all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", -))] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; #[cfg(all( all(target_arch = "wasm32", not(target_os = "wasi")), @@ -42,10 +39,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn interval_50_sends_5_times_then_we_dispose_it() { @@ -90,10 +84,7 @@ async fn interval_50_sends_5_times_then_we_dispose_it() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn interval_1000_can_be_disposed_before_anything_is_sent() { diff --git a/tests/map.rs b/tests/map.rs index cabab67..7a1055a 100644 --- a/tests/map.rs +++ b/tests/map.rs @@ -170,10 +170,7 @@ fn it_maps_a_pullable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_maps_an_async_finite_source() { @@ -312,10 +309,7 @@ async fn it_maps_an_async_finite_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() { diff --git a/tests/merge.rs b/tests/merge.rs index 368df97..85df706 100644 --- a/tests/merge.rs +++ b/tests/merge.rs @@ -48,10 +48,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_merges_one_async_finite_listenable_source() { @@ -156,10 +153,7 @@ async fn it_merges_one_async_finite_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_merges_two_async_finite_listenable_sources() { @@ -333,10 +327,7 @@ async fn it_merges_two_async_finite_listenable_sources() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() { @@ -458,10 +449,7 @@ async fn it_returns_a_source_that_disposes_upon_upwards_end() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_errors_when_one_of_the_sources_errors() { @@ -659,10 +647,7 @@ async fn it_errors_when_one_of_the_sources_errors() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_greets_the_sink_as_soon_as_the_first_member_source_greets() { @@ -810,10 +795,7 @@ async fn it_greets_the_sink_as_soon_as_the_first_member_source_greets() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_merges_sync_listenable_sources_resilient_to_greet_terminate_race_conditions_part_1() { @@ -937,10 +919,7 @@ async fn it_merges_sync_listenable_sources_resilient_to_greet_terminate_race_con #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_merges_sync_listenable_sources_resilient_to_greet_terminate_race_conditions_part_2() { diff --git a/tests/scan.rs b/tests/scan.rs index d946c5e..36350fe 100644 --- a/tests/scan.rs +++ b/tests/scan.rs @@ -170,10 +170,7 @@ fn it_scans_a_pullable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_scans_an_async_finite_listenable_source() { @@ -312,10 +309,7 @@ async fn it_scans_an_async_finite_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() { diff --git a/tests/share.rs b/tests/share.rs index 6dd012d..f21a214 100644 --- a/tests/share.rs +++ b/tests/share.rs @@ -47,10 +47,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_shares_an_async_finite_listenable_source() { @@ -226,10 +223,7 @@ async fn it_shares_an_async_finite_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_shares_a_pullable_source() { @@ -501,10 +495,7 @@ async fn it_shares_a_pullable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_disposes_only_when_last_sink_sends_upwards_end() { diff --git a/tests/skip.rs b/tests/skip.rs index 48f9c55..3745f4b 100644 --- a/tests/skip.rs +++ b/tests/skip.rs @@ -23,10 +23,7 @@ use { tracing_futures::Instrument, }; -#[cfg(all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", -))] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test; #[cfg(all( all(target_arch = "wasm32", not(target_os = "wasi")), @@ -50,10 +47,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_skips_from_a_pullable_source() { @@ -302,10 +296,7 @@ async fn it_skips_from_a_pullable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_skips_an_async_listenable_source() { @@ -465,10 +456,7 @@ async fn it_skips_an_async_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() { diff --git a/tests/take.rs b/tests/take.rs index 607e1de..a512faf 100644 --- a/tests/take.rs +++ b/tests/take.rs @@ -47,10 +47,7 @@ wasm_bindgen_test_configure!(run_in_browser); #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_takes_from_a_pullable_source() { @@ -287,10 +284,7 @@ async fn it_takes_from_a_pullable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_takes_an_async_listenable_source() { @@ -408,10 +402,7 @@ async fn it_takes_an_async_listenable_source() { #[tracing::instrument] #[test_log::test(async_std::test)] #[cfg_attr( - all( - all(target_arch = "wasm32", not(target_os = "wasi")), - feature = "browser", - ), + all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test )] async fn it_returns_a_source_that_disposes_upon_upwards_end() {