From 5b43eae7f913233355cb42387f51100d9c45b2ce Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sat, 22 Jul 2023 22:57:24 +1000 Subject: [PATCH] Rm `build.rs` and replace `tokio_wasi` & `tokio_wasm_not_wasi` Replace `tokio_wasi` with `target_os = "wasi"` and replace latter with `cfg_is_wasm_not_wasi!` or `all(target_family = "wasm", not(target_os = "wasi"))`. Signed-off-by: Jiahao XU --- tokio/build.rs | 15 ------ tokio/src/io/mod.rs | 4 +- tokio/src/lib.rs | 20 -------- tokio/src/macros/cfg.rs | 12 ++--- tokio/src/net/tcp/listener.rs | 4 +- tokio/src/net/tcp/stream.rs | 4 +- tokio/src/runtime/blocking/pool.rs | 2 +- tokio/src/runtime/blocking/schedule.rs | 8 ++-- tokio/src/runtime/builder.rs | 12 ++--- tokio/src/runtime/coop.rs | 5 +- tokio/src/runtime/handle.rs | 12 ++--- tokio/src/runtime/io/driver.rs | 10 ++-- tokio/src/runtime/io/registration.rs | 2 +- tokio/src/runtime/mod.rs | 2 +- tokio/src/runtime/runtime.rs | 12 ++--- tokio/src/runtime/scheduler/inject/shared.rs | 5 +- tokio/src/runtime/scheduler/mod.rs | 32 ++++++------- tokio/src/runtime/task/trace/mod.rs | 8 +++- tokio/src/runtime/time/tests/mod.rs | 2 +- tokio/src/sync/tests/atomic_waker.rs | 5 +- tokio/src/sync/tests/notify.rs | 5 +- tokio/src/sync/tests/semaphore_batch.rs | 5 +- tokio/tests/async_send_sync.rs | 2 +- tokio/tests/buffered.rs | 2 +- tokio/tests/fs.rs | 2 +- tokio/tests/fs_canonicalize_dir.rs | 2 +- tokio/tests/fs_copy.rs | 2 +- tokio/tests/fs_dir.rs | 2 +- tokio/tests/fs_file.rs | 2 +- tokio/tests/fs_link.rs | 2 +- tokio/tests/fs_open_options.rs | 2 +- tokio/tests/fs_open_options_windows.rs | 2 +- tokio/tests/fs_remove_dir_all.rs | 2 +- tokio/tests/fs_remove_file.rs | 2 +- tokio/tests/fs_rename.rs | 2 +- tokio/tests/fs_symlink_dir_windows.rs | 2 +- tokio/tests/fs_symlink_file_windows.rs | 2 +- tokio/tests/fs_try_exists.rs | 2 +- tokio/tests/io_copy_bidirectional.rs | 2 +- tokio/tests/io_driver.rs | 2 +- tokio/tests/io_driver_drop.rs | 2 +- tokio/tests/io_fill_buf.rs | 2 +- tokio/tests/io_panic.rs | 2 +- tokio/tests/io_read.rs | 2 +- tokio/tests/io_split.rs | 2 +- tokio/tests/io_take.rs | 2 +- tokio/tests/join_handle_panic.rs | 2 +- tokio/tests/macros_join.rs | 12 ++--- tokio/tests/macros_pin.rs | 7 +-- tokio/tests/macros_rename_test.rs | 2 +- tokio/tests/macros_select.rs | 9 ++-- tokio/tests/macros_test.rs | 2 +- tokio/tests/macros_try_join.rs | 7 +-- tokio/tests/net_bind_resource.rs | 2 +- tokio/tests/net_lookup_host.rs | 2 +- tokio/tests/net_panic.rs | 2 +- tokio/tests/no_rt.rs | 2 +- tokio/tests/process_smoke.rs | 2 +- tokio/tests/rt_basic.rs | 10 ++-- tokio/tests/rt_common.rs | 20 ++++---- tokio/tests/rt_handle.rs | 2 +- tokio/tests/rt_handle_block_on.rs | 16 +++---- tokio/tests/rt_metrics.rs | 2 +- tokio/tests/rt_panic.rs | 2 +- tokio/tests/rt_threaded.rs | 2 +- tokio/tests/rt_threaded_alt.rs | 2 +- tokio/tests/signal_no_rt.rs | 2 +- tokio/tests/sync_barrier.rs | 5 +- tokio/tests/sync_broadcast.rs | 48 ++++++++++---------- tokio/tests/sync_errors.rs | 5 +- tokio/tests/sync_mpsc.rs | 20 ++++---- tokio/tests/sync_mpsc_weak.rs | 5 +- tokio/tests/sync_mutex.rs | 10 ++-- tokio/tests/sync_mutex_owned.rs | 10 ++-- tokio/tests/sync_notify.rs | 5 +- tokio/tests/sync_oneshot.rs | 10 ++-- tokio/tests/sync_panic.rs | 2 +- tokio/tests/sync_rwlock.rs | 12 ++--- tokio/tests/sync_semaphore.rs | 5 +- tokio/tests/sync_semaphore_owned.rs | 5 +- tokio/tests/sync_watch.rs | 5 +- tokio/tests/task_abort.rs | 2 +- tokio/tests/task_blocking.rs | 2 +- tokio/tests/task_id.rs | 26 +++++------ tokio/tests/task_local.rs | 2 +- tokio/tests/task_local_set.rs | 37 ++++++++------- tokio/tests/task_panic.rs | 2 +- tokio/tests/tcp_accept.rs | 2 +- tokio/tests/tcp_connect.rs | 2 +- tokio/tests/tcp_echo.rs | 2 +- tokio/tests/tcp_into_split.rs | 2 +- tokio/tests/tcp_into_std.rs | 2 +- tokio/tests/tcp_peek.rs | 2 +- tokio/tests/tcp_shutdown.rs | 2 +- tokio/tests/tcp_socket.rs | 2 +- tokio/tests/tcp_split.rs | 2 +- tokio/tests/tcp_stream.rs | 2 +- tokio/tests/time_panic.rs | 2 +- tokio/tests/time_pause.rs | 6 +-- tokio/tests/time_rt.rs | 2 +- tokio/tests/time_sleep.rs | 2 +- tokio/tests/time_timeout.rs | 2 +- tokio/tests/udp.rs | 2 +- tokio/tests/unwindsafe.rs | 2 +- 104 files changed, 296 insertions(+), 303 deletions(-) delete mode 100644 tokio/build.rs diff --git a/tokio/build.rs b/tokio/build.rs deleted file mode 100644 index cf2e8bf6621..00000000000 --- a/tokio/build.rs +++ /dev/null @@ -1,15 +0,0 @@ -fn emit(cfg: &str) { - println!("cargo:rustc-cfg={}", cfg); -} - -fn main() { - let target = ::std::env::var("TARGET").unwrap_or_default(); - - if target.starts_with("wasm") { - if target.contains("wasi") { - emit("tokio_wasi"); - } else { - emit("tokio_wasm_not_wasi"); - } - } -} diff --git a/tokio/src/io/mod.rs b/tokio/src/io/mod.rs index 666d69cb438..0fd6cc2c5cb 100644 --- a/tokio/src/io/mod.rs +++ b/tokio/src/io/mod.rs @@ -223,11 +223,11 @@ cfg_io_driver_impl! { pub use ready::Ready; } - #[cfg_attr(tokio_wasi, allow(unused_imports))] + #[cfg_attr(target_os = "wasi", allow(unused_imports))] mod poll_evented; #[cfg(not(loom))] - #[cfg_attr(tokio_wasi, allow(unused_imports))] + #[cfg_attr(target_os = "wasi", allow(unused_imports))] pub(crate) use poll_evented::PollEvented; } diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 9453365adad..21d19bac9d9 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -456,26 +456,6 @@ compile_error! { "Tokio requires the platform pointer width to be 32, 64, or 128 bits" } -// Ensure that our build script has correctly set cfg flags for wasm. -// -// Each condition is written all(a, not(b)). This should be read as -// "if a, then we must also have b". -#[cfg(any( - all(target_arch = "wasm32", not(target_family = "wasm")), - all(target_arch = "wasm64", not(target_family = "wasm")), - all(target_family = "wasm", not(target_family = "wasm")), - all(target_os = "wasi", not(target_family = "wasm")), - all(target_os = "wasi", not(tokio_wasi)), - all(target_os = "wasi", tokio_wasm_not_wasi), - all( - target_family = "wasm", - not(any(target_arch = "wasm32", target_arch = "wasm64")) - ), - all(tokio_wasm_not_wasi, not(target_family = "wasm")), - all(tokio_wasi, not(target_family = "wasm")) -))] -compile_error!("Tokio's build script has incorrectly detected wasm."); - #[cfg(all( not(tokio_unstable), target_family = "wasm", diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index a80e323cf43..f60c040fd01 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -85,7 +85,7 @@ macro_rules! cfg_fs { ($($item:item)*) => { $( #[cfg(feature = "fs")] - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] #[cfg_attr(docsrs, doc(cfg(feature = "fs")))] $item )* @@ -276,7 +276,7 @@ macro_rules! cfg_process { #[cfg(feature = "process")] #[cfg_attr(docsrs, doc(cfg(feature = "process")))] #[cfg(not(loom))] - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] $item )* } @@ -305,7 +305,7 @@ macro_rules! cfg_signal { #[cfg(feature = "signal")] #[cfg_attr(docsrs, doc(cfg(feature = "signal")))] #[cfg(not(loom))] - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] $item )* } @@ -372,7 +372,7 @@ macro_rules! cfg_not_rt { macro_rules! cfg_rt_multi_thread { ($($item:item)*) => { $( - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] #[cfg_attr(docsrs, doc(cfg(feature = "rt-multi-thread")))] $item )* @@ -585,7 +585,7 @@ macro_rules! cfg_not_has_const_mutex_new { macro_rules! cfg_not_wasi { ($($item:item)*) => { $( - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] $item )* } @@ -594,7 +594,7 @@ macro_rules! cfg_not_wasi { macro_rules! cfg_is_wasm_not_wasi { ($($item:item)*) => { $( - #[cfg(tokio_wasm_not_wasi)] + #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] $item )* } diff --git a/tokio/src/net/tcp/listener.rs b/tokio/src/net/tcp/listener.rs index 34e393c895f..07ac6311d1e 100644 --- a/tokio/src/net/tcp/listener.rs +++ b/tokio/src/net/tcp/listener.rs @@ -281,7 +281,7 @@ impl TcpListener { .map(|raw_socket| unsafe { std::net::TcpListener::from_raw_socket(raw_socket) }) } - #[cfg(tokio_wasi)] + #[cfg(target_os = "wasi")] { use std::os::wasi::io::{FromRawFd, IntoRawFd}; self.io @@ -416,7 +416,7 @@ mod sys { } cfg_unstable! { - #[cfg(tokio_wasi)] + #[cfg(target_os = "wasi")] mod sys { use super::TcpListener; use std::os::wasi::prelude::*; diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index b7104d78b40..1c9f1fc56e6 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -258,7 +258,7 @@ impl TcpStream { .map(|raw_socket| unsafe { std::net::TcpStream::from_raw_socket(raw_socket) }) } - #[cfg(tokio_wasi)] + #[cfg(target_os = "wasi")] { use std::os::wasi::io::{FromRawFd, IntoRawFd}; self.io @@ -1405,7 +1405,7 @@ cfg_windows! { } } -#[cfg(all(tokio_unstable, tokio_wasi))] +#[cfg(all(tokio_unstable, target_os = "wasi"))] mod sys { use super::TcpStream; use std::os::wasi::prelude::*; diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs index a23b0a0d2de..33778670c98 100644 --- a/tokio/src/runtime/blocking/pool.rs +++ b/tokio/src/runtime/blocking/pool.rs @@ -173,7 +173,7 @@ const KEEP_ALIVE: Duration = Duration::from_secs(10); /// Tasks will be scheduled as non-mandatory, meaning they may not get executed /// in case of runtime shutdown. #[track_caller] -#[cfg_attr(tokio_wasi, allow(dead_code))] +#[cfg_attr(target_os = "wasi", allow(dead_code))] pub(crate) fn spawn_blocking(func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, diff --git a/tokio/src/runtime/blocking/schedule.rs b/tokio/src/runtime/blocking/schedule.rs index b4c6a2862b3..8dfe5fd10f2 100644 --- a/tokio/src/runtime/blocking/schedule.rs +++ b/tokio/src/runtime/blocking/schedule.rs @@ -23,9 +23,9 @@ impl BlockingSchedule { scheduler::Handle::CurrentThread(handle) => { handle.driver.clock.inhibit_auto_advance(); } - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThread(_) => {} - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThreadAlt(_) => {} } } @@ -45,9 +45,9 @@ impl task::Schedule for BlockingSchedule { handle.driver.clock.allow_auto_advance(); handle.driver.unpark(); } - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThread(_) => {} - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThreadAlt(_) => {} } } diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index d2e10b004ae..38462ef485d 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -197,9 +197,9 @@ pub(crate) type ThreadNameFn = std::sync::Arc String + Send + Sync + #[derive(Clone, Copy)] pub(crate) enum Kind { CurrentThread, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThread, - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThreadAlt, } @@ -676,9 +676,9 @@ impl Builder { pub fn build(&mut self) -> io::Result { match &self.kind { Kind::CurrentThread => self.build_current_thread_runtime(), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Kind::MultiThread => self.build_threaded_runtime(), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Kind::MultiThreadAlt => self.build_alt_threaded_runtime(), } } @@ -687,9 +687,9 @@ impl Builder { driver::Cfg { enable_pause_time: match self.kind { Kind::CurrentThread => true, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Kind::MultiThread => false, - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Kind::MultiThreadAlt => false, }, enable_io: self.enable_io, diff --git a/tokio/src/runtime/coop.rs b/tokio/src/runtime/coop.rs index 2dba2461592..32c13b80e8e 100644 --- a/tokio/src/runtime/coop.rs +++ b/tokio/src/runtime/coop.rs @@ -246,8 +246,9 @@ cfg_coop! { mod test { use super::*; - #[cfg(tokio_wasm_not_wasi)] - use wasm_bindgen_test::wasm_bindgen_test as test; + cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; + } fn get() -> Budget { context::budget(|cell| cell.get()).unwrap_or(Budget::unconstrained()) diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs index 121ed8815f8..ebc7bbaff63 100644 --- a/tokio/src/runtime/handle.rs +++ b/tokio/src/runtime/handle.rs @@ -355,9 +355,9 @@ impl Handle { pub fn runtime_flavor(&self) -> RuntimeFlavor { match self.inner { scheduler::Handle::CurrentThread(_) => RuntimeFlavor::CurrentThread, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThread(_) => RuntimeFlavor::MultiThread, - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThreadAlt(_) => RuntimeFlavor::MultiThreadAlt, } } @@ -385,9 +385,9 @@ impl Handle { pub fn id(&self) -> runtime::Id { let owned_id = match &self.inner { scheduler::Handle::CurrentThread(handle) => handle.owned_id(), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThread(handle) => handle.owned_id(), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThreadAlt(handle) => handle.owned_id(), }; owned_id.into() @@ -529,7 +529,7 @@ cfg_taskdump! { pub async fn dump(&self) -> crate::runtime::Dump { match &self.inner { scheduler::Handle::CurrentThread(handle) => handle.dump(), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThread(handle) => { // perform the trace in a separate thread so that the // trace itself does not appear in the taskdump. @@ -539,7 +539,7 @@ cfg_taskdump! { handle.dump().await }).await }, - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Handle::MultiThreadAlt(_) => panic!("task dump not implemented for this runtime flavor"), } } diff --git a/tokio/src/runtime/io/driver.rs b/tokio/src/runtime/io/driver.rs index a55129210f6..755cb9d1413 100644 --- a/tokio/src/runtime/io/driver.rs +++ b/tokio/src/runtime/io/driver.rs @@ -45,7 +45,7 @@ pub(crate) struct Handle { /// Used to wake up the reactor from a call to `turn`. /// Not supported on Wasi due to lack of threading support. - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] waker: mio::Waker, pub(crate) metrics: IoDriverMetrics, @@ -97,7 +97,7 @@ impl Driver { /// creation. pub(crate) fn new(nevents: usize) -> io::Result<(Driver, Handle)> { let poll = mio::Poll::new()?; - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] let waker = mio::Waker::new(poll.registry(), TOKEN_WAKEUP)?; let registry = poll.registry().try_clone()?; @@ -114,7 +114,7 @@ impl Driver { registry, registrations, synced: Mutex::new(synced), - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] waker, metrics: IoDriverMetrics::default(), }; @@ -156,7 +156,7 @@ impl Driver { match self.poll.poll(events, max_wait) { Ok(_) => {} Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} - #[cfg(tokio_wasi)] + #[cfg(target_os = "wasi")] Err(e) if e.kind() == io::ErrorKind::InvalidInput => { // In case of wasm32_wasi this error happens, when trying to poll without subscriptions // just return from the park, as there would be nothing, which wakes us up. @@ -212,7 +212,7 @@ impl Handle { /// blocked in `turn`, then the next call to `turn` will not block and /// return immediately. pub(crate) fn unpark(&self) { - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] self.waker.wake().expect("failed to wake I/O driver"); } diff --git a/tokio/src/runtime/io/registration.rs b/tokio/src/runtime/io/registration.rs index 4e52d28476c..759589863eb 100644 --- a/tokio/src/runtime/io/registration.rs +++ b/tokio/src/runtime/io/registration.rs @@ -118,7 +118,7 @@ impl Registration { // Uses the poll path, requiring the caller to ensure mutual exclusion for // correctness. Only the last task to call this function is notified. - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] pub(crate) fn poll_read_io( &self, cx: &mut Context<'_>, diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index f0d3a0e6c2e..e3369cb2249 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -212,7 +212,7 @@ cfg_rt! { use config::Config; mod blocking; - #[cfg_attr(tokio_wasi, allow(unused_imports))] + #[cfg_attr(target_os = "wasi", allow(unused_imports))] pub(crate) use blocking::spawn_blocking; cfg_trace! { diff --git a/tokio/src/runtime/runtime.rs b/tokio/src/runtime/runtime.rs index ddec2ab5f20..5d79685300b 100644 --- a/tokio/src/runtime/runtime.rs +++ b/tokio/src/runtime/runtime.rs @@ -125,11 +125,11 @@ pub(super) enum Scheduler { CurrentThread(CurrentThread), /// Execute tasks across multiple threads. - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThread(MultiThread), /// Execute tasks across multiple threads. - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThreadAlt(MultiThreadAlt), } @@ -345,9 +345,9 @@ impl Runtime { match &self.scheduler { Scheduler::CurrentThread(exec) => exec.block_on(&self.handle.inner, future), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Scheduler::MultiThread(exec) => exec.block_on(&self.handle.inner, future), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Scheduler::MultiThreadAlt(exec) => exec.block_on(&self.handle.inner, future), } } @@ -463,13 +463,13 @@ impl Drop for Runtime { let _guard = context::try_set_current(&self.handle.inner); current_thread.shutdown(&self.handle.inner); } - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Scheduler::MultiThread(multi_thread) => { // The threaded scheduler drops its tasks on its worker threads, which is // already in the runtime's context. multi_thread.shutdown(&self.handle.inner); } - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Scheduler::MultiThreadAlt(multi_thread) => { // The threaded scheduler drops its tasks on its worker threads, which is // already in the runtime's context. diff --git a/tokio/src/runtime/scheduler/inject/shared.rs b/tokio/src/runtime/scheduler/inject/shared.rs index 7fdd2839dd2..5a7b9c6a903 100644 --- a/tokio/src/runtime/scheduler/inject/shared.rs +++ b/tokio/src/runtime/scheduler/inject/shared.rs @@ -38,7 +38,10 @@ impl Shared { } // Kind of annoying to have to include the cfg here - #[cfg(any(tokio_taskdump, all(feature = "rt-multi-thread", not(tokio_wasi))))] + #[cfg(any( + tokio_taskdump, + all(feature = "rt-multi-thread", not(target_os = "wasi")) + ))] pub(crate) fn is_closed(&self, synced: &Synced) -> bool { synced.is_closed } diff --git a/tokio/src/runtime/scheduler/mod.rs b/tokio/src/runtime/scheduler/mod.rs index de49dae5e81..d02c0272c90 100644 --- a/tokio/src/runtime/scheduler/mod.rs +++ b/tokio/src/runtime/scheduler/mod.rs @@ -32,10 +32,10 @@ pub(crate) enum Handle { #[cfg(feature = "rt")] CurrentThread(Arc), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThread(Arc), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThreadAlt(Arc), // TODO: This is to avoid triggering "dead code" warnings many other places @@ -49,10 +49,10 @@ pub(crate) enum Handle { pub(super) enum Context { CurrentThread(current_thread::Context), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThread(multi_thread::Context), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] MultiThreadAlt(multi_thread_alt::Context), } @@ -63,10 +63,10 @@ impl Handle { #[cfg(feature = "rt")] Handle::CurrentThread(ref h) => &h.driver, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThread(ref h) => &h.driver, - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThreadAlt(ref h) => &h.driver, #[cfg(not(feature = "rt"))] @@ -89,10 +89,10 @@ cfg_rt! { match $self { $ty::CurrentThread($h) => $e, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] $ty::MultiThread($h) => $e, - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] $ty::MultiThreadAlt($h) => $e, } } @@ -119,10 +119,10 @@ cfg_rt! { match self { Handle::CurrentThread(h) => current_thread::Handle::spawn(h, future, id), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThread(h) => multi_thread::Handle::spawn(h, future, id), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThreadAlt(h) => multi_thread_alt::Handle::spawn(h, future, id), } } @@ -131,10 +131,10 @@ cfg_rt! { match *self { Handle::CurrentThread(_) => {}, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThread(ref h) => h.shutdown(), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThreadAlt(ref h) => h.shutdown(), } } @@ -146,7 +146,7 @@ cfg_rt! { pub(crate) fn as_current_thread(&self) -> &Arc { match self { Handle::CurrentThread(handle) => handle, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] _ => panic!("not a CurrentThread handle"), } } @@ -170,9 +170,9 @@ cfg_rt! { pub(crate) fn num_workers(&self) -> usize { match self { Handle::CurrentThread(_) => 1, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThread(handle) => handle.num_workers(), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(target_os = "wasi")))] Handle::MultiThreadAlt(handle) => handle.num_workers(), } } @@ -216,7 +216,7 @@ cfg_rt! { pub(crate) fn expect_current_thread(&self) -> ¤t_thread::Context { match self { Context::CurrentThread(context) => context, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] _ => panic!("expected `CurrentThread::Context`") } } diff --git a/tokio/src/runtime/task/trace/mod.rs b/tokio/src/runtime/task/trace/mod.rs index 9c61014e865..af2c5644b1a 100644 --- a/tokio/src/runtime/task/trace/mod.rs +++ b/tokio/src/runtime/task/trace/mod.rs @@ -184,9 +184,13 @@ pub(crate) fn trace_leaf(cx: &mut task::Context<'_>) -> Poll<()> { if let Some(scheduler) = scheduler { match scheduler { scheduler::Context::CurrentThread(s) => s.defer.defer(cx.waker()), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] scheduler::Context::MultiThread(s) => s.defer.defer(cx.waker()), - #[cfg(all(tokio_unstable, feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all( + tokio_unstable, + feature = "rt-multi-thread", + not(target_os = "wasi") + ))] scheduler::Context::MultiThreadAlt(_) => unimplemented!(), } } diff --git a/tokio/src/runtime/time/tests/mod.rs b/tokio/src/runtime/time/tests/mod.rs index 155d99a348f..e7ab222ef63 100644 --- a/tokio/src/runtime/time/tests/mod.rs +++ b/tokio/src/runtime/time/tests/mod.rs @@ -1,4 +1,4 @@ -#![cfg(not(tokio_wasi))] +#![cfg(not(target_os = "wasi"))] use std::{task::Context, time::Duration}; diff --git a/tokio/src/sync/tests/atomic_waker.rs b/tokio/src/sync/tests/atomic_waker.rs index bfc5c77d3fe..d01aefc897d 100644 --- a/tokio/src/sync/tests/atomic_waker.rs +++ b/tokio/src/sync/tests/atomic_waker.rs @@ -12,8 +12,9 @@ impl AssertSync for AtomicWaker {} impl AssertSend for Waker {} impl AssertSync for Waker {} -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} #[test] fn basic_usage() { diff --git a/tokio/src/sync/tests/notify.rs b/tokio/src/sync/tests/notify.rs index a806a1b11e2..4af495ad601 100644 --- a/tokio/src/sync/tests/notify.rs +++ b/tokio/src/sync/tests/notify.rs @@ -3,8 +3,9 @@ use std::future::Future; use std::sync::Arc; use std::task::{Context, RawWaker, RawWakerVTable, Waker}; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} #[test] fn notify_clones_waker_before_lock() { diff --git a/tokio/src/sync/tests/semaphore_batch.rs b/tokio/src/sync/tests/semaphore_batch.rs index a75266941df..403b6caa381 100644 --- a/tokio/src/sync/tests/semaphore_batch.rs +++ b/tokio/src/sync/tests/semaphore_batch.rs @@ -3,8 +3,9 @@ use tokio_test::*; const MAX_PERMITS: usize = crate::sync::Semaphore::MAX_PERMITS; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} #[test] fn poll_acquire_one_available() { diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index 32c03a54be2..dfd26f9e9e7 100644 --- a/tokio/tests/async_send_sync.rs +++ b/tokio/tests/async_send_sync.rs @@ -130,7 +130,7 @@ macro_rules! assert_value { macro_rules! cfg_not_wasi { ($($item:item)*) => { $( - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] $item )* } diff --git a/tokio/tests/buffered.rs b/tokio/tests/buffered.rs index 4251c3fcc0b..27e75d10d52 100644 --- a/tokio/tests/buffered.rs +++ b/tokio/tests/buffered.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind() +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind() use tokio::net::TcpListener; use tokio_test::assert_ok; diff --git a/tokio/tests/fs.rs b/tokio/tests/fs.rs index ba38b719f2c..9f739f60c44 100644 --- a/tokio/tests/fs.rs +++ b/tokio/tests/fs.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support file operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations use tokio::fs; use tokio_test::assert_ok; diff --git a/tokio/tests/fs_canonicalize_dir.rs b/tokio/tests/fs_canonicalize_dir.rs index 83f0d813737..e7f6c68ea91 100644 --- a/tokio/tests/fs_canonicalize_dir.rs +++ b/tokio/tests/fs_canonicalize_dir.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tokio::fs; diff --git a/tokio/tests/fs_copy.rs b/tokio/tests/fs_copy.rs index e6e5b666f4a..3311710e9dc 100644 --- a/tokio/tests/fs_copy.rs +++ b/tokio/tests/fs_copy.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tempfile::tempdir; use tokio::fs; diff --git a/tokio/tests/fs_dir.rs b/tokio/tests/fs_dir.rs index 5f653cb2135..3f28c1a07b3 100644 --- a/tokio/tests/fs_dir.rs +++ b/tokio/tests/fs_dir.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tokio::fs; use tokio_test::{assert_err, assert_ok}; diff --git a/tokio/tests/fs_file.rs b/tokio/tests/fs_file.rs index 94d872a57aa..40bd4fce564 100644 --- a/tokio/tests/fs_file.rs +++ b/tokio/tests/fs_file.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use std::io::prelude::*; use tempfile::NamedTempFile; diff --git a/tokio/tests/fs_link.rs b/tokio/tests/fs_link.rs index 681b566607e..48da5f67dd9 100644 --- a/tokio/tests/fs_link.rs +++ b/tokio/tests/fs_link.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tokio::fs; diff --git a/tokio/tests/fs_open_options.rs b/tokio/tests/fs_open_options.rs index e8d8b51b39f..41cfb45460c 100644 --- a/tokio/tests/fs_open_options.rs +++ b/tokio/tests/fs_open_options.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use std::io::Write; use tempfile::NamedTempFile; diff --git a/tokio/tests/fs_open_options_windows.rs b/tokio/tests/fs_open_options_windows.rs index 398e6a12b36..f09e8b4520c 100644 --- a/tokio/tests/fs_open_options_windows.rs +++ b/tokio/tests/fs_open_options_windows.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations #![cfg(windows)] use tokio::fs::OpenOptions; diff --git a/tokio/tests/fs_remove_dir_all.rs b/tokio/tests/fs_remove_dir_all.rs index 53a2fd34f36..5c71bdfda63 100644 --- a/tokio/tests/fs_remove_dir_all.rs +++ b/tokio/tests/fs_remove_dir_all.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tempfile::tempdir; use tokio::fs; diff --git a/tokio/tests/fs_remove_file.rs b/tokio/tests/fs_remove_file.rs index 14fd680dabe..ea477213988 100644 --- a/tokio/tests/fs_remove_file.rs +++ b/tokio/tests/fs_remove_file.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tempfile::tempdir; use tokio::fs; diff --git a/tokio/tests/fs_rename.rs b/tokio/tests/fs_rename.rs index 382fea079bd..91bb39ee359 100644 --- a/tokio/tests/fs_rename.rs +++ b/tokio/tests/fs_rename.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tempfile::tempdir; use tokio::fs; diff --git a/tokio/tests/fs_symlink_dir_windows.rs b/tokio/tests/fs_symlink_dir_windows.rs index d80354268a2..bcfba214be5 100644 --- a/tokio/tests/fs_symlink_dir_windows.rs +++ b/tokio/tests/fs_symlink_dir_windows.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations #![cfg(windows)] use tempfile::tempdir; diff --git a/tokio/tests/fs_symlink_file_windows.rs b/tokio/tests/fs_symlink_file_windows.rs index 50eaf8aab75..4bc032ed79f 100644 --- a/tokio/tests/fs_symlink_file_windows.rs +++ b/tokio/tests/fs_symlink_file_windows.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations #![cfg(windows)] use tempfile::tempdir; diff --git a/tokio/tests/fs_try_exists.rs b/tokio/tests/fs_try_exists.rs index 00d23650015..dca554dda45 100644 --- a/tokio/tests/fs_try_exists.rs +++ b/tokio/tests/fs_try_exists.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // WASI does not support all fs operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations use tempfile::tempdir; use tokio::fs; diff --git a/tokio/tests/io_copy_bidirectional.rs b/tokio/tests/io_copy_bidirectional.rs index c5496759550..10eba3166ac 100644 --- a/tokio/tests/io_copy_bidirectional.rs +++ b/tokio/tests/io_copy_bidirectional.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind() +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind() use std::time::Duration; use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt}; diff --git a/tokio/tests/io_driver.rs b/tokio/tests/io_driver.rs index 97018e0f967..2e2c84746c9 100644 --- a/tokio/tests/io_driver.rs +++ b/tokio/tests/io_driver.rs @@ -1,6 +1,6 @@ #![warn(rust_2018_idioms)] // Wasi does not support panic recovery or threading -#![cfg(all(feature = "full", not(tokio_wasi)))] +#![cfg(all(feature = "full", not(target_os = "wasi")))] use tokio::net::TcpListener; use tokio::runtime; diff --git a/tokio/tests/io_driver_drop.rs b/tokio/tests/io_driver_drop.rs index 0a384d4196d..c3182637916 100644 --- a/tokio/tests/io_driver_drop.rs +++ b/tokio/tests/io_driver_drop.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind use tokio::net::TcpListener; use tokio::runtime; diff --git a/tokio/tests/io_fill_buf.rs b/tokio/tests/io_fill_buf.rs index 62c3f1b370d..534417c855d 100644 --- a/tokio/tests/io_fill_buf.rs +++ b/tokio/tests/io_fill_buf.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support file operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations use tempfile::NamedTempFile; use tokio::fs::File; diff --git a/tokio/tests/io_panic.rs b/tokio/tests/io_panic.rs index 922d7c076e7..9b2bf6a3bd8 100644 --- a/tokio/tests/io_panic.rs +++ b/tokio/tests/io_panic.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery use std::task::{Context, Poll}; use std::{error::Error, pin::Pin}; diff --git a/tokio/tests/io_read.rs b/tokio/tests/io_read.rs index 7f74c5e857a..6bea0ac865e 100644 --- a/tokio/tests/io_read.rs +++ b/tokio/tests/io_read.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf}; use tokio_test::assert_ok; diff --git a/tokio/tests/io_split.rs b/tokio/tests/io_split.rs index 4cbd2a2d1fb..77b77a3a04c 100644 --- a/tokio/tests/io_split.rs +++ b/tokio/tests/io_split.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf}; diff --git a/tokio/tests/io_take.rs b/tokio/tests/io_take.rs index fba01d2e0c6..539f17f3a2d 100644 --- a/tokio/tests/io_take.rs +++ b/tokio/tests/io_take.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery use std::pin::Pin; use std::task::{Context, Poll}; diff --git a/tokio/tests/join_handle_panic.rs b/tokio/tests/join_handle_panic.rs index bc34fd0ea59..c25a5f88568 100644 --- a/tokio/tests/join_handle_panic.rs +++ b/tokio/tests/join_handle_panic.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery struct PanicsOnDrop; diff --git a/tokio/tests/macros_join.rs b/tokio/tests/macros_join.rs index 7866ac086fa..7f75ae9db3a 100644 --- a/tokio/tests/macros_join.rs +++ b/tokio/tests/macros_join.rs @@ -2,13 +2,13 @@ #![allow(clippy::disallowed_names)] use std::sync::Arc; -#[cfg(tokio_wasm_not_wasi)] -#[cfg(target_pointer_width = "64")] -use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + #[cfg(target_pointer_width = "64")] + use wasm_bindgen_test::wasm_bindgen_test as test; + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::{oneshot, Semaphore}; diff --git a/tokio/tests/macros_pin.rs b/tokio/tests/macros_pin.rs index e99a3ee2017..e926d892c7f 100644 --- a/tokio/tests/macros_pin.rs +++ b/tokio/tests/macros_pin.rs @@ -1,9 +1,10 @@ #![cfg(feature = "macros")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; async fn one() {} diff --git a/tokio/tests/macros_rename_test.rs b/tokio/tests/macros_rename_test.rs index 6c2ce2f57aa..0c5eba20f8d 100644 --- a/tokio/tests/macros_rename_test.rs +++ b/tokio/tests/macros_rename_test.rs @@ -1,4 +1,4 @@ -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threading +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threading #[allow(unused_imports)] use std as tokio; diff --git a/tokio/tests/macros_select.rs b/tokio/tests/macros_select.rs index 0514c864d5e..d6da65fe1f4 100644 --- a/tokio/tests/macros_select.rs +++ b/tokio/tests/macros_select.rs @@ -1,10 +1,11 @@ #![cfg(feature = "macros")] #![allow(clippy::disallowed_names)] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::oneshot; @@ -633,7 +634,7 @@ mod unstable { } #[test] - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] fn deterministic_select_multi_thread() { let seed = b"bytes used to generate seed"; let rt1 = tokio::runtime::Builder::new_multi_thread() diff --git a/tokio/tests/macros_test.rs b/tokio/tests/macros_test.rs index 85279b7edc0..b5095e36e4b 100644 --- a/tokio/tests/macros_test.rs +++ b/tokio/tests/macros_test.rs @@ -1,4 +1,4 @@ -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threading +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threading use tokio::test; diff --git a/tokio/tests/macros_try_join.rs b/tokio/tests/macros_try_join.rs index 74b1c9f9481..5a3846f3b5d 100644 --- a/tokio/tests/macros_try_join.rs +++ b/tokio/tests/macros_try_join.rs @@ -6,10 +6,11 @@ use std::sync::Arc; use tokio::sync::{oneshot, Semaphore}; use tokio_test::{assert_pending, assert_ready, task}; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; #[maybe_tokio_test] diff --git a/tokio/tests/net_bind_resource.rs b/tokio/tests/net_bind_resource.rs index 76378b3ea1e..05fd1604b87 100644 --- a/tokio/tests/net_bind_resource.rs +++ b/tokio/tests/net_bind_resource.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support panic recovery or bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery or bind use tokio::net::TcpListener; diff --git a/tokio/tests/net_lookup_host.rs b/tokio/tests/net_lookup_host.rs index 2b346e65e37..667030c7e02 100644 --- a/tokio/tests/net_lookup_host.rs +++ b/tokio/tests/net_lookup_host.rs @@ -1,4 +1,4 @@ -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support direct socket operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support direct socket operations use tokio::net; use tokio_test::assert_ok; diff --git a/tokio/tests/net_panic.rs b/tokio/tests/net_panic.rs index fc2209ad4b0..79807618973 100644 --- a/tokio/tests/net_panic.rs +++ b/tokio/tests/net_panic.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] +#![cfg(all(feature = "full", not(target_os = "wasi")))] use std::error::Error; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/no_rt.rs b/tokio/tests/no_rt.rs index 747fab6af7d..89c7ce0aa57 100644 --- a/tokio/tests/no_rt.rs +++ b/tokio/tests/no_rt.rs @@ -1,4 +1,4 @@ -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery use tokio::net::TcpStream; use tokio::sync::oneshot; diff --git a/tokio/tests/process_smoke.rs b/tokio/tests/process_smoke.rs index 81d2020a079..635b951a065 100644 --- a/tokio/tests/process_smoke.rs +++ b/tokio/tests/process_smoke.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi cannot run system commands +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi cannot run system commands use tokio::process::Command; use tokio_test::assert_ok; diff --git a/tokio/tests/rt_basic.rs b/tokio/tests/rt_basic.rs index 6caf0a44bf8..789c0475da4 100644 --- a/tokio/tests/rt_basic.rs +++ b/tokio/tests/rt_basic.rs @@ -178,7 +178,7 @@ fn drop_tasks_in_context() { } #[test] -#[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] +#[cfg_attr(target_os = "wasi", ignore = "Wasi does not support panic recovery")] #[should_panic(expected = "boom")] fn wake_in_drop_after_panic() { let (tx, rx) = oneshot::channel::<()>(); @@ -239,7 +239,7 @@ fn spawn_two() { } } -#[cfg_attr(tokio_wasi, ignore = "WASI: std::thread::spawn not supported")] +#[cfg_attr(target_os = "wasi", ignore = "WASI: std::thread::spawn not supported")] #[test] fn spawn_remote() { let rt = rt(); @@ -276,7 +276,7 @@ fn spawn_remote() { } #[test] -#[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] +#[cfg_attr(target_os = "wasi", ignore = "Wasi does not support panic recovery")] #[should_panic( expected = "A Tokio 1.x context was found, but timers are disabled. Call `enable_time` on the runtime builder to enable timers." )] @@ -315,7 +315,7 @@ mod unstable { } #[test] - #[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] + #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support panic recovery")] fn spawns_do_nothing() { use std::sync::Arc; @@ -344,7 +344,7 @@ mod unstable { } #[test] - #[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] + #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support panic recovery")] fn shutdown_all_concurrent_block_on() { const N: usize = 2; use std::sync::{mpsc, Arc}; diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs index 9ab7fd3516e..58df53f0170 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -21,7 +21,7 @@ macro_rules! rt_test { } } - #[cfg(not(tokio_wasi))] // Wasi doesn't support threads + #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads mod threaded_scheduler_4_threads { $($t)* @@ -37,7 +37,7 @@ macro_rules! rt_test { } } - #[cfg(not(tokio_wasi))] // Wasi doesn't support threads + #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads mod threaded_scheduler_1_thread { $($t)* @@ -53,7 +53,7 @@ macro_rules! rt_test { } } - #[cfg(not(tokio_wasi))] // Wasi doesn't support threads + #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[cfg(tokio_unstable)] mod alt_threaded_scheduler_4_threads { $($t)* @@ -70,7 +70,7 @@ macro_rules! rt_test { } } - #[cfg(not(tokio_wasi))] // Wasi doesn't support threads + #[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[cfg(tokio_unstable)] mod alt_threaded_scheduler_1_thread { $($t)* @@ -844,7 +844,7 @@ rt_test! { assert_err!(rx.try_recv()); } - #[cfg_attr(tokio_wasi, ignore = "Wasi does not support threads or panic recovery")] + #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support threads or panic recovery")] #[test] fn panic_in_task() { let rt = rt(); @@ -873,7 +873,7 @@ rt_test! { #[test] #[should_panic] - #[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] + #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support panic recovery")] fn panic_in_block_on() { let rt = rt(); rt.block_on(async { panic!() }); @@ -1103,7 +1103,7 @@ rt_test! { // See https://github.com/rust-lang/rust/issues/74875 #[test] #[cfg(not(windows))] - #[cfg_attr(tokio_wasi, ignore = "Wasi does not support threads")] + #[cfg_attr(target_os = "wasi", ignore = "Wasi does not support threads")] fn runtime_in_thread_local() { use std::cell::RefCell; use std::thread; @@ -1148,7 +1148,7 @@ rt_test! { tx.send(()).unwrap(); } - #[cfg(not(tokio_wasi))] // Wasi does not support bind + #[cfg(not(target_os = "wasi"))] // Wasi does not support bind #[test] fn local_set_block_on_socket() { let rt = rt(); @@ -1170,7 +1170,7 @@ rt_test! { }); } - #[cfg(not(tokio_wasi))] // Wasi does not support bind + #[cfg(not(target_os = "wasi"))] // Wasi does not support bind #[test] fn local_set_client_server_block_on() { let rt = rt(); @@ -1184,7 +1184,7 @@ rt_test! { assert_err!(rx.try_recv()); } - #[cfg(not(tokio_wasi))] // Wasi does not support bind + #[cfg(not(target_os = "wasi"))] // Wasi does not support bind async fn client_server_local(tx: mpsc::Sender<()>) { let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await); diff --git a/tokio/tests/rt_handle.rs b/tokio/tests/rt_handle.rs index 14d6524f62e..5d4b53f6319 100644 --- a/tokio/tests/rt_handle.rs +++ b/tokio/tests/rt_handle.rs @@ -42,7 +42,7 @@ fn interleave_enter_same_rt() { } #[test] -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] fn interleave_then_enter() { let _ = std::panic::catch_unwind(|| { let rt1 = rt(); diff --git a/tokio/tests/rt_handle_block_on.rs b/tokio/tests/rt_handle_block_on.rs index 5ec783e5588..54b9002c075 100644 --- a/tokio/tests/rt_handle_block_on.rs +++ b/tokio/tests/rt_handle_block_on.rs @@ -10,10 +10,10 @@ use std::time::Duration; use tokio::runtime::{Handle, Runtime}; use tokio::sync::mpsc; -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use tokio::{net, time}; -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads macro_rules! multi_threaded_rt_test { ($($t:tt)*) => { mod threaded_scheduler_4_threads_only { @@ -46,7 +46,7 @@ macro_rules! multi_threaded_rt_test { } } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] macro_rules! rt_test { ($($t:tt)*) => { mod current_thread_scheduler { @@ -126,7 +126,7 @@ fn unbounded_mpsc_channel() { }) } -#[cfg(not(tokio_wasi))] // Wasi doesn't support file operations or bind +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support file operations or bind rt_test! { use tokio::fs; // ==== spawn blocking futures ====== @@ -419,7 +419,7 @@ rt_test! { } } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] multi_threaded_rt_test! { #[cfg(unix)] #[test] @@ -482,7 +482,7 @@ multi_threaded_rt_test! { // ==== utils ====== /// Create a new multi threaded runtime -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] fn new_multi_thread(n: usize) -> Runtime { tokio::runtime::Builder::new_multi_thread() .worker_threads(n) @@ -513,7 +513,7 @@ where f(); } - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] { let rt = new_multi_thread(1); let _enter = rt.enter(); @@ -523,7 +523,7 @@ where f(); } - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] { let rt = new_multi_thread(4); let _enter = rt.enter(); diff --git a/tokio/tests/rt_metrics.rs b/tokio/tests/rt_metrics.rs index 0fe839a2f97..7b7a957c419 100644 --- a/tokio/tests/rt_metrics.rs +++ b/tokio/tests/rt_metrics.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", tokio_unstable, not(tokio_wasi)))] +#![cfg(all(feature = "full", tokio_unstable, not(target_os = "wasi")))] use std::future::Future; use std::sync::{Arc, Mutex}; diff --git a/tokio/tests/rt_panic.rs b/tokio/tests/rt_panic.rs index f9a684fdada..57f327481b6 100644 --- a/tokio/tests/rt_panic.rs +++ b/tokio/tests/rt_panic.rs @@ -1,6 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] -#![cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery +#![cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery use futures::future; use std::error::Error; diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs index 3c77c7e5c50..83df6ed480f 100644 --- a/tokio/tests/rt_threaded.rs +++ b/tokio/tests/rt_threaded.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] +#![cfg(all(feature = "full", not(target_os = "wasi")))] use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/rt_threaded_alt.rs b/tokio/tests/rt_threaded_alt.rs index b8af6a7b8a9..b0eb4279af0 100644 --- a/tokio/tests/rt_threaded_alt.rs +++ b/tokio/tests/rt_threaded_alt.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] +#![cfg(all(feature = "full", not(target_os = "wasi")))] #![cfg(tokio_unstable)] use tokio::io::{AsyncReadExt, AsyncWriteExt}; diff --git a/tokio/tests/signal_no_rt.rs b/tokio/tests/signal_no_rt.rs index ffcc6651c4d..db284e16513 100644 --- a/tokio/tests/signal_no_rt.rs +++ b/tokio/tests/signal_no_rt.rs @@ -4,7 +4,7 @@ use tokio::signal::unix::{signal, SignalKind}; -#[cfg_attr(tokio_wasi, ignore = "Wasi does not support panic recovery")] +#[cfg_attr(target_os = "wasi", ignore = "Wasi does not support panic recovery")] #[test] #[should_panic] fn no_runtime_panics_creating_signals() { diff --git a/tokio/tests/sync_barrier.rs b/tokio/tests/sync_barrier.rs index 2001c3598cb..ee665ebadf7 100644 --- a/tokio/tests/sync_barrier.rs +++ b/tokio/tests/sync_barrier.rs @@ -2,8 +2,9 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} use tokio::sync::Barrier; diff --git a/tokio/tests/sync_broadcast.rs b/tokio/tests/sync_broadcast.rs index 59190a9603d..562350bc2b0 100644 --- a/tokio/tests/sync_broadcast.rs +++ b/tokio/tests/sync_broadcast.rs @@ -2,8 +2,9 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} use tokio::sync::broadcast; use tokio_test::task; @@ -562,29 +563,30 @@ fn sender_len() { assert!(!tx.is_empty()); } -#[test] -#[cfg(not(tokio_wasm_not_wasi))] -fn sender_len_random() { - use rand::Rng; - - let (tx, mut rx1) = broadcast::channel(16); - let mut rx2 = tx.subscribe(); - - for _ in 0..1000 { - match rand::thread_rng().gen_range(0..4) { - 0 => { - let _ = rx1.try_recv(); - } - 1 => { - let _ = rx2.try_recv(); - } - _ => { - tx.send(0).unwrap(); +cfg_is_wasm_not_wasi! { + #[test] + fn sender_len_random() { + use rand::Rng; + + let (tx, mut rx1) = broadcast::channel(16); + let mut rx2 = tx.subscribe(); + + for _ in 0..1000 { + match rand::thread_rng().gen_range(0..4) { + 0 => { + let _ = rx1.try_recv(); + } + 1 => { + let _ = rx2.try_recv(); + } + _ => { + tx.send(0).unwrap(); + } } - } - let expected_len = usize::min(usize::max(rx1.len(), rx2.len()), 16); - assert_eq!(tx.len(), expected_len); + let expected_len = usize::min(usize::max(rx1.len(), rx2.len()), 16); + assert_eq!(tx.len(), expected_len); + } } } diff --git a/tokio/tests/sync_errors.rs b/tokio/tests/sync_errors.rs index bf0a6cf7374..b84b1d8214a 100644 --- a/tokio/tests/sync_errors.rs +++ b/tokio/tests/sync_errors.rs @@ -1,8 +1,9 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} fn is_error() {} diff --git a/tokio/tests/sync_mpsc.rs b/tokio/tests/sync_mpsc.rs index 84211a7c272..39ff5d3377b 100644 --- a/tokio/tests/sync_mpsc.rs +++ b/tokio/tests/sync_mpsc.rs @@ -2,16 +2,18 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} + +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] +use tokio::test as maybe_tokio_test; use std::fmt; use std::sync::Arc; use tokio::sync::mpsc; use tokio::sync::mpsc::error::{TryRecvError, TrySendError}; -#[cfg(not(tokio_wasm_not_wasi))] use tokio::test as maybe_tokio_test; use tokio_test::*; @@ -87,7 +89,7 @@ async fn reserve_disarm() { } #[tokio::test] -#[cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads async fn send_recv_stream_with_buffer() { use tokio_stream::StreamExt; @@ -191,7 +193,7 @@ async fn async_send_recv_unbounded() { } #[tokio::test] -#[cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads async fn send_recv_stream_unbounded() { use tokio_stream::StreamExt; @@ -452,7 +454,7 @@ fn unconsumed_messages_are_dropped() { } #[test] -#[cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads fn blocking_recv() { let (tx, mut rx) = mpsc::channel::(1); @@ -477,7 +479,7 @@ async fn blocking_recv_async() { } #[test] -#[cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads fn blocking_send() { let (tx, mut rx) = mpsc::channel::(1); diff --git a/tokio/tests/sync_mpsc_weak.rs b/tokio/tests/sync_mpsc_weak.rs index 0fdfc00708b..bbaad200463 100644 --- a/tokio/tests/sync_mpsc_weak.rs +++ b/tokio/tests/sync_mpsc_weak.rs @@ -2,8 +2,9 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::{Acquire, Release}; diff --git a/tokio/tests/sync_mutex.rs b/tokio/tests/sync_mutex.rs index 1e35a558c1d..5b468e74cf6 100644 --- a/tokio/tests/sync_mutex.rs +++ b/tokio/tests/sync_mutex.rs @@ -1,12 +1,12 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::Mutex; diff --git a/tokio/tests/sync_mutex_owned.rs b/tokio/tests/sync_mutex_owned.rs index ba472fee78e..2e37aef660c 100644 --- a/tokio/tests/sync_mutex_owned.rs +++ b/tokio/tests/sync_mutex_owned.rs @@ -1,12 +1,12 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::Mutex; diff --git a/tokio/tests/sync_notify.rs b/tokio/tests/sync_notify.rs index aa58039fac1..9d1cae01882 100644 --- a/tokio/tests/sync_notify.rs +++ b/tokio/tests/sync_notify.rs @@ -1,8 +1,9 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} use tokio::sync::Notify; use tokio_test::task::spawn; diff --git a/tokio/tests/sync_oneshot.rs b/tokio/tests/sync_oneshot.rs index f11b1071cd0..55b8b335714 100644 --- a/tokio/tests/sync_oneshot.rs +++ b/tokio/tests/sync_oneshot.rs @@ -1,12 +1,12 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::oneshot; diff --git a/tokio/tests/sync_panic.rs b/tokio/tests/sync_panic.rs index 6c23664998f..bcdaaae56d0 100644 --- a/tokio/tests/sync_panic.rs +++ b/tokio/tests/sync_panic.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] +#![cfg(all(feature = "full", not(target_os = "wasi")))] use std::{error::Error, sync::Arc}; use tokio::{ diff --git a/tokio/tests/sync_rwlock.rs b/tokio/tests/sync_rwlock.rs index 667f621721f..8bcd2e36f5c 100644 --- a/tokio/tests/sync_rwlock.rs +++ b/tokio/tests/sync_rwlock.rs @@ -1,12 +1,12 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; + use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; +} -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use std::task::Poll; @@ -172,7 +172,7 @@ async fn write_order() { } // A single RwLock is contested by tasks in multiple threads -#[cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread", worker_threads = 8)] async fn multithreaded() { use futures::stream::{self, StreamExt}; diff --git a/tokio/tests/sync_semaphore.rs b/tokio/tests/sync_semaphore.rs index 52c65fdb1f7..47f7fb5f02c 100644 --- a/tokio/tests/sync_semaphore.rs +++ b/tokio/tests/sync_semaphore.rs @@ -1,7 +1,8 @@ #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} use std::sync::Arc; use tokio::sync::Semaphore; diff --git a/tokio/tests/sync_semaphore_owned.rs b/tokio/tests/sync_semaphore_owned.rs index 6f66d6adc98..fb675d2f9ee 100644 --- a/tokio/tests/sync_semaphore_owned.rs +++ b/tokio/tests/sync_semaphore_owned.rs @@ -1,7 +1,8 @@ #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} use std::sync::Arc; use tokio::sync::Semaphore; diff --git a/tokio/tests/sync_watch.rs b/tokio/tests/sync_watch.rs index 9d169641d23..1a3bb32c0cf 100644 --- a/tokio/tests/sync_watch.rs +++ b/tokio/tests/sync_watch.rs @@ -2,8 +2,9 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] -use wasm_bindgen_test::wasm_bindgen_test as test; +cfg_is_wasm_not_wasi! { + use wasm_bindgen_test::wasm_bindgen_test as test; +} use tokio::sync::watch; use tokio_test::task::spawn; diff --git a/tokio/tests/task_abort.rs b/tokio/tests/task_abort.rs index 492f8b551a3..4798246c374 100644 --- a/tokio/tests/task_abort.rs +++ b/tokio/tests/task_abort.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery use std::sync::Arc; use std::thread::sleep; diff --git a/tokio/tests/task_blocking.rs b/tokio/tests/task_blocking.rs index 2999758ff36..62e20f6c0fe 100644 --- a/tokio/tests/task_blocking.rs +++ b/tokio/tests/task_blocking.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads use tokio::{runtime, task, time}; use tokio_test::assert_ok; diff --git a/tokio/tests/task_id.rs b/tokio/tests/task_id.rs index d7b7c0cd812..e10f24be99c 100644 --- a/tokio/tests/task_id.rs +++ b/tokio/tests/task_id.rs @@ -2,21 +2,21 @@ #![allow(clippy::declare_interior_mutable_const)] #![cfg(all(feature = "full", tokio_unstable))] -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use tokio::runtime::{Builder, Runtime}; use tokio::sync::oneshot; use tokio::task::{self, Id, LocalSet}; -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] mod support { pub mod panic; } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use support::panic::test_panic; #[tokio::test(flavor = "current_thread")] @@ -26,7 +26,7 @@ async fn task_id_spawn() { .unwrap(); } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[tokio::test(flavor = "current_thread")] async fn task_id_spawn_blocking() { task::spawn_blocking(|| println!("task id: {}", task::id())) @@ -43,7 +43,7 @@ async fn task_id_collision_current_thread() { assert_ne!(id1.unwrap(), id2.unwrap()); } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[tokio::test(flavor = "multi_thread")] async fn task_id_collision_multi_thread() { let handle1 = tokio::spawn(async { task::id() }); @@ -64,7 +64,7 @@ async fn task_ids_match_current_thread() { handle.await.unwrap(); } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[tokio::test(flavor = "multi_thread")] async fn task_ids_match_multi_thread() { let (tx, rx) = oneshot::channel(); @@ -76,7 +76,7 @@ async fn task_ids_match_multi_thread() { handle.await.unwrap(); } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[tokio::test(flavor = "multi_thread")] async fn task_id_future_destructor_completion() { struct MyFuture { @@ -104,7 +104,7 @@ async fn task_id_future_destructor_completion() { assert_eq!(rx.await.unwrap(), id); } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[tokio::test(flavor = "multi_thread")] async fn task_id_future_destructor_abort() { struct MyFuture { @@ -210,7 +210,7 @@ fn task_try_id_outside_task() { assert_eq!(None, task::try_id()); } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[test] fn task_try_id_inside_block_on() { let rt = Runtime::new().unwrap(); @@ -253,7 +253,7 @@ async fn task_id_nested_spawn_local() { .await; } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[tokio::test(flavor = "multi_thread")] async fn task_id_block_in_place_block_on_spawn() { task::spawn(async { @@ -273,7 +273,7 @@ async fn task_id_block_in_place_block_on_spawn() { .unwrap(); } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[test] fn task_id_outside_task_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { @@ -286,7 +286,7 @@ fn task_id_outside_task_panic_caller() -> Result<(), Box> { Ok(()) } -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] #[test] fn task_id_inside_block_on_panic_caller() -> Result<(), Box> { let panic_location_file = test_panic(|| { diff --git a/tokio/tests/task_local.rs b/tokio/tests/task_local.rs index 949a40c2a4d..a9ffaa15acc 100644 --- a/tokio/tests/task_local.rs +++ b/tokio/tests/task_local.rs @@ -1,4 +1,4 @@ -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads #![allow(clippy::declare_interior_mutable_const)] use std::future::Future; use std::pin::Pin; diff --git a/tokio/tests/task_local_set.rs b/tokio/tests/task_local_set.rs index 2da87f5aed2..baca58b776c 100644 --- a/tokio/tests/task_local_set.rs +++ b/tokio/tests/task_local_set.rs @@ -11,13 +11,13 @@ use tokio::sync::{mpsc, oneshot}; use tokio::task::{self, LocalSet}; use tokio::time; -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use std::cell::Cell; use std::sync::atomic::AtomicBool; -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use std::sync::atomic::Ordering::SeqCst; use std::time::Duration; @@ -30,7 +30,7 @@ async fn local_current_thread_scheduler() { .await; } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn local_threadpool() { thread_local! { @@ -51,7 +51,7 @@ async fn local_threadpool() { .await; } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn localset_future_threadpool() { thread_local! { @@ -67,7 +67,7 @@ async fn localset_future_threadpool() { local.await; } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn localset_future_timers() { static RAN1: AtomicBool = AtomicBool::new(false); @@ -112,7 +112,7 @@ async fn localset_future_drives_all_local_futs() { assert!(RAN3.load(Ordering::SeqCst)); } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn local_threadpool_timer() { // This test ensures that runtime services like the timer are properly @@ -151,7 +151,7 @@ fn enter_guard_spawn() { }); } -#[cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery #[test] // This will panic, since the thread that calls `block_on` cannot use // in-place blocking inside of `block_on`. @@ -178,7 +178,7 @@ fn local_threadpool_blocking_in_place() { }); } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn local_threadpool_blocking_run() { thread_local! { @@ -207,7 +207,7 @@ async fn local_threadpool_blocking_run() { .await; } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn all_spawns_are_local() { use futures::future; @@ -234,7 +234,7 @@ async fn all_spawns_are_local() { .await; } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn nested_spawn_is_local() { thread_local! { @@ -270,7 +270,7 @@ async fn nested_spawn_is_local() { .await; } -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[test] fn join_local_future_elsewhere() { thread_local! { @@ -307,7 +307,7 @@ fn join_local_future_elsewhere() { } // Tests for -#[cfg(not(tokio_wasi))] // Wasi doesn't support threads +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread")] async fn localset_in_thread_local() { thread_local! { @@ -398,7 +398,10 @@ fn with_timeout(timeout: Duration, f: impl FnOnce() + Send + 'static) { thread.join().expect("test thread should not panic!") } -#[cfg_attr(tokio_wasi, ignore = "`unwrap()` in `with_timeout()` panics on Wasi")] +#[cfg_attr( + target_os = "wasi", + ignore = "`unwrap()` in `with_timeout()` panics on Wasi" +)] #[test] fn drop_cancels_remote_tasks() { // This test reproduces issue #1885. @@ -422,7 +425,7 @@ fn drop_cancels_remote_tasks() { } #[cfg_attr( - tokio_wasi, + target_os = "wasi", ignore = "FIXME: `task::spawn_local().await.unwrap()` panics on Wasi" )] #[test] @@ -446,7 +449,7 @@ fn local_tasks_wake_join_all() { }); } -#[cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery #[test] fn local_tasks_are_polled_after_tick() { // This test depends on timing, so we run it up to five times. @@ -463,7 +466,7 @@ fn local_tasks_are_polled_after_tick() { local_tasks_are_polled_after_tick_inner(); } -#[cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery #[tokio::main(flavor = "current_thread")] async fn local_tasks_are_polled_after_tick_inner() { // Reproduces issues #1899 and #1900 diff --git a/tokio/tests/task_panic.rs b/tokio/tests/task_panic.rs index e4cedce2798..2ca21b1ded2 100644 --- a/tokio/tests/task_panic.rs +++ b/tokio/tests/task_panic.rs @@ -1,6 +1,6 @@ #![warn(rust_2018_idioms)] #![allow(clippy::declare_interior_mutable_const)] -#![cfg(all(feature = "full", not(tokio_wasi)))] +#![cfg(all(feature = "full", not(target_os = "wasi")))] use futures::future; use std::error::Error; diff --git a/tokio/tests/tcp_accept.rs b/tokio/tests/tcp_accept.rs index ba4a498d1a5..d547c48daa3 100644 --- a/tokio/tests/tcp_accept.rs +++ b/tokio/tests/tcp_accept.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::net::{TcpListener, TcpStream}; use tokio::sync::{mpsc, oneshot}; diff --git a/tokio/tests/tcp_connect.rs b/tokio/tests/tcp_connect.rs index f2384420ed3..03f7b34ff43 100644 --- a/tokio/tests/tcp_connect.rs +++ b/tokio/tests/tcp_connect.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; diff --git a/tokio/tests/tcp_echo.rs b/tokio/tests/tcp_echo.rs index f47d4ac185a..dfd4dd7b9f4 100644 --- a/tokio/tests/tcp_echo.rs +++ b/tokio/tests/tcp_echo.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/tcp_into_split.rs b/tokio/tests/tcp_into_split.rs index 010984af8cc..2a030691f64 100644 --- a/tokio/tests/tcp_into_split.rs +++ b/tokio/tests/tcp_into_split.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use std::io::{Error, ErrorKind, Result}; use std::io::{Read, Write}; diff --git a/tokio/tests/tcp_into_std.rs b/tokio/tests/tcp_into_std.rs index 320d9946e81..58996f75c90 100644 --- a/tokio/tests/tcp_into_std.rs +++ b/tokio/tests/tcp_into_std.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use std::io::Read; use std::io::Result; diff --git a/tokio/tests/tcp_peek.rs b/tokio/tests/tcp_peek.rs index a5fd6ba4fe5..b2d3eda097e 100644 --- a/tokio/tests/tcp_peek.rs +++ b/tokio/tests/tcp_peek.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::io::AsyncReadExt; use tokio::net::TcpStream; diff --git a/tokio/tests/tcp_shutdown.rs b/tokio/tests/tcp_shutdown.rs index 1d477f37c22..86c1485a4a4 100644 --- a/tokio/tests/tcp_shutdown.rs +++ b/tokio/tests/tcp_shutdown.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/tcp_socket.rs b/tokio/tests/tcp_socket.rs index 66309d30411..b431196f1c6 100644 --- a/tokio/tests/tcp_socket.rs +++ b/tokio/tests/tcp_socket.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use std::time::Duration; use tokio::net::TcpSocket; diff --git a/tokio/tests/tcp_split.rs b/tokio/tests/tcp_split.rs index 335b21f2940..32aaa1f771b 100644 --- a/tokio/tests/tcp_split.rs +++ b/tokio/tests/tcp_split.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use std::io::Result; use std::io::{Read, Write}; diff --git a/tokio/tests/tcp_stream.rs b/tokio/tests/tcp_stream.rs index 31fe3baa296..725a60169ea 100644 --- a/tokio/tests/tcp_stream.rs +++ b/tokio/tests/tcp_stream.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/time_panic.rs b/tokio/tests/time_panic.rs index aaff11bb4f0..02b928bb83e 100644 --- a/tokio/tests/time_panic.rs +++ b/tokio/tests/time_panic.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery use futures::future; use std::error::Error; diff --git a/tokio/tests/time_pause.rs b/tokio/tests/time_pause.rs index c772e387384..6251b4b829f 100644 --- a/tokio/tests/time_pause.rs +++ b/tokio/tests/time_pause.rs @@ -6,7 +6,7 @@ use rand::{rngs::StdRng, Rng}; use tokio::time::{self, Duration, Instant, Sleep}; use tokio_test::{assert_elapsed, assert_pending, assert_ready, assert_ready_eq, task}; -#[cfg(not(tokio_wasi))] +#[cfg(not(target_os = "wasi"))] use tokio_test::assert_err; use std::{ @@ -29,14 +29,14 @@ async fn pause_time_in_task() { t.await.unwrap(); } -#[cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread", worker_threads = 1)] #[should_panic] async fn pause_time_in_main_threads() { tokio::time::pause(); } -#[cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn pause_time_in_spawn_threads() { let t = tokio::spawn(async { diff --git a/tokio/tests/time_rt.rs b/tokio/tests/time_rt.rs index 20f9e181b4b..13f888c1791 100644 --- a/tokio/tests/time_rt.rs +++ b/tokio/tests/time_rt.rs @@ -5,7 +5,7 @@ use tokio::time::*; use std::sync::mpsc; -#[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] // Wasi doesn't support threads +#[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] // Wasi doesn't support threads #[test] fn timer_with_threaded_runtime() { use tokio::runtime::Runtime; diff --git a/tokio/tests/time_sleep.rs b/tokio/tests/time_sleep.rs index 94022e3c00c..4afcc12c10d 100644 --- a/tokio/tests/time_sleep.rs +++ b/tokio/tests/time_sleep.rs @@ -168,7 +168,7 @@ async fn reset_sleep_to_past() { assert_ready!(sleep.poll()); } -#[cfg(not(tokio_wasi))] // Wasi doesn't support panic recovery +#[cfg(not(target_os = "wasi"))] // Wasi doesn't support panic recovery #[test] #[should_panic] fn creating_sleep_outside_of_context() { diff --git a/tokio/tests/time_timeout.rs b/tokio/tests/time_timeout.rs index be6b8fb4462..ec871cf62fe 100644 --- a/tokio/tests/time_timeout.rs +++ b/tokio/tests/time_timeout.rs @@ -17,7 +17,7 @@ async fn simultaneous_deadline_future_completion() { assert_ready_ok!(fut.poll()); } -#[cfg_attr(tokio_wasi, ignore = "FIXME: `fut.poll()` panics on Wasi")] +#[cfg_attr(target_os = "wasi", ignore = "FIXME: `fut.poll()` panics on Wasi")] #[tokio::test] async fn completed_future_past_deadline() { // Wrap it with a deadline diff --git a/tokio/tests/udp.rs b/tokio/tests/udp.rs index 565323b3742..eea281c2316 100644 --- a/tokio/tests/udp.rs +++ b/tokio/tests/udp.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind or UDP +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind or UDP use futures::future::poll_fn; use std::io; diff --git a/tokio/tests/unwindsafe.rs b/tokio/tests/unwindsafe.rs index 3e63820864d..8ab6654295b 100644 --- a/tokio/tests/unwindsafe.rs +++ b/tokio/tests/unwindsafe.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support panic recovery +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery use std::panic::{RefUnwindSafe, UnwindSafe};