Skip to content

Commit

Permalink
apply the same test fix as in mio-serial
Browse files Browse the repository at this point in the history
  • Loading branch information
estokes committed Dec 31, 2024
1 parent 7d94933 commit aecd438
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tokio-serial"
version = "5.4.4"
version = "5.4.5"
authors = ["Zac Berkowitz <[email protected]>"]
description = "A serial port implementation for tokio"
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ impl SerialStream {
///
/// ## Examples
///
/// ```rust
/// use tokio_serial::Serial;
/// ```no_run
/// use tokio_serial::SerialStream;
///
/// #[tokio::main]
/// async fn main() {
/// let (master, slave) = Serial::pair().unwrap();
/// let (master, slave) = SerialStream::pair().unwrap();
/// }
/// ```
#[cfg(unix)]
Expand Down
12 changes: 7 additions & 5 deletions tests/test_serialstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Drop for Fixture {
log::trace!("stopping socat process (id: {})...", id);

self.process.start_kill().ok();
std::thread::sleep(Duration::from_millis(250));
std::thread::sleep(Duration::from_millis(1000));
log::trace!("removing link: {}", self.port_a);
std::fs::remove_file(self.port_a).ok();
log::trace!("removing link: {}", self.port_b);
Expand All @@ -41,20 +41,22 @@ impl Drop for Fixture {
impl Fixture {
#[cfg(unix)]
pub async fn new(port_a: &'static str, port_b: &'static str) -> Self {
use std::sync::atomic::{AtomicUsize, Ordering};
static N: AtomicUsize = AtomicUsize::new(0);
let n = N.fetch_add(1, Ordering::Relaxed);
let port_a = format!("{}{}", port_a, n).leak();
let port_b = format!("{}{}", port_b, n).leak();
let args = [
format!("PTY,link={}", port_a),
format!("PTY,link={}", port_b),
];
log::trace!("starting process: socat {} {}", args[0], args[1]);

let process = process::Command::new("socat")
.args(&args)
.spawn()
.expect("unable to spawn socat process");
log::trace!(".... done! (pid: {:?})", process.id().unwrap());

time::sleep(Duration::from_millis(500)).await;

time::sleep(Duration::from_millis(1000)).await;
Self {
process,
port_a,
Expand Down

0 comments on commit aecd438

Please sign in to comment.