Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use target_family wasm instead of wasm32 #4864

Merged
merged 3 commits into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions tokio/Cargo.toml
Expand Up @@ -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(target_arch = "wasm32"))'.dependencies]
[target.'cfg(not(target_family = "wasm"))'.dependencies]
socket2 = { version = "0.4.4", features = [ "all" ] }

# Currently unstable. The API exposed by these features may be broken at any time.
Expand Down Expand Up @@ -150,14 +150,14 @@ mockall = "0.11.1"
tempfile = "3.1.0"
async-stream = "0.3"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
proptest = "1"
socket2 = "0.4"

[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dev-dependencies]
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dev-dependencies]
rand = "0.8.0"

[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
[target.'cfg(all(target_family = "wasm", not(target_os = "wasi")))'.dev-dependencies]
wasm-bindgen-test = "0.3.0"

[target.'cfg(target_os = "freebsd")'.dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/coop.rs
Expand Up @@ -207,7 +207,7 @@ cfg_coop! {
mod test {
use super::*;

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

fn get() -> Budget {
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/io/driver/registration.rs
Expand Up @@ -115,7 +115,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(all(target_arch = "wasm32", target_os = "wasi")))]
#[cfg(not(all(target_family = "wasm", target_os = "wasi")))]
pub(crate) fn poll_read_io<R>(
&self,
cx: &mut Context<'_>,
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/lib.rs
Expand Up @@ -395,7 +395,7 @@ compile_error! {

#[cfg(all(
not(tokio_unstable),
target_arch = "wasm32",
target_family = "wasm",
any(
feature = "fs",
feature = "io-std",
Expand Down
6 changes: 3 additions & 3 deletions tokio/src/macros/cfg.rs
Expand Up @@ -459,7 +459,7 @@ macro_rules! cfg_has_atomic_u64 {
target_arch = "mips",
target_arch = "powerpc",
target_arch = "riscv32",
target_arch = "wasm32"
target_family = "wasm"
)))]
$item
)*
Expand All @@ -474,7 +474,7 @@ macro_rules! cfg_not_has_atomic_u64 {
target_arch = "mips",
target_arch = "powerpc",
target_arch = "riscv32",
target_arch = "wasm32"
target_family = "wasm"
))]
$item
)*
Expand All @@ -493,7 +493,7 @@ macro_rules! cfg_not_wasi {
macro_rules! cfg_is_wasm_not_wasi {
($($item:item)*) => {
$(
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
$item
)*
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/mod.rs
Expand Up @@ -174,7 +174,7 @@

// At the top due to macros
#[cfg(test)]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
#[macro_use]
mod tests;

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/task/mod.rs
Expand Up @@ -389,7 +389,7 @@ impl<S: Schedule> LocalNotified<S> {
impl<S: Schedule> UnownedTask<S> {
// Used in test of the inject queue.
#[cfg(test)]
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
#[cfg_attr(target_family = "wasm", allow(dead_code))]
pub(super) fn into_notified(self) -> Notified<S> {
Notified(self.into_task())
}
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/sync/tests/atomic_waker.rs
Expand Up @@ -12,7 +12,7 @@ impl AssertSync for AtomicWaker {}
impl AssertSend for Waker {}
impl AssertSync for Waker {}

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
Expand All @@ -37,7 +37,7 @@ fn wake_without_register() {
}

#[test]
#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn atomic_waker_panic_safe() {
use std::panic;
use std::ptr;
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/sync/tests/notify.rs
Expand Up @@ -4,7 +4,7 @@ use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
Expand Down Expand Up @@ -63,7 +63,7 @@ fn notify_simple() {
}

#[test]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
fn watch_test() {
let rt = crate::runtime::Builder::new_current_thread()
.build()
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/sync/tests/semaphore_batch.rs
@@ -1,7 +1,7 @@
use crate::sync::batch_semaphore::Semaphore;
use tokio_test::*;

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
Expand Down Expand Up @@ -170,7 +170,7 @@ fn poll_acquire_one_zero_permits() {

#[test]
#[should_panic]
#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn validates_max_permits() {
use std::usize;
Semaphore::new((usize::MAX >> 2) + 1);
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/util/linked_list.rs
Expand Up @@ -623,15 +623,15 @@ mod tests {
}
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
proptest::proptest! {
#[test]
fn fuzz_linked_list(ops: Vec<usize>) {
run_fuzz(ops);
}
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
fn run_fuzz(ops: Vec<usize>) {
use std::collections::VecDeque;

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/_require_full.rs
@@ -1,2 +1,2 @@
#![cfg(not(any(feature = "full", target_arch = "wasm32")))]
#![cfg(not(any(feature = "full", target_family = "wasm")))]
compile_error!("run main Tokio tests with `--features full`");
6 changes: 3 additions & 3 deletions tokio/tests/macros_join.rs
Expand Up @@ -2,12 +2,12 @@
#![allow(clippy::blacklisted_name)]
use std::sync::Arc;

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test;

#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
use tokio::test as maybe_tokio_test;

use tokio::sync::{oneshot, Semaphore};
Expand Down
4 changes: 2 additions & 2 deletions tokio/tests/macros_pin.rs
@@ -1,9 +1,9 @@
#![cfg(feature = "macros")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test;

#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
use tokio::test as maybe_tokio_test;

async fn one() {}
Expand Down
4 changes: 2 additions & 2 deletions tokio/tests/macros_select.rs
@@ -1,10 +1,10 @@
#![cfg(feature = "macros")]
#![allow(clippy::blacklisted_name)]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test;

#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
use tokio::test as maybe_tokio_test;

use tokio::sync::oneshot;
Expand Down
4 changes: 2 additions & 2 deletions tokio/tests/macros_try_join.rs
Expand Up @@ -6,10 +6,10 @@ use std::sync::Arc;
use tokio::sync::{oneshot, Semaphore};
use tokio_test::{assert_pending, assert_ready, task};

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test;

#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
use tokio::test as maybe_tokio_test;

#[maybe_tokio_test]
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/sync_barrier.rs
Expand Up @@ -2,7 +2,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

use tokio::sync::Barrier;
Expand Down
8 changes: 4 additions & 4 deletions tokio/tests/sync_broadcast.rs
Expand Up @@ -2,7 +2,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

use tokio::sync::broadcast;
Expand Down Expand Up @@ -276,22 +276,22 @@ fn send_no_rx() {

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

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

broadcast::channel::<()>(1 + (usize::MAX >> 1));
}

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

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/sync_errors.rs
@@ -1,7 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

fn is_error<T: std::error::Error + Send + Sync>() {}
Expand Down
16 changes: 8 additions & 8 deletions tokio/tests/sync_mpsc.rs
Expand Up @@ -2,12 +2,12 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test;

#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
use tokio::test as maybe_tokio_test;

use tokio::sync::mpsc;
Expand All @@ -16,7 +16,7 @@ use tokio_test::*;

use std::sync::Arc;

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

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

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

#[tokio::test]
#[should_panic]
#[cfg(not(target_arch = "wasm32"))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
async fn blocking_send_async() {
let (tx, _rx) = mpsc::channel::<()>(1);
let _ = tx.blocking_send(());
Expand Down Expand Up @@ -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(target_arch = "wasm32"))] // wasm currently doesn't support unwinding
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn recv_timeout_panic() {
use futures::future::FutureExt;
use tokio::time::Duration;
Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/sync_mutex.rs
@@ -1,12 +1,12 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test;

#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
use tokio::test as maybe_tokio_test;

use tokio::sync::Mutex;
Expand Down
6 changes: 3 additions & 3 deletions tokio/tests/sync_mutex_owned.rs
@@ -1,12 +1,12 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test;

#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))]
#[cfg(not(all(target_family = "wasm", not(target_os = "wasi"))))]
use tokio::test as maybe_tokio_test;

use tokio::sync::Mutex;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/sync_notify.rs
@@ -1,7 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]

#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;

use tokio::sync::Notify;
Expand Down