remove need for macros feature when testing spawn

This commit is contained in:
Rob Ede 2021-09-01 21:38:05 +01:00
parent 6fae297bbf
commit 6cfa808094
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
2 changed files with 22 additions and 19 deletions

View File

@ -46,7 +46,10 @@ use tokio::task::JoinHandle;
// Cannot define a main macro when compiled into test harness.
// Workaround for https://github.com/rust-lang/rust/issues/62127.
#[cfg(all(feature = "macros", not(test)))]
pub use actix_macros::{main, test};
pub use actix_macros::main;
#[cfg(feature = "macros")]
pub use actix_macros::test;
mod arbiter;
mod runtime;

View File

@ -9,7 +9,7 @@ use std::{
time::{Duration, Instant},
};
use actix_rt::{Arbiter, System};
use actix_rt::{task::JoinError, Arbiter, System};
use tokio::sync::oneshot;
#[test]
@ -301,8 +301,9 @@ fn try_current_with_system() {
}
#[allow(clippy::unit_cmp)]
#[actix_rt::test]
async fn spawn_local() {
#[test]
fn spawn_local() {
System::new().block_on(async {
// demonstrate that spawn -> R is strictly more capable than spawn -> ()
assert_eq!(actix_rt::spawn(async {}).await.unwrap(), ());
@ -313,8 +314,6 @@ async fn spawn_local() {
.await
.unwrap();
use actix_rt::task::JoinError;
fn g<F: Future<Output = Result<(), JoinError>>>(_f: F) {}
g(actix_rt::spawn(async {}));
// g(actix_rt::spawn(async { 1 })); // compile err
@ -322,4 +321,5 @@ async fn spawn_local() {
fn h<F: Future<Output = Result<R, JoinError>>, R>(_f: F) {}
h(actix_rt::spawn(async {}));
h(actix_rt::spawn(async { 1 }));
})
}