Skip to content

Commit

Permalink
enable some tests for async --no-default-features --features alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Congyuwang committed Jul 30, 2023
1 parent e0637cf commit c23c4f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use rb::AsyncRb;
pub use traits::{consumer, producer};
pub use transfer::async_transfer;

#[cfg(all(test, feature = "std"))]
#[cfg(test)]
mod tests;

#[cfg(all(test, feature = "bench"))]
Expand Down
8 changes: 6 additions & 2 deletions async/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{async_transfer, traits::*, AsyncHeapRb};
use alloc::vec::Vec;
use core::sync::atomic::{AtomicUsize, Ordering};
use futures::task::{noop_waker_ref, AtomicWaker};
#[cfg(feature = "std")]
use std::sync::Arc;
use std::{vec, vec::Vec};

#[test]
fn atomic_waker() {
Expand Down Expand Up @@ -59,7 +60,7 @@ fn push_pop_slice() {
},
async move {
let mut cons = cons;
let mut data = vec![0; COUNT + 1];
let mut data = [0; COUNT + 1];
let count = cons.pop_slice_all(&mut data).await.unwrap_err();
assert_eq!(count, COUNT);
assert!(data.into_iter().take(COUNT).eq(0..COUNT));
Expand Down Expand Up @@ -94,6 +95,7 @@ fn sink_stream() {
);
}

#[cfg(feature = "std")]
#[test]
fn read_write() {
use futures::{AsyncReadExt, AsyncWriteExt};
Expand Down Expand Up @@ -167,6 +169,7 @@ fn wait() {
);
}

#[cfg(feature = "std")]
#[test]
fn drop_close_prod() {
let (prod, mut cons) = AsyncHeapRb::<usize>::new(1).split();
Expand All @@ -189,6 +192,7 @@ fn drop_close_prod() {
t1.join().unwrap();
}

#[cfg(feature = "std")]
#[test]
fn drop_close_cons() {
let (mut prod, mut cons) = AsyncHeapRb::<usize>::new(1).split();
Expand Down
1 change: 1 addition & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cargo check --no-default-features --features alloc && \
cargo check --no-default-features && \
cd async && \
cargo test && \
cargo test --no-default-features --features alloc && \
cargo check --no-default-features --features alloc && \
cargo check --no-default-features && \
cd ../blocking && \
Expand Down

0 comments on commit c23c4f0

Please sign in to comment.