Skip to content

Commit

Permalink
Replace use of tokio_wasm in tests with target_family = "wasm"
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Jul 22, 2023
1 parent 13563a4 commit 1d1e5e2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tokio/tests/_require_full.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(not(any(feature = "full", tokio_wasm)))]
#[cfg(not(any(feature = "full", target_family = "wasm")))]
compile_error!("run main Tokio tests with `--features full`");

// CI sets `--cfg tokio_no_parking_lot` when trying to run tests with
Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/sync_broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ fn send_no_rx() {

#[test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn zero_capacity() {
broadcast::channel::<()>(0);
}

#[test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn capacity_too_big() {
use std::usize;

Expand All @@ -292,7 +292,7 @@ fn capacity_too_big() {

#[test]
#[cfg(panic = "unwind")]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn panic_in_clone() {
use std::panic::{self, AssertUnwindSafe};

Expand Down
10 changes: 5 additions & 5 deletions tokio/tests/sync_mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tokio::sync::mpsc::error::{TryRecvError, TrySendError};
use tokio::test as maybe_tokio_test;
use tokio_test::*;

#[cfg(not(tokio_wasm))]
#[cfg(not(target_family = "wasm"))]
mod support {
pub(crate) mod mpsc_stream;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ async fn start_send_past_cap() {

#[test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn buffer_gteq_one() {
mpsc::channel::<i32>(0);
}
Expand Down Expand Up @@ -470,7 +470,7 @@ fn blocking_recv() {

#[tokio::test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
async fn blocking_recv_async() {
let (_tx, mut rx) = mpsc::channel::<()>(1);
let _ = rx.blocking_recv();
Expand All @@ -495,7 +495,7 @@ fn blocking_send() {

#[tokio::test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
async fn blocking_send_async() {
let (tx, _rx) = mpsc::channel::<()>(1);
let _ = tx.blocking_send(());
Expand Down Expand Up @@ -648,7 +648,7 @@ async fn recv_timeout() {

#[test]
#[should_panic = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn recv_timeout_panic() {
use futures::future::FutureExt;
use tokio::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/sync_oneshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn explicit_close_try_recv() {

#[test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn close_try_recv_poll() {
let (_tx, rx) = oneshot::channel::<i32>();
let mut rx = task::spawn(rx);
Expand Down
8 changes: 4 additions & 4 deletions tokio/tests/sync_semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn merge() {
}

#[test]
#[cfg(not(tokio_wasm))] // No stack unwinding on wasm targets
#[cfg(not(target_family = "wasm"))] // No stack unwinding on wasm targets
#[should_panic]
fn merge_unrelated_permits() {
let sem1 = Arc::new(Semaphore::new(3));
Expand Down Expand Up @@ -118,15 +118,15 @@ fn add_max_amount_permits() {
assert_eq!(s.available_permits(), tokio::sync::Semaphore::MAX_PERMITS);
}

#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
#[test]
#[should_panic]
fn add_more_than_max_amount_permits1() {
let s = tokio::sync::Semaphore::new(1);
s.add_permits(tokio::sync::Semaphore::MAX_PERMITS);
}

#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
#[test]
#[should_panic]
fn add_more_than_max_amount_permits2() {
Expand All @@ -135,7 +135,7 @@ fn add_more_than_max_amount_permits2() {
s.add_permits(1);
}

#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
#[test]
#[should_panic]
fn panic_when_exceeds_maxpermits() {
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/sync_semaphore_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn merge() {
}

#[test]
#[cfg(not(tokio_wasm))] // No stack unwinding on wasm targets
#[cfg(not(target_family = "wasm"))] // No stack unwinding on wasm targets
#[should_panic]
fn merge_unrelated_permits() {
let sem1 = Arc::new(Semaphore::new(3));
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/sync_watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fn reopened_after_subscribe() {

#[test]
#[cfg(panic = "unwind")]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn send_modify_panic() {
let (tx, mut rx) = watch::channel("one");

Expand Down

0 comments on commit 1d1e5e2

Please sign in to comment.