Skip to content

Commit

Permalink
fixup: enable more tests for Wasi
Browse files Browse the repository at this point in the history
Also adding comments when a test is disabled.

Signed-off-by: Richard Zak <richard@profian.com>
  • Loading branch information
rjzak committed Jul 11, 2022
1 parent af6a351 commit aeedf12
Show file tree
Hide file tree
Showing 71 changed files with 117 additions and 177 deletions.
2 changes: 1 addition & 1 deletion tokio-stream/tests/stream_panic.rs
@@ -1,6 +1,6 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "time")]
#![cfg(not(target_os = "wasi"))]
#![cfg(not(target_os = "wasi"))] // Wasi does not support panic recovery

use parking_lot::{const_mutex, Mutex};
use std::error::Error;
Expand Down
1 change: 0 additions & 1 deletion tokio-stream/tests/watch.rs
Expand Up @@ -5,7 +5,6 @@ use tokio_stream::wrappers::WatchStream;
use tokio_stream::StreamExt;

#[tokio::test]
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
async fn message_not_twice() {
let (tx, rx) = watch::channel("hello");

Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/context.rs
@@ -1,5 +1,5 @@
#![cfg(feature = "rt")]
#![cfg(not(target_os = "wasi"))]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads
#![warn(rust_2018_idioms)]

use tokio::runtime::Builder;
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/io_sync_bridge.rs
@@ -1,5 +1,5 @@
#![cfg(feature = "io-util")]
#![cfg(not(target_os = "wasi"))]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads

use std::error::Error;
use std::io::{Cursor, Read, Result as IoResult};
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/panic.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery

use parking_lot::{const_mutex, Mutex};
use std::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/spawn_pinned.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(not(target_os = "wasi"))]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads

use std::rc::Rc;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/udp.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(not(target_os = "wasi"))]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support UDP

use tokio::net::UdpSocket;
use tokio_stream::StreamExt;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/async_send_sync.rs
Expand Up @@ -200,6 +200,7 @@ async_assert_fn!(tokio::net::TcpStream::readable(_): Send & Sync & !Unpin);
async_assert_fn!(tokio::net::TcpStream::ready(_, tokio::io::Interest): Send & Sync & !Unpin);
async_assert_fn!(tokio::net::TcpStream::writable(_): Send & Sync & !Unpin);

// Wasi does not support UDP
cfg_not_wasi! {
mod udp_socket {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/buffered.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind()

use tokio::net::TcpListener;
use tokio_test::assert_ok;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations

use tokio::fs;
use tokio_test::assert_ok;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs_copy.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations

use tempfile::tempdir;
use tokio::fs;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs_dir.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support directory operations

use tokio::fs;
use tokio_test::{assert_err, assert_ok};
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs_file.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations

use std::io::prelude::*;
use tempfile::NamedTempFile;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs_link.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations

use tokio::fs;

Expand Down
5 changes: 0 additions & 5 deletions tokio/tests/io_buf_reader.rs
Expand Up @@ -222,8 +222,6 @@ async fn test_short_reads() {
assert_eq!(reader.read(&mut buf).await.unwrap(), 0);
}

// https://github.com/tokio-rs/mio/pull/1580
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn maybe_pending() {
let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
Expand Down Expand Up @@ -261,7 +259,6 @@ async fn maybe_pending() {
assert_eq!(reader.read(&mut buf).await.unwrap(), 0);
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn maybe_pending_buf_read() {
let inner = MaybePending::new(&[0, 1, 2, 3, 1, 0]);
Expand All @@ -280,8 +277,6 @@ async fn maybe_pending_buf_read() {
assert_eq!(v, []);
}

// https://github.com/rust-lang/futures-rs/pull/1573#discussion_r281162309
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn maybe_pending_seek() {
struct MaybePendingSeek<'a> {
Expand Down
4 changes: 0 additions & 4 deletions tokio/tests/io_buf_writer.rs
Expand Up @@ -131,8 +131,6 @@ async fn buf_writer_seek() {
assert_eq!(&w.into_inner().into_inner()[..], &[0, 1, 8, 9, 4, 5, 6, 7]);
}

// https://github.com/tokio-rs/mio/pull/1580
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn maybe_pending_buf_writer() {
let mut writer = BufWriter::with_capacity(2, MaybePending::new(Vec::new()));
Expand Down Expand Up @@ -181,7 +179,6 @@ async fn maybe_pending_buf_writer() {
);
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn maybe_pending_buf_writer_inner_flushes() {
let mut w = BufWriter::with_capacity(3, MaybePending::new(Vec::new()));
Expand All @@ -192,7 +189,6 @@ async fn maybe_pending_buf_writer_inner_flushes() {
assert_eq!(w, [0, 1]);
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn maybe_pending_buf_writer_seek() {
struct MaybePendingSeek {
Expand Down
2 changes: 0 additions & 2 deletions tokio/tests/io_copy.rs
Expand Up @@ -37,8 +37,6 @@ async fn copy() {
assert_eq!(wr, b"hello world");
}

// https://github.com/tokio-rs/mio/pull/1580
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn proxy() {
struct BufferedWd {
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_copy_bidirectional.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![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};
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_driver.rs
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
// Wasi does not support panic recovery or threading
#![cfg(all(feature = "full", not(target_os = "wasi")))]

use tokio::net::TcpListener;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_driver_drop.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind

use tokio::net::TcpListener;
use tokio::runtime;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_fill_buf.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support file operations

use tempfile::NamedTempFile;
use tokio::fs::File;
Expand Down
6 changes: 0 additions & 6 deletions tokio/tests/io_mem_stream.rs
Expand Up @@ -18,8 +18,6 @@ async fn ping_pong() {
assert_eq!(&buf, b"pong");
}

// https://github.com/tokio-rs/mio/pull/1580
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn across_tasks() {
let (mut a, mut b) = duplex(32);
Expand All @@ -42,7 +40,6 @@ async fn across_tasks() {
t2.await.unwrap();
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn disconnect() {
let (mut a, mut b) = duplex(32);
Expand All @@ -65,7 +62,6 @@ async fn disconnect() {
t2.await.unwrap();
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn disconnect_reader() {
let (a, mut b) = duplex(2);
Expand All @@ -85,7 +81,6 @@ async fn disconnect_reader() {
t1.await.unwrap();
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn max_write_size() {
let (mut a, mut b) = duplex(32);
Expand All @@ -106,7 +101,6 @@ async fn max_write_size() {
drop(b);
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn duplex_is_cooperative() {
let (mut tx, mut rx) = tokio::io::duplex(1024 * 8);
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_panic.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![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};
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_read.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![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;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_split.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery

use tokio::io::{split, AsyncRead, AsyncWrite, ReadBuf, ReadHalf, WriteHalf};

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_take.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery

use std::pin::Pin;
use std::task::{Context, Poll};
Expand Down
3 changes: 0 additions & 3 deletions tokio/tests/io_util_empty.rs
@@ -1,8 +1,6 @@
#![cfg(feature = "full")]
use tokio::io::{AsyncBufReadExt, AsyncReadExt};

// https://github.com/tokio-rs/mio/pull/1580
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn empty_read_is_cooperative() {
tokio::select! {
Expand All @@ -18,7 +16,6 @@ async fn empty_read_is_cooperative() {
}
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[tokio::test]
async fn empty_buf_reads_are_cooperative() {
tokio::select! {
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/join_handle_panic.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery

struct PanicsOnDrop;

Expand Down
4 changes: 0 additions & 4 deletions tokio/tests/macros_join.rs
Expand Up @@ -82,7 +82,6 @@ fn join_size() {
assert_eq!(mem::size_of_val(&fut), 32);
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
async fn non_cooperative_task(permits: Arc<Semaphore>) -> usize {
let mut exceeded_budget = 0;

Expand All @@ -98,7 +97,6 @@ async fn non_cooperative_task(permits: Arc<Semaphore>) -> usize {
exceeded_budget
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
async fn poor_little_task(permits: Arc<Semaphore>) -> usize {
let mut how_many_times_i_got_to_run = 0;

Expand All @@ -110,7 +108,6 @@ async fn poor_little_task(permits: Arc<Semaphore>) -> usize {
how_many_times_i_got_to_run
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
#[tokio::test]
async fn join_does_not_allow_tasks_to_starve() {
let permits = Arc::new(Semaphore::new(1));
Expand All @@ -125,7 +122,6 @@ async fn join_does_not_allow_tasks_to_starve() {
assert_eq!(5, little_task_result);
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
#[tokio::test]
async fn a_different_future_is_polled_first_every_time_poll_fn_is_polled() {
let poll_order = Arc::new(std::sync::Mutex::new(vec![]));
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/macros_rename_test.rs
@@ -1,4 +1,4 @@
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threading

#[allow(unused_imports)]
use std as tokio;
Expand Down
2 changes: 0 additions & 2 deletions tokio/tests/macros_select.rs
Expand Up @@ -125,9 +125,7 @@ async fn one_ready() {
assert_eq!(1, v);
}

// https://github.com/tokio-rs/mio/pull/1580
#[maybe_tokio_test]
#[cfg_attr(target_os = "wasi", ignore = "FIXME: empty poll in park")]
#[cfg(feature = "full")]
async fn select_streams() {
use tokio::sync::mpsc;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/macros_test.rs
@@ -1,4 +1,4 @@
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threading

use tokio::test;

Expand Down
2 changes: 0 additions & 2 deletions tokio/tests/macros_try_join.rs
Expand Up @@ -137,7 +137,6 @@ async fn poor_little_task(permits: Arc<Semaphore>) -> Result<usize, String> {
Ok(how_many_times_i_got_to_run)
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
#[tokio::test]
async fn try_join_does_not_allow_tasks_to_starve() {
let permits = Arc::new(Semaphore::new(10));
Expand All @@ -154,7 +153,6 @@ async fn try_join_does_not_allow_tasks_to_starve() {
assert_eq!(5, little_task_result);
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
#[tokio::test]
async fn a_different_future_is_polled_first_every_time_poll_fn_is_polled() {
let poll_order = Arc::new(std::sync::Mutex::new(vec![]));
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/net_bind_resource.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery or bind

use tokio::net::TcpListener;

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/net_lookup_host.rs
@@ -1,4 +1,4 @@
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support direct socket operations

use tokio::net;
use tokio_test::assert_ok;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/no_rt.rs
@@ -1,4 +1,4 @@
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery

use tokio::net::TcpStream;
use tokio::sync::oneshot;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/process_smoke.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi cannot run system commands

use tokio::process::Command;
use tokio_test::assert_ok;
Expand Down

0 comments on commit aeedf12

Please sign in to comment.