Skip to content

Commit

Permalink
Merge pull request #677 from swimos/circ-fix
Browse files Browse the repository at this point in the history
Fixes faulty test logic for the circular buffer channel.
  • Loading branch information
horned-sphere authored Jun 27, 2024
2 parents 73f7316 + b6b8759 commit 57e843f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion swimos_utilities/swimos_sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ swimos_num = { workspace = true }

[dev-dependencies]
futures = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "sync"] }
9 changes: 5 additions & 4 deletions swimos_utilities/swimos_sync/src/circular_buffer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use crate::circular_buffer::error::{RecvError, SendError};
use crate::circular_buffer::{InternalQueue, OneItemQueue, LARGE_BOUNDARY};
use futures::future::join;
use futures::task::ArcWake;
use futures::StreamExt;
use std::future::Future;
Expand Down Expand Up @@ -183,6 +184,7 @@ async fn receive_several_stream(n: usize) {
for i in 0..n {
assert!(tx.try_send(i).is_ok());
}
tx
};

let recv_task = async move {
Expand All @@ -194,8 +196,9 @@ async fn receive_several_stream(n: usize) {
let send_handle = tokio::spawn(send_task);
let recv_handle = tokio::spawn(recv_task);

assert!(send_handle.await.is_ok());
assert!(recv_handle.await.is_ok());
let (send_result, recv_result) = join(send_handle, recv_handle).await;
assert!(send_result.is_ok());
assert!(recv_result.is_ok());
}

#[tokio::test(flavor = "multi_thread")]
Expand All @@ -204,8 +207,6 @@ async fn small_receive_several_stream() {
}

#[tokio::test(flavor = "multi_thread")]
#[ignore]
// todo: spuriously failing on CI
async fn large_receive_several_stream() {
receive_several_stream(LARGE_BOUNDARY + 1).await;
}
Expand Down

0 comments on commit 57e843f

Please sign in to comment.