Skip to content

Commit

Permalink
chore(hydroflow): fix clippy::items_after_test_module, simplify rus…
Browse files Browse the repository at this point in the history
…tdoc links (#942)
  • Loading branch information
MingweiSamuel committed Oct 12, 2023
1 parent 6bf846f commit f6a7299
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion hydroflow/src/scheduled/graph_ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Helper extensions for [`Hydroflow`](super::graph::Hydroflow).
//! Helper extensions for [`Hydroflow`].
#![allow(missing_docs)]

use core::task;
Expand Down
59 changes: 29 additions & 30 deletions hydroflow/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ pub use socket::*;
#[cfg(feature = "cli_integration")]
pub mod cli;

use std::io::Read;
use std::net::SocketAddr;
use std::num::NonZeroUsize;
use std::process::{Child, ChildStdin, ChildStdout, Stdio};
use std::task::{Context, Poll};

use bincode;
Expand Down Expand Up @@ -229,36 +231,6 @@ where
slice.sort_unstable_by(|a, b| f(a).cmp(f(b)))
}

#[cfg(test)]
mod test {
use super::*;

#[test]
pub fn test_collect_ready() {
let (send, mut recv) = unbounded_channel::<usize>();
for x in 0..1000 {
send.send(x).unwrap();
}
assert_eq!(1000, collect_ready::<Vec<_>, _>(&mut recv).len());
}

#[crate::test]
pub async fn test_collect_ready_async() {
// Tokio unbounded channel returns items in 128 item long chunks, so we have to be careful that everything gets returned.
let (send, mut recv) = unbounded_channel::<usize>();
for x in 0..1000 {
send.send(x).unwrap();
}
assert_eq!(
1000,
collect_ready_async::<Vec<_>, _>(&mut recv).await.len()
);
}
}

use std::io::Read;
use std::process::{Child, ChildStdin, ChildStdout, Stdio};

/// When a child process is spawned often you want to wait until the child process is ready before moving on.
/// One way to do that synchronization is by waiting for the child process to output something and match regex against that output.
/// For example, you could wait until the child process outputs "Client live!" which would indicate that it is ready to receive input now on stdin.
Expand Down Expand Up @@ -351,3 +323,30 @@ where
}
})
}

#[cfg(test)]
mod test {
use super::*;

#[test]
pub fn test_collect_ready() {
let (send, mut recv) = unbounded_channel::<usize>();
for x in 0..1000 {
send.send(x).unwrap();
}
assert_eq!(1000, collect_ready::<Vec<_>, _>(&mut recv).len());
}

#[crate::test]
pub async fn test_collect_ready_async() {
// Tokio unbounded channel returns items in 128 item long chunks, so we have to be careful that everything gets returned.
let (send, mut recv) = unbounded_channel::<usize>();
for x in 0..1000 {
send.send(x).unwrap();
}
assert_eq!(
1000,
collect_ready_async::<Vec<_>, _>(&mut recv).await.len()
);
}
}
2 changes: 1 addition & 1 deletion lattices/src/collections.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Simple singleton or array collection with [`cc_traits`](crate::cc_traits) implementations.
//! Simple singleton or array collection with [`cc_traits`] implementations.
use std::borrow::Borrow;
use std::hash::Hash;
Expand Down

0 comments on commit f6a7299

Please sign in to comment.