From 01b819bb1ed6eb8a61f032e60a8719ea71a4e70c Mon Sep 17 00:00:00 2001 From: manaswini05 Date: Thu, 28 Jul 2022 11:10:04 +0800 Subject: [PATCH] Revert "chore: fix version detection for `addr_of!` (#4863)" This reverts commit ffff9e65fd44a82b9d9d54321183a60dd879d0c2. --- tokio/Cargo.toml | 8 ++--- tokio/build.rs | 44 ++----------------------- tokio/src/coop.rs | 2 +- tokio/src/io/driver/mod.rs | 10 +++--- tokio/src/io/driver/registration.rs | 1 - tokio/src/io/mod.rs | 4 +-- tokio/src/io/poll_evented.rs | 34 +++++-------------- tokio/src/lib.rs | 19 +---------- tokio/src/macros/cfg.rs | 16 ++++----- tokio/src/net/tcp/listener.rs | 4 +-- tokio/src/net/tcp/stream.rs | 4 +-- tokio/src/park/thread.rs | 4 +-- tokio/src/runtime/blocking/pool.rs | 2 +- tokio/src/runtime/builder.rs | 6 ++-- tokio/src/runtime/mod.rs | 10 +++--- tokio/src/runtime/spawner.rs | 18 +++++----- tokio/src/runtime/task/mod.rs | 2 +- tokio/src/sync/tests/atomic_waker.rs | 4 +-- tokio/src/sync/tests/notify.rs | 4 +-- tokio/src/sync/tests/semaphore_batch.rs | 4 +-- tokio/src/time/driver/tests/mod.rs | 2 +- tokio/src/util/linked_list.rs | 4 +-- tokio/tests/_require_full.rs | 2 +- tokio/tests/async_send_sync.rs | 2 +- tokio/tests/buffered.rs | 2 +- tokio/tests/fs.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/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 | 6 ++-- tokio/tests/macros_pin.rs | 4 +-- tokio/tests/macros_rename_test.rs | 2 +- tokio/tests/macros_select.rs | 4 +-- tokio/tests/macros_test.rs | 2 +- tokio/tests/macros_try_join.rs | 4 +-- 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 | 16 ++++----- 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/signal_no_rt.rs | 2 +- tokio/tests/sync_barrier.rs | 2 +- tokio/tests/sync_broadcast.rs | 8 ++--- tokio/tests/sync_errors.rs | 2 +- tokio/tests/sync_mpsc.rs | 24 +++++++------- tokio/tests/sync_mutex.rs | 6 ++-- tokio/tests/sync_mutex_owned.rs | 6 ++-- tokio/tests/sync_notify.rs | 2 +- tokio/tests/sync_oneshot.rs | 8 ++--- tokio/tests/sync_panic.rs | 2 +- tokio/tests/sync_rwlock.rs | 8 ++--- tokio/tests/sync_semaphore.rs | 4 +-- tokio/tests/sync_semaphore_owned.rs | 2 +- tokio/tests/sync_watch.rs | 4 +-- tokio/tests/task_abort.rs | 2 +- tokio/tests/task_blocking.rs | 2 +- tokio/tests/task_local.rs | 2 +- tokio/tests/task_local_set.rs | 35 +++++++++++--------- 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 +- 92 files changed, 205 insertions(+), 276 deletions(-) diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 9295987a32e..ff5b1360ad4 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -117,7 +117,7 @@ mio = { version = "0.8.4", optional = true } num_cpus = { version = "1.8.0", optional = true } parking_lot = { version = "0.12.0", optional = true } -[target.'cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))'.dependencies] +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] socket2 = { version = "0.4.4", features = [ "all" ] } # Currently unstable. The API exposed by these features may be broken at any time. @@ -150,14 +150,14 @@ mockall = "0.11.1" tempfile = "3.1.0" async-stream = "0.3" -[target.'cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))'.dev-dependencies] +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] proptest = "1" socket2 = "0.4" -[target.'cfg(not(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown")))'.dev-dependencies] +[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dev-dependencies] rand = "0.8.0" -[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_os = "wasi")))'.dev-dependencies] +[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies] wasm-bindgen-test = "0.3.0" [target.'cfg(target_os = "freebsd")'.dev-dependencies] diff --git a/tokio/build.rs b/tokio/build.rs index 8b47e76559e..315d0b0d65f 100644 --- a/tokio/build.rs +++ b/tokio/build.rs @@ -10,16 +10,8 @@ const CONST_THREAD_LOCAL_PROBE: &str = r#" } "#; -const ADDR_OF_PROBE: &str = r#" -{ - let my_var = 10; - ::std::ptr::addr_of!(my_var) -} -"#; - fn main() { let mut enable_const_thread_local = false; - let mut enable_addr_of = false; match AutoCfg::new() { Ok(ac) => { @@ -43,19 +35,8 @@ fn main() { } } - // The `addr_of` and `addr_of_mut` macros were stabilized in 1.51. - if ac.probe_rustc_version(1, 52) { - enable_addr_of = true; - } else if ac.probe_rustc_version(1, 51) { - // This compiler claims to be 1.51, but there are some nightly - // compilers that claim to be 1.51 without supporting the - // feature. Explicitly probe to check if code using them - // compiles. - // - // The oldest nightly that supports the feature is 2021-01-31. - if ac.probe_expression(ADDR_OF_PROBE) { - enable_addr_of = true; - } + if !ac.probe_rustc_version(1, 51) { + autocfg::emit("tokio_no_addr_of") } } @@ -77,25 +58,4 @@ fn main() { // RUSTFLAGS="--cfg tokio_no_const_thread_local" autocfg::emit("tokio_no_const_thread_local") } - - if !enable_addr_of { - // To disable this feature on compilers that support it, you can - // explicitly pass this flag with the following environment variable: - // - // RUSTFLAGS="--cfg tokio_no_addr_of" - autocfg::emit("tokio_no_addr_of") - } - - let target = ::std::env::var("TARGET").unwrap_or_default(); - - // We emit cfgs instead of using `target_family = "wasm"` that requires Rust 1.54. - // Note that these cfgs are unavailable in `Cargo.toml`. - if target.starts_with("wasm") { - autocfg::emit("tokio_wasm"); - if target.contains("wasi") { - autocfg::emit("tokio_wasi"); - } else { - autocfg::emit("tokio_wasm_not_wasi"); - } - } } diff --git a/tokio/src/coop.rs b/tokio/src/coop.rs index 3d15a53f25d..1ed1d17aa9f 100644 --- a/tokio/src/coop.rs +++ b/tokio/src/coop.rs @@ -207,7 +207,7 @@ cfg_coop! { mod test { use super::*; - #[cfg(tokio_wasm_not_wasi)] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; fn get() -> Budget { diff --git a/tokio/src/io/driver/mod.rs b/tokio/src/io/driver/mod.rs index 9801a22c4a9..5d9e114a604 100644 --- a/tokio/src/io/driver/mod.rs +++ b/tokio/src/io/driver/mod.rs @@ -73,7 +73,7 @@ pub(super) struct Inner { /// 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, metrics: IoDriverMetrics, @@ -117,7 +117,7 @@ impl Driver { /// creation. pub(crate) fn new() -> io::Result { 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()?; @@ -132,7 +132,7 @@ impl Driver { inner: Arc::new(Inner { registry, io_dispatch: RwLock::new(IoDispatcher::new(allocator)), - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] waker, metrics: IoDriverMetrics::default(), }), @@ -168,7 +168,7 @@ impl Driver { match self.poll.poll(&mut 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. @@ -310,7 +310,7 @@ impl Handle { /// blocked in `turn`, then the next call to `turn` will not block and /// return immediately. fn wakeup(&self) { - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] self.inner.waker.wake().expect("failed to wake I/O driver"); } } diff --git a/tokio/src/io/driver/registration.rs b/tokio/src/io/driver/registration.rs index b765976bbb1..c9393650c20 100644 --- a/tokio/src/io/driver/registration.rs +++ b/tokio/src/io/driver/registration.rs @@ -115,7 +115,6 @@ 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))] pub(crate) fn poll_read_io( &self, cx: &mut Context<'_>, diff --git a/tokio/src/io/mod.rs b/tokio/src/io/mod.rs index 3f6cc6b720d..7113af0c363 100644 --- a/tokio/src/io/mod.rs +++ b/tokio/src/io/mod.rs @@ -211,11 +211,11 @@ cfg_io_driver_impl! { pub use driver::{Interest, 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/io/poll_evented.rs b/tokio/src/io/poll_evented.rs index f495fddd138..25cece62764 100644 --- a/tokio/src/io/poll_evented.rs +++ b/tokio/src/io/poll_evented.rs @@ -153,32 +153,16 @@ feature! { { use std::io::Read; - loop { - let evt = ready!(self.registration.poll_read_ready(cx))?; - + let n = ready!(self.registration.poll_read_io(cx, || { let b = &mut *(buf.unfilled_mut() as *mut [std::mem::MaybeUninit] as *mut [u8]); - let len = b.len(); - - match self.io.as_ref().unwrap().read(b) { - Ok(n) => { - // if we read a partially full buffer, this is sufficient on unix to show - // that the socket buffer has been drained - if n > 0 && (!cfg!(windows) && n < len) { - self.registration.clear_readiness(evt); - } - - // Safety: We trust `TcpStream::read` to have filled up `n` bytes in the - // buffer. - buf.assume_init(n); - buf.advance(n); - return Poll::Ready(Ok(())); - }, - Err(e) if e.kind() == io::ErrorKind::WouldBlock => { - self.registration.clear_readiness(evt); - } - Err(e) => return Poll::Ready(Err(e)), - } - } + self.io.as_ref().unwrap().read(b) + }))?; + + // Safety: We trust `TcpStream::read` to have filled up `n` bytes in the + // buffer. + buf.assume_init(n); + buf.advance(n); + Poll::Ready(Ok(())) } pub(crate) fn poll_write<'a>(&'a self, cx: &mut Context<'_>, buf: &[u8]) -> Poll> diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index 3897de5340a..e8ddf16b39e 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -393,26 +393,9 @@ 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(tokio_wasm)), - all(target_arch = "wasm64", not(tokio_wasm)), - all(target_family = "wasm", not(tokio_wasm)), - all(target_os = "wasi", not(tokio_wasm)), - all(target_os = "wasi", not(tokio_wasi)), - all(target_os = "wasi", tokio_wasm_not_wasi), - all(tokio_wasm, not(any(target_arch = "wasm32", target_arch = "wasm64"))), - all(tokio_wasm_not_wasi, not(tokio_wasm)), - all(tokio_wasi, not(tokio_wasm)) -))] -compile_error!("Tokio's build script has incorrectly detected wasm."); - #[cfg(all( not(tokio_unstable), - tokio_wasm, + target_arch = "wasm32", any( feature = "fs", feature = "io-std", diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index 287f072acde..f728722132d 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -61,7 +61,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 )* @@ -252,7 +252,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 )* } @@ -281,7 +281,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 )* } @@ -341,7 +341,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 )* @@ -459,7 +459,7 @@ macro_rules! cfg_has_atomic_u64 { target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32", - tokio_wasm + target_arch = "wasm32" )))] $item )* @@ -474,7 +474,7 @@ macro_rules! cfg_not_has_atomic_u64 { target_arch = "mips", target_arch = "powerpc", target_arch = "riscv32", - tokio_wasm + target_arch = "wasm32" ))] $item )* @@ -484,7 +484,7 @@ macro_rules! cfg_not_has_atomic_u64 { macro_rules! cfg_not_wasi { ($($item:item)*) => { $( - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] $item )* } @@ -493,7 +493,7 @@ macro_rules! cfg_not_wasi { macro_rules! cfg_is_wasm_not_wasi { ($($item:item)*) => { $( - #[cfg(tokio_wasm_not_wasi)] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] $item )* } diff --git a/tokio/src/net/tcp/listener.rs b/tokio/src/net/tcp/listener.rs index 4a022fa2a2c..23e9cd23329 100644 --- a/tokio/src/net/tcp/listener.rs +++ b/tokio/src/net/tcp/listener.rs @@ -275,7 +275,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 @@ -403,7 +403,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 19e3ead80fb..142f70bc662 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -252,7 +252,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 @@ -1334,7 +1334,7 @@ mod sys { } } -#[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/park/thread.rs b/tokio/src/park/thread.rs index 7b35ba38e28..b42b73fe0fe 100644 --- a/tokio/src/park/thread.rs +++ b/tokio/src/park/thread.rs @@ -65,9 +65,9 @@ impl Park for ParkThread { fn park_timeout(&mut self, duration: Duration) -> Result<(), Self::Error> { // Wasi doesn't have threads, so just sleep. - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] self.inner.park_timeout(duration); - #[cfg(tokio_wasi)] + #[cfg(target_os = "wasi")] std::thread::sleep(duration); Ok(()) } diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs index 19315388563..98edd6908b2 100644 --- a/tokio/src/runtime/blocking/pool.rs +++ b/tokio/src/runtime/blocking/pool.rs @@ -125,7 +125,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/builder.rs b/tokio/src/runtime/builder.rs index 2f678aa72e2..fff1b3ad64b 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -174,7 +174,7 @@ pub(crate) type ThreadNameFn = std::sync::Arc String + Send + Sync + 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, } @@ -619,7 +619,7 @@ impl Builder { pub fn build(&mut self) -> io::Result { match &self.kind { Kind::CurrentThread => self.build_basic_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(), } } @@ -628,7 +628,7 @@ 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, }, enable_io: self.enable_io, diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index ff06b70eb2d..c0e2d96db8a 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -174,7 +174,7 @@ // At the top due to macros #[cfg(test)] -#[cfg(not(tokio_wasm))] +#[cfg(not(target_arch = "wasm32"))] #[macro_use] mod tests; @@ -204,7 +204,7 @@ cfg_rt! { mod blocking; use blocking::BlockingPool; - #[cfg_attr(tokio_wasi, allow(unused_imports))] + #[cfg_attr(target_os = "wasi", allow(unused_imports))] pub(crate) use blocking::spawn_blocking; cfg_trace! { @@ -304,7 +304,7 @@ cfg_rt! { CurrentThread(BasicScheduler), /// Execute tasks across multiple threads. - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] ThreadPool(ThreadPool), } @@ -484,7 +484,7 @@ cfg_rt! { match &self.kind { Kind::CurrentThread(exec) => exec.block_on(future), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Kind::ThreadPool(exec) => exec.block_on(future), } } @@ -614,7 +614,7 @@ cfg_rt! { }, } }, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Kind::ThreadPool(_) => { // The threaded scheduler drops its tasks on its worker threads, which is // already in the runtime's context. diff --git a/tokio/src/runtime/spawner.rs b/tokio/src/runtime/spawner.rs index 090a54c0627..dd1f6da24ae 100644 --- a/tokio/src/runtime/spawner.rs +++ b/tokio/src/runtime/spawner.rs @@ -10,13 +10,13 @@ cfg_rt_multi_thread! { #[derive(Debug, Clone)] pub(crate) enum Spawner { Basic(basic_scheduler::Spawner), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] ThreadPool(thread_pool::Spawner), } impl Spawner { pub(crate) fn shutdown(&mut self) { - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] { if let Spawner::ThreadPool(spawner) = self { spawner.shutdown(); @@ -31,7 +31,7 @@ impl Spawner { { match self { Spawner::Basic(spawner) => spawner.spawn(future, id), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Spawner::ThreadPool(spawner) => spawner.spawn(future, id), } } @@ -39,7 +39,7 @@ impl Spawner { pub(crate) fn as_handle_inner(&self) -> &HandleInner { match self { Spawner::Basic(spawner) => spawner.as_handle_inner(), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Spawner::ThreadPool(spawner) => spawner.as_handle_inner(), } } @@ -52,7 +52,7 @@ cfg_metrics! { pub(crate) fn num_workers(&self) -> usize { match self { Spawner::Basic(_) => 1, - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Spawner::ThreadPool(spawner) => spawner.num_workers(), } } @@ -60,7 +60,7 @@ cfg_metrics! { pub(crate) fn scheduler_metrics(&self) -> &SchedulerMetrics { match self { Spawner::Basic(spawner) => spawner.scheduler_metrics(), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Spawner::ThreadPool(spawner) => spawner.scheduler_metrics(), } } @@ -68,7 +68,7 @@ cfg_metrics! { pub(crate) fn worker_metrics(&self, worker: usize) -> &WorkerMetrics { match self { Spawner::Basic(spawner) => spawner.worker_metrics(worker), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Spawner::ThreadPool(spawner) => spawner.worker_metrics(worker), } } @@ -76,7 +76,7 @@ cfg_metrics! { pub(crate) fn injection_queue_depth(&self) -> usize { match self { Spawner::Basic(spawner) => spawner.injection_queue_depth(), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Spawner::ThreadPool(spawner) => spawner.injection_queue_depth(), } } @@ -84,7 +84,7 @@ cfg_metrics! { pub(crate) fn worker_local_queue_depth(&self, worker: usize) -> usize { match self { Spawner::Basic(spawner) => spawner.worker_metrics(worker).queue_depth(), - #[cfg(all(feature = "rt-multi-thread", not(tokio_wasi)))] + #[cfg(all(feature = "rt-multi-thread", not(target_os = "wasi")))] Spawner::ThreadPool(spawner) => spawner.worker_local_queue_depth(worker), } } diff --git a/tokio/src/runtime/task/mod.rs b/tokio/src/runtime/task/mod.rs index 350b6442ad0..46aa62b14d1 100644 --- a/tokio/src/runtime/task/mod.rs +++ b/tokio/src/runtime/task/mod.rs @@ -389,7 +389,7 @@ impl LocalNotified { impl UnownedTask { // Used in test of the inject queue. #[cfg(test)] - #[cfg_attr(tokio_wasm, allow(dead_code))] + #[cfg_attr(target_arch = "wasm32", allow(dead_code))] pub(super) fn into_notified(self) -> Notified { Notified(self.into_task()) } diff --git a/tokio/src/sync/tests/atomic_waker.rs b/tokio/src/sync/tests/atomic_waker.rs index b52d46c775e..34bb9fbe782 100644 --- a/tokio/src/sync/tests/atomic_waker.rs +++ b/tokio/src/sync/tests/atomic_waker.rs @@ -12,7 +12,7 @@ impl AssertSync for AtomicWaker {} impl AssertSend for Waker {} impl AssertSync for Waker {} -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; #[test] @@ -37,7 +37,7 @@ fn wake_without_register() { } #[test] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding fn atomic_waker_panic_safe() { use std::panic; use std::ptr; diff --git a/tokio/src/sync/tests/notify.rs b/tokio/src/sync/tests/notify.rs index eb0da8faad6..858752b6fe5 100644 --- a/tokio/src/sync/tests/notify.rs +++ b/tokio/src/sync/tests/notify.rs @@ -4,7 +4,7 @@ use std::mem::ManuallyDrop; use std::sync::Arc; use std::task::{Context, RawWaker, RawWakerVTable, Waker}; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; #[test] @@ -63,7 +63,7 @@ fn notify_simple() { } #[test] -#[cfg(not(tokio_wasm))] +#[cfg(not(target_arch = "wasm32"))] fn watch_test() { let rt = crate::runtime::Builder::new_current_thread() .build() diff --git a/tokio/src/sync/tests/semaphore_batch.rs b/tokio/src/sync/tests/semaphore_batch.rs index d4e35aa7b2f..103e09dea4f 100644 --- a/tokio/src/sync/tests/semaphore_batch.rs +++ b/tokio/src/sync/tests/semaphore_batch.rs @@ -1,7 +1,7 @@ use crate::sync::batch_semaphore::Semaphore; use tokio_test::*; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; #[test] @@ -170,7 +170,7 @@ fn poll_acquire_one_zero_permits() { #[test] #[should_panic] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding fn validates_max_permits() { use std::usize; Semaphore::new((usize::MAX >> 2) + 1); diff --git a/tokio/src/time/driver/tests/mod.rs b/tokio/src/time/driver/tests/mod.rs index efccd57253a..fbe000f0f82 100644 --- a/tokio/src/time/driver/tests/mod.rs +++ b/tokio/src/time/driver/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/util/linked_list.rs b/tokio/src/util/linked_list.rs index 9698f727f4f..af963204467 100644 --- a/tokio/src/util/linked_list.rs +++ b/tokio/src/util/linked_list.rs @@ -623,7 +623,7 @@ mod tests { } } - #[cfg(not(tokio_wasm))] + #[cfg(not(target_arch = "wasm32"))] proptest::proptest! { #[test] fn fuzz_linked_list(ops: Vec) { @@ -631,7 +631,7 @@ mod tests { } } - #[cfg(not(tokio_wasm))] + #[cfg(not(target_arch = "wasm32"))] fn run_fuzz(ops: Vec) { use std::collections::VecDeque; diff --git a/tokio/tests/_require_full.rs b/tokio/tests/_require_full.rs index a339374fd86..3abda2629cf 100644 --- a/tokio/tests/_require_full.rs +++ b/tokio/tests/_require_full.rs @@ -1,2 +1,2 @@ -#![cfg(not(any(feature = "full", tokio_wasm)))] +#![cfg(not(any(feature = "full", target_arch = "wasm32")))] compile_error!("run main Tokio tests with `--features full`"); diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs index e85c54b3cc8..397e55fa55f 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 19afebd392a..2ae1100448f 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_copy.rs b/tokio/tests/fs_copy.rs index 04678cf05b4..e32aebd939b 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 file operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations use tempfile::tempdir; use tokio::fs; diff --git a/tokio/tests/fs_dir.rs b/tokio/tests/fs_dir.rs index f197a40ac95..21391e27b56 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 directory operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support directory 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 9cecb6c4342..55ff24183c6 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 file operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations use std::io::prelude::*; use tempfile::NamedTempFile; diff --git a/tokio/tests/fs_link.rs b/tokio/tests/fs_link.rs index d198abc5182..9a83df523b9 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 file operations +#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations use tokio::fs; diff --git a/tokio/tests/io_copy_bidirectional.rs b/tokio/tests/io_copy_bidirectional.rs index 600427866ef..679d78dc1a7 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 2ca56301de0..650e66c8b2a 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..055b1f6b69c 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 does not support panic recovery struct PanicsOnDrop; diff --git a/tokio/tests/macros_join.rs b/tokio/tests/macros_join.rs index 0efbd83c3ea..b2969557f45 100644 --- a/tokio/tests/macros_join.rs +++ b/tokio/tests/macros_join.rs @@ -2,12 +2,12 @@ #![allow(clippy::blacklisted_name)] use std::sync::Arc; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", 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..001528ddeb0 100644 --- a/tokio/tests/macros_pin.rs +++ b/tokio/tests/macros_pin.rs @@ -1,9 +1,9 @@ #![cfg(feature = "macros")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", 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 90a86f9722b..a99c921e11d 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 23162a1a918..c7297b52884 100644 --- a/tokio/tests/macros_select.rs +++ b/tokio/tests/macros_select.rs @@ -1,10 +1,10 @@ #![cfg(feature = "macros")] #![allow(clippy::blacklisted_name)] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::oneshot; diff --git a/tokio/tests/macros_test.rs b/tokio/tests/macros_test.rs index 60809f2b8e9..311067ecdfd 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 681b1b7bc68..876de0b496a 100644 --- a/tokio/tests/macros_try_join.rs +++ b/tokio/tests/macros_try_join.rs @@ -6,10 +6,10 @@ use std::sync::Arc; use tokio::sync::{oneshot, Semaphore}; use tokio_test::{assert_pending, assert_ready, task}; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", 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 1c604aa534c..d279fe4a15e 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 ee5f6e4bc6e..d2d80ef5020 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 0cb92487af3..73bafdc4d5c 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 e8b5f526c1e..7ff6ae3f120 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -18,7 +18,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)* @@ -32,7 +32,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)* @@ -675,7 +675,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(); @@ -704,7 +704,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!() }); @@ -935,7 +935,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; @@ -980,7 +980,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(); @@ -1002,7 +1002,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(); @@ -1016,7 +1016,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_block_on.rs b/tokio/tests/rt_handle_block_on.rs index b5d5889d470..e8f3993aa03 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) @@ -516,7 +516,7 @@ where f(); } - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] { println!("multi thread (1 thread) runtime"); @@ -529,7 +529,7 @@ where f(); } - #[cfg(not(tokio_wasi))] + #[cfg(not(target_os = "wasi"))] { println!("multi thread (4 threads) runtime"); diff --git a/tokio/tests/rt_metrics.rs b/tokio/tests/rt_metrics.rs index 914723445cd..3b8070533cf 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 tokio::runtime::Runtime; use tokio::time::{self, Duration}; diff --git a/tokio/tests/rt_panic.rs b/tokio/tests/rt_panic.rs index 03c6a3c6836..1488c9dcd22 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 dd137fa9b18..187cd557b37 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/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..afd3ef16b5f 100644 --- a/tokio/tests/sync_barrier.rs +++ b/tokio/tests/sync_barrier.rs @@ -2,7 +2,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "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 cee888dd2c0..7ca8281ce3e 100644 --- a/tokio/tests/sync_broadcast.rs +++ b/tokio/tests/sync_broadcast.rs @@ -2,7 +2,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::broadcast; @@ -276,14 +276,14 @@ fn send_no_rx() { #[test] #[should_panic] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // 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_arch = "wasm32"))] // wasm currently doesn't support unwinding fn capacity_too_big() { use std::usize; @@ -291,7 +291,7 @@ fn capacity_too_big() { } #[test] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding fn panic_in_clone() { use std::panic::{self, AssertUnwindSafe}; diff --git a/tokio/tests/sync_errors.rs b/tokio/tests/sync_errors.rs index bf0a6cf7374..3dd42fad2f6 100644 --- a/tokio/tests/sync_errors.rs +++ b/tokio/tests/sync_errors.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "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 99c22931e77..a1510f57d09 100644 --- a/tokio/tests/sync_mpsc.rs +++ b/tokio/tests/sync_mpsc.rs @@ -2,12 +2,12 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::mpsc; @@ -16,7 +16,7 @@ use tokio_test::*; use std::sync::Arc; -#[cfg(not(tokio_wasm))] +#[cfg(not(target_arch = "wasm32"))] mod support { pub(crate) mod mpsc_stream; } @@ -88,7 +88,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; @@ -155,7 +155,7 @@ async fn start_send_past_cap() { #[test] #[should_panic] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding fn buffer_gteq_one() { mpsc::channel::(0); } @@ -192,7 +192,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; @@ -453,7 +453,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); @@ -471,14 +471,14 @@ fn blocking_recv() { #[tokio::test] #[should_panic] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding async fn blocking_recv_async() { let (_tx, mut rx) = mpsc::channel::<()>(1); let _ = rx.blocking_recv(); } #[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); @@ -496,7 +496,7 @@ fn blocking_send() { #[tokio::test] #[should_panic] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding async fn blocking_send_async() { let (tx, _rx) = mpsc::channel::<()>(1); let _ = tx.blocking_send(()); @@ -649,7 +649,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_arch = "wasm32"))] // wasm currently doesn't support unwinding fn recv_timeout_panic() { use futures::future::FutureExt; use tokio::time::Duration; diff --git a/tokio/tests/sync_mutex.rs b/tokio/tests/sync_mutex.rs index e7650dcc4eb..ef60a348f93 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)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", 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..5fb48ec8a0a 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)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", 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..4bbc71c5054 100644 --- a/tokio/tests/sync_notify.rs +++ b/tokio/tests/sync_notify.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::Notify; diff --git a/tokio/tests/sync_oneshot.rs b/tokio/tests/sync_oneshot.rs index 15b6923701f..76194abae1f 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)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))] use tokio::test as maybe_tokio_test; use tokio::sync::oneshot; @@ -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_arch = "wasm32"))] // wasm currently doesn't support unwinding fn close_try_recv_poll() { let (_tx, rx) = oneshot::channel::(); let mut rx = task::spawn(rx); diff --git a/tokio/tests/sync_panic.rs b/tokio/tests/sync_panic.rs index 73bf67d97aa..fb81ad8b4dd 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; use tokio::{ diff --git a/tokio/tests/sync_rwlock.rs b/tokio/tests/sync_rwlock.rs index afad39eb481..ff10fa324db 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)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; -#[cfg(not(tokio_wasm_not_wasi))] +#[cfg(not(all(target_arch = "wasm32", 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 a061033ed7d..fe5807c8e7e 100644 --- a/tokio/tests/sync_semaphore.rs +++ b/tokio/tests/sync_semaphore.rs @@ -1,6 +1,6 @@ #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; @@ -93,7 +93,7 @@ fn add_max_amount_permits() { assert_eq!(s.available_permits(), usize::MAX >> 3); } -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding #[test] #[should_panic] fn add_more_than_max_amount_permits() { diff --git a/tokio/tests/sync_semaphore_owned.rs b/tokio/tests/sync_semaphore_owned.rs index a09346f17f8..c01add3cacc 100644 --- a/tokio/tests/sync_semaphore_owned.rs +++ b/tokio/tests/sync_semaphore_owned.rs @@ -1,6 +1,6 @@ #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; diff --git a/tokio/tests/sync_watch.rs b/tokio/tests/sync_watch.rs index 34f9b786710..13aecc25971 100644 --- a/tokio/tests/sync_watch.rs +++ b/tokio/tests/sync_watch.rs @@ -2,7 +2,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "sync")] -#[cfg(tokio_wasm_not_wasi)] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use tokio::sync::watch; @@ -213,7 +213,7 @@ fn reopened_after_subscribe() { } #[test] -#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding +#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding fn send_modify_panic() { let (tx, mut rx) = watch::channel("one"); diff --git a/tokio/tests/task_abort.rs b/tokio/tests/task_abort.rs index bf64edae937..2c165d00383 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 c35da99a175..46307b03fef 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}; use tokio_test::assert_ok; diff --git a/tokio/tests/task_local.rs b/tokio/tests/task_local.rs index a1fab08950d..f0da060b1a4 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 use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; diff --git a/tokio/tests/task_local_set.rs b/tokio/tests/task_local_set.rs index 1d2f76ce14b..77920a44765 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_basic_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! { @@ -384,7 +384,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. @@ -408,7 +411,7 @@ fn drop_cancels_remote_tasks() { } #[cfg_attr( - tokio_wasi, + target_os = "wasi", ignore = "FIXME: `task::spawn_local().await.unwrap()` panics on Wasi" )] #[test] @@ -432,7 +435,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. @@ -449,7 +452,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 451243d2e6b..661bbe23625 100644 --- a/tokio/tests/task_panic.rs +++ b/tokio/tests/task_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 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 e1359c936ea..269ba8ef695 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 03813c2e46c..606e23e7c16 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 d67c9f4a03d..faead95c0bb 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 8cea82fb615..a1fc39af25c 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 453023fc51d..f1048f93898 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 2f505ef77a6..cb06f44522a 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 3a4bd856226..3652b0bc448 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 93f63503821..787f6329a16 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 0d42b520f03..5a29525d421 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 98cf5b1b044..23fc1b2a4ac 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};