diff --git a/tokio/src/runtime/coop.rs b/tokio/src/runtime/coop.rs index d94b940d475..15a4d98c08d 100644 --- a/tokio/src/runtime/coop.rs +++ b/tokio/src/runtime/coop.rs @@ -246,18 +246,14 @@ cfg_coop! { mod test { use super::*; - cfg_is_wasm_not_wasi! { - use wasm_bindgen_test::wasm_bindgen_test as test; - } - - #[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] - use std::prelude::v1::test; + #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] + use wasm_bindgen_test::wasm_bindgen_test as test; fn get() -> Budget { context::budget(|cell| cell.get()).unwrap_or(Budget::unconstrained()) } - #[self::test] + #[test] fn budgeting() { use futures::future::poll_fn; use tokio_test::*; diff --git a/tokio/src/sync/tests/atomic_waker.rs b/tokio/src/sync/tests/atomic_waker.rs index acd81ac0656..989175a53a9 100644 --- a/tokio/src/sync/tests/atomic_waker.rs +++ b/tokio/src/sync/tests/atomic_waker.rs @@ -12,14 +12,10 @@ impl AssertSync for AtomicWaker {} impl AssertSend for Waker {} impl AssertSync for Waker {} -cfg_is_wasm_not_wasi! { - use wasm_bindgen_test::wasm_bindgen_test as test; -} - -#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] -use std::prelude::v1::test; +#[cfg(all(target_family = "wasm", not(target_os = "wasi")))] +use wasm_bindgen_test::wasm_bindgen_test as test; -#[self::test] +#[test] fn basic_usage() { let mut waker = task::spawn(AtomicWaker::new()); @@ -29,7 +25,7 @@ fn basic_usage() { assert!(waker.is_woken()); } -#[self::test] +#[test] fn wake_without_register() { let mut waker = task::spawn(AtomicWaker::new()); waker.wake(); @@ -40,7 +36,7 @@ fn wake_without_register() { assert!(!waker.is_woken()); } -#[self::test] +#[test] #[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding fn atomic_waker_panic_safe() { use std::panic; diff --git a/tokio/src/sync/tests/notify.rs b/tokio/src/sync/tests/notify.rs index 3b48bd8929d..323b5c65ae3 100644 --- a/tokio/src/sync/tests/notify.rs +++ b/tokio/src/sync/tests/notify.rs @@ -3,14 +3,10 @@ use std::future::Future; use std::sync::Arc; use std::task::{Context, RawWaker, RawWakerVTable, Waker}; -cfg_is_wasm_not_wasi! { - use wasm_bindgen_test::wasm_bindgen_test as test; -} - -#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] -use std::prelude::v1::test; +#[cfg(all(target_family = "wasm", not(target_os = "wasi")))] +use wasm_bindgen_test::wasm_bindgen_test as test; -#[self::test] +#[test] fn notify_clones_waker_before_lock() { const VTABLE: &RawWakerVTable = &RawWakerVTable::new(clone_w, wake, wake_by_ref, drop_w); @@ -50,7 +46,7 @@ fn notify_clones_waker_before_lock() { } #[cfg(panic = "unwind")] -#[self::test] +#[test] fn notify_waiters_handles_panicking_waker() { use futures::task::ArcWake; @@ -88,7 +84,7 @@ fn notify_waiters_handles_panicking_waker() { } } -#[self::test] +#[test] fn notify_simple() { let notify = Notify::new(); @@ -104,7 +100,7 @@ fn notify_simple() { assert!(fut2.poll().is_ready()); } -#[self::test] +#[test] #[cfg(not(target_family = "wasm"))] fn watch_test() { let rt = crate::runtime::Builder::new_current_thread() diff --git a/tokio/src/sync/tests/semaphore_batch.rs b/tokio/src/sync/tests/semaphore_batch.rs index 6c8fd2f74c6..391797b3f66 100644 --- a/tokio/src/sync/tests/semaphore_batch.rs +++ b/tokio/src/sync/tests/semaphore_batch.rs @@ -3,14 +3,10 @@ use tokio_test::*; const MAX_PERMITS: usize = crate::sync::Semaphore::MAX_PERMITS; -cfg_is_wasm_not_wasi! { - use wasm_bindgen_test::wasm_bindgen_test as test; -} - -#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] -use std::prelude::v1::test; +#[cfg(all(target_family = "wasm", not(target_os = "wasi")))] +use wasm_bindgen_test::wasm_bindgen_test as test; -#[self::test] +#[test] fn poll_acquire_one_available() { let s = Semaphore::new(100); assert_eq!(s.available_permits(), 100); @@ -20,7 +16,7 @@ fn poll_acquire_one_available() { assert_eq!(s.available_permits(), 99); } -#[self::test] +#[test] fn poll_acquire_many_available() { let s = Semaphore::new(100); assert_eq!(s.available_permits(), 100); @@ -33,7 +29,7 @@ fn poll_acquire_many_available() { assert_eq!(s.available_permits(), 90); } -#[self::test] +#[test] fn try_acquire_one_available() { let s = Semaphore::new(100); assert_eq!(s.available_permits(), 100); @@ -45,7 +41,7 @@ fn try_acquire_one_available() { assert_eq!(s.available_permits(), 98); } -#[self::test] +#[test] fn try_acquire_many_available() { let s = Semaphore::new(100); assert_eq!(s.available_permits(), 100); @@ -57,7 +53,7 @@ fn try_acquire_many_available() { assert_eq!(s.available_permits(), 90); } -#[self::test] +#[test] fn poll_acquire_one_unavailable() { let s = Semaphore::new(1); @@ -81,7 +77,7 @@ fn poll_acquire_one_unavailable() { assert_eq!(s.available_permits(), 1); } -#[self::test] +#[test] fn poll_acquire_many_unavailable() { let s = Semaphore::new(5); @@ -118,7 +114,7 @@ fn poll_acquire_many_unavailable() { assert_ready_ok!(acquire_3.poll()); } -#[self::test] +#[test] fn try_acquire_one_unavailable() { let s = Semaphore::new(1); @@ -137,7 +133,7 @@ fn try_acquire_one_unavailable() { assert_eq!(s.available_permits(), 1); } -#[self::test] +#[test] fn try_acquire_many_unavailable() { let s = Semaphore::new(5); @@ -159,7 +155,7 @@ fn try_acquire_many_unavailable() { assert_eq!(s.available_permits(), 2); } -#[self::test] +#[test] fn poll_acquire_one_zero_permits() { let s = Semaphore::new(0); assert_eq!(s.available_permits(), 0); @@ -174,19 +170,19 @@ fn poll_acquire_one_zero_permits() { assert_ready_ok!(acquire.poll()); } -#[self::test] +#[test] fn max_permits_doesnt_panic() { Semaphore::new(MAX_PERMITS); } -#[self::test] +#[test] #[should_panic] #[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding fn validates_max_permits() { Semaphore::new(MAX_PERMITS + 1); } -#[self::test] +#[test] fn close_semaphore_prevents_acquire() { let s = Semaphore::new(5); s.close(); @@ -200,7 +196,7 @@ fn close_semaphore_prevents_acquire() { assert_eq!(5, s.available_permits()); } -#[self::test] +#[test] fn close_semaphore_notifies_permit1() { let s = Semaphore::new(0); let mut acquire = task::spawn(s.acquire(1)); @@ -213,7 +209,7 @@ fn close_semaphore_notifies_permit1() { assert_ready_err!(acquire.poll()); } -#[self::test] +#[test] fn close_semaphore_notifies_permit2() { let s = Semaphore::new(2); @@ -247,7 +243,7 @@ fn close_semaphore_notifies_permit2() { assert_eq!(2, s.available_permits()); } -#[self::test] +#[test] fn cancel_acquire_releases_permits() { let s = Semaphore::new(10); s.try_acquire(4).expect("uncontended try_acquire succeeds"); @@ -263,7 +259,7 @@ fn cancel_acquire_releases_permits() { assert_ok!(s.try_acquire(6)); } -#[self::test] +#[test] fn release_permits_at_drop() { use crate::sync::semaphore::*; use futures::task::ArcWake;