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

futures: Require all stable features in tests #2216

Merged
merged 1 commit into from Sep 30, 2020
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
10 changes: 8 additions & 2 deletions .travis.yml
Expand Up @@ -38,10 +38,16 @@ matrix:
# When updating this, the reminder to update the minimum required version of `async-await` feature in README.md.
- name: cargo build --features async-await (minimum required version)
rust: 1.39.0
install:
# cargo does not support for --features/--no-default-features with workspace, so use cargo-hack instead.
# Refs: cargo#3620, cargo#4106, cargo#4463, cargo#4753, cargo#5015, cargo#5364, cargo#6195
- if ! cargo hack -V 2>/dev/null; then
cargo install cargo-hack;
fi
script:
- cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml */Cargo.toml
# async-await feature is activated by default.
- cargo build --workspace
- cargo hack build --workspace --no-dev-deps
- cargo build --tests --features default,thread-pool,io-compat --manifest-path futures/Cargo.toml

- name: cargo +stable build
rust: stable
Expand Down
8 changes: 8 additions & 0 deletions futures/tests/_require_features.rs
@@ -0,0 +1,8 @@
#[cfg(not(all(
feature = "std", feature = "alloc", feature = "async-await",
feature = "compat", feature = "io-compat",
feature = "executor", feature = "thread-pool",
)))]
compile_error!("`futures` tests must have all stable features activated: \
use `--all-features` or `--features default,thread-pool,io-compat`"
);
3 changes: 0 additions & 3 deletions futures/tests/abortable.rs
@@ -1,4 +1,3 @@
#[cfg(all(feature = "alloc", feature = "executor"))]
#[test]
fn abortable_works() {
use futures::channel::oneshot;
Expand All @@ -12,7 +11,6 @@ fn abortable_works() {
assert_eq!(Err(Aborted), block_on(abortable_rx));
}

#[cfg(all(feature = "alloc", feature = "executor"))]
#[test]
fn abortable_awakens() {
use futures::channel::oneshot;
Expand All @@ -33,7 +31,6 @@ fn abortable_awakens() {
assert_eq!(Poll::Ready(Err(Aborted)), abortable_rx.poll_unpin(&mut cx));
}

#[cfg(all(feature = "alloc", feature = "executor"))]
#[test]
fn abortable_resolves() {
use futures::channel::oneshot;
Expand Down
2 changes: 0 additions & 2 deletions futures/tests/arc_wake.rs
@@ -1,4 +1,3 @@
#[cfg(feature = "alloc")]
mod countingwaker {
use futures::task::{self, ArcWake, Waker};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -60,7 +59,6 @@ mod countingwaker {
}
}

#[cfg(feature = "alloc")]
#[test]
fn proper_refcount_on_wake_panic() {
use futures::task::{self, ArcWake, Waker};
Expand Down
22 changes: 0 additions & 22 deletions futures/tests/async_await_macros.rs
@@ -1,6 +1,3 @@
#![recursion_limit="128"]

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn poll_and_pending() {
use futures::{pending, pin_mut, poll};
Expand All @@ -15,7 +12,6 @@ fn poll_and_pending() {
});
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn join() {
use futures::{pin_mut, poll, join};
Expand All @@ -41,7 +37,6 @@ fn join() {
});
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select() {
use futures::select;
Expand All @@ -65,7 +60,6 @@ fn select() {
assert!(ran);
}

#[cfg(all(feature = "alloc", feature = "executor", feature = "async-await"))]
#[test]
fn select_biased() {
use futures::channel::oneshot;
Expand All @@ -89,7 +83,6 @@ fn select_biased() {
assert!(ran);
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_streams() {
use futures::select;
Expand Down Expand Up @@ -139,7 +132,6 @@ fn select_streams() {
assert!(ran);
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_can_move_uncompleted_futures() {
use futures::select;
Expand Down Expand Up @@ -171,7 +163,6 @@ fn select_can_move_uncompleted_futures() {
assert!(ran);
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_nested() {
use futures::select;
Expand All @@ -192,7 +183,6 @@ fn select_nested() {
assert_eq!(res, 3);
}

#[cfg(all(feature = "async-await", feature = "std"))]
#[test]
fn select_size() {
use futures::select;
Expand All @@ -217,7 +207,6 @@ fn select_size() {
assert_eq!(::std::mem::size_of_val(&fut), 40);
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_on_non_unpin_expressions() {
use futures::select;
Expand All @@ -240,7 +229,6 @@ fn select_on_non_unpin_expressions() {
assert_eq!(res, 5);
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_on_non_unpin_expressions_with_default() {
use futures::select;
Expand All @@ -264,7 +252,6 @@ fn select_on_non_unpin_expressions_with_default() {
assert_eq!(res, 5);
}

#[cfg(all(feature = "async-await", feature = "std"))]
#[test]
fn select_on_non_unpin_size() {
use futures::select;
Expand All @@ -287,7 +274,6 @@ fn select_on_non_unpin_size() {
assert_eq!(32, std::mem::size_of_val(&fut));
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_can_be_used_as_expression() {
use futures::select;
Expand All @@ -303,7 +289,6 @@ fn select_can_be_used_as_expression() {
});
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_with_default_can_be_used_as_expression() {
use futures::select;
Expand All @@ -325,7 +310,6 @@ fn select_with_default_can_be_used_as_expression() {
});
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_with_complete_can_be_used_as_expression() {
use futures::select;
Expand All @@ -343,7 +327,6 @@ fn select_with_complete_can_be_used_as_expression() {
});
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_on_mutable_borrowing_future_with_same_borrow_in_block() {
use futures::select;
Expand All @@ -364,7 +347,6 @@ fn select_on_mutable_borrowing_future_with_same_borrow_in_block() {
});
}

#[cfg(all(feature = "async-await", feature = "std", feature = "executor"))]
#[test]
fn select_on_mutable_borrowing_future_with_same_borrow_in_block_and_default() {
use futures::select;
Expand All @@ -388,7 +370,6 @@ fn select_on_mutable_borrowing_future_with_same_borrow_in_block_and_default() {
});
}

#[cfg(feature = "async-await")]
#[test]
fn join_size() {
use futures::join;
Expand All @@ -408,7 +389,6 @@ fn join_size() {
assert_eq!(::std::mem::size_of_val(&fut), 28);
}

#[cfg(feature = "async-await")]
#[test]
fn try_join_size() {
use futures::try_join;
Expand All @@ -428,7 +408,6 @@ fn try_join_size() {
assert_eq!(::std::mem::size_of_val(&fut), 28);
}

#[cfg(feature = "async-await")]
#[test]
fn join_doesnt_require_unpin() {
use futures::join;
Expand All @@ -438,7 +417,6 @@ fn join_doesnt_require_unpin() {
};
}

#[cfg(feature = "async-await")]
#[test]
fn try_join_doesnt_require_unpin() {
use futures::try_join;
Expand Down
1 change: 0 additions & 1 deletion futures/tests/atomic_waker.rs
@@ -1,4 +1,3 @@
#[cfg(feature = "executor")]
#[test]
fn basic() {
use std::sync::atomic::AtomicUsize;
Expand Down
1 change: 0 additions & 1 deletion futures/tests/buffer_unordered.rs
@@ -1,4 +1,3 @@
#[cfg(all(feature = "alloc", feature = "std", feature = "executor"))]
#[test]
#[ignore] // FIXME: https://github.com/rust-lang/futures-rs/issues/1790
fn works() {
Expand Down
2 changes: 0 additions & 2 deletions futures/tests/compat.rs
@@ -1,5 +1,3 @@
#![cfg(feature = "compat")]

use tokio::timer::Delay;
use tokio::runtime::Runtime;
use std::time::Instant;
Expand Down
3 changes: 0 additions & 3 deletions futures/tests/eager_drop.rs
Expand Up @@ -63,7 +63,6 @@ mod channelled {
}
}

#[cfg(feature = "alloc")]
#[test]
fn then_drops_eagerly() {
use futures::channel::oneshot;
Expand All @@ -88,7 +87,6 @@ mod channelled {
rx2.recv().unwrap();
}

#[cfg(feature = "alloc")]
#[test]
fn and_then_drops_eagerly() {
use futures::channel::oneshot;
Expand All @@ -113,7 +111,6 @@ mod channelled {
rx2.recv().unwrap();
}

#[cfg(feature = "alloc")]
#[test]
fn or_else_drops_eagerly() {
use futures::channel::oneshot;
Expand Down
1 change: 0 additions & 1 deletion futures/tests/eventual.rs
@@ -1,4 +1,3 @@
#![cfg(all(feature = "executor", feature = "thread-pool"))]
use futures::channel::oneshot;
use futures::executor::ThreadPool;
use futures::future::{self, ok, Future, FutureExt, TryFutureExt};
Expand Down
2 changes: 0 additions & 2 deletions futures/tests/future_try_flatten_stream.rs
@@ -1,4 +1,3 @@
#[cfg(feature = "executor")]
#[test]
fn successful_future() {
use futures::executor::block_on_stream;
Expand All @@ -16,7 +15,6 @@ fn successful_future() {
assert_eq!(None, iter.next());
}

#[cfg(feature = "executor")]
#[test]
fn failed_future() {
use core::marker::PhantomData;
Expand Down
4 changes: 0 additions & 4 deletions futures/tests/futures_ordered.rs
@@ -1,4 +1,3 @@
#[cfg(all(feature = "alloc", feature="executor"))]
#[test]
fn works_1() {
use futures::channel::oneshot;
Expand All @@ -25,7 +24,6 @@ fn works_1() {
assert_eq!(None, iter.next());
}

#[cfg(feature = "alloc")]
#[test]
fn works_2() {
use futures::channel::oneshot;
Expand All @@ -51,7 +49,6 @@ fn works_2() {
assert!(stream.poll_next_unpin(&mut cx).is_ready());
}

#[cfg(feature = "executor")]
#[test]
fn from_iterator() {
use futures::executor::block_on;
Expand All @@ -67,7 +64,6 @@ fn from_iterator() {
assert_eq!(block_on(stream.collect::<Vec<_>>()), vec![1,2,3]);
}

#[cfg(feature = "alloc")]
#[test]
fn queue_never_unblocked() {
use futures::channel::oneshot;
Expand Down
11 changes: 0 additions & 11 deletions futures/tests/futures_unordered.rs
@@ -1,4 +1,3 @@
#[cfg(feature = "alloc")]
#[test]
fn is_terminated() {
use futures::future;
Expand Down Expand Up @@ -31,7 +30,6 @@ fn is_terminated() {
assert_eq!(tasks.is_terminated(), true);
}

#[cfg(all(feature = "alloc", feature = "executor"))]
#[test]
fn works_1() {
use futures::channel::oneshot;
Expand All @@ -58,7 +56,6 @@ fn works_1() {
assert_eq!(None, iter.next());
}

#[cfg(feature = "alloc")]
#[test]
fn works_2() {
use futures::channel::oneshot;
Expand Down Expand Up @@ -88,7 +85,6 @@ fn works_2() {
assert_eq!(stream.poll_next_unpin(&mut cx), Poll::Ready(None));
}

#[cfg(feature = "executor")]
#[test]
fn from_iterator() {
use futures::executor::block_on;
Expand All @@ -106,7 +102,6 @@ fn from_iterator() {
assert_eq!(block_on(stream.collect::<Vec<_>>()), vec![1, 2, 3]);
}

#[cfg(feature = "alloc")]
#[test]
fn finished_future() {
use std::marker::Unpin;
Expand Down Expand Up @@ -138,7 +133,6 @@ fn finished_future() {
assert!(stream.poll_next_unpin(cx).is_pending());
}

#[cfg(all(feature = "alloc", feature = "executor"))]
#[test]
fn iter_mut_cancel() {
use futures::channel::oneshot;
Expand Down Expand Up @@ -169,7 +163,6 @@ fn iter_mut_cancel() {
assert_eq!(iter.next(), None);
}

#[cfg(feature = "alloc")]
#[test]
fn iter_mut_len() {
use futures::future;
Expand All @@ -194,7 +187,6 @@ fn iter_mut_len() {
assert!(iter_mut.next().is_none());
}

#[cfg(feature = "executor")]
#[test]
fn iter_cancel() {
use std::marker::Unpin;
Expand Down Expand Up @@ -249,7 +241,6 @@ fn iter_cancel() {
assert_eq!(iter.next(), None);
}

#[cfg(feature = "alloc")]
#[test]
fn iter_len() {
use futures::future;
Expand All @@ -274,7 +265,6 @@ fn iter_len() {
assert!(iter.next().is_none());
}

#[cfg(feature = "alloc")]
#[test]
fn futures_not_moved_after_poll() {
use futures::future;
Expand All @@ -292,7 +282,6 @@ fn futures_not_moved_after_poll() {
assert_stream_done!(stream);
}

#[cfg(feature = "alloc")]
#[test]
fn len_valid_during_out_of_order_completion() {
use futures::channel::oneshot;
Expand Down
1 change: 0 additions & 1 deletion futures/tests/inspect.rs
@@ -1,4 +1,3 @@
#[cfg(feature = "executor")]
#[test]
fn smoke() {
use futures::executor::block_on;
Expand Down