From dcceb025761d379e18111043eb2101e112addb71 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 8 Mar 2023 12:58:51 -0500 Subject: bump deps --- tests/basic.rs | 5 ++--- tests/fixtures/mod.rs | 15 ++++++++------- tests/input.rs | 4 +--- 3 files changed, 11 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/basic.rs b/tests/basic.rs index e0856fb..3faac9c 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -1,5 +1,4 @@ use std::io::Write as _; -use std::os::unix::io::AsRawFd as _; mod fixtures; @@ -11,7 +10,7 @@ fn test_basic() { assert_eq!(fixtures::read(pty), b"\x1b[6;6Hfoo"); pty.write_all(b"a").unwrap(); - assert!(!fixtures::read_ready(pty.as_raw_fd())); + assert!(!fixtures::read_ready(&pty)); pty.write_all(b"a").unwrap(); assert_eq!( @@ -32,7 +31,7 @@ fn test_async() { assert_eq!(fixtures::read(pty), b"\x1b[6;6Hfoo"); pty.write_all(b"a").unwrap(); - assert!(!fixtures::read_ready(pty.as_raw_fd())); + assert!(!fixtures::read_ready(&pty)); pty.write_all(b"a").unwrap(); assert_eq!( diff --git a/tests/fixtures/mod.rs b/tests/fixtures/mod.rs index 5a65954..aee5019 100644 --- a/tests/fixtures/mod.rs +++ b/tests/fixtures/mod.rs @@ -74,7 +74,7 @@ impl BuiltFixture { let mut child = cmd.spawn(&pts).unwrap(); if self.screenguard { - assert!(read_ready(pty.as_raw_fd())); + assert!(read_ready(&pty)); let mut buf = vec![0u8; 1024]; let bytes = pty.read(&mut buf).unwrap(); buf.truncate(bytes); @@ -86,7 +86,7 @@ impl BuiltFixture { f(&mut pty); if self.screenguard { - assert!(read_ready(pty.as_raw_fd())); + assert!(read_ready(&pty)); let mut buf = vec![0u8; 1024]; let bytes = pty.read(&mut buf).unwrap(); buf.truncate(bytes); @@ -101,7 +101,7 @@ impl BuiltFixture { #[allow(dead_code)] #[track_caller] pub fn read(f: &mut pty_process::blocking::Pty) -> Vec { - assert!(read_ready(f.as_raw_fd())); + assert!(read_ready(&f)); let mut buf = vec![0u8; 1024]; let bytes = f.read(&mut buf).unwrap(); buf.truncate(bytes); @@ -113,16 +113,17 @@ pub fn read(f: &mut pty_process::blocking::Pty) -> Vec { pub fn read_line( f: &mut std::io::BufReader<&mut pty_process::blocking::Pty>, ) -> Vec { - assert!(!f.buffer().is_empty() || read_ready(f.get_ref().as_raw_fd())); + assert!(!f.buffer().is_empty() || read_ready(f.get_ref())); let mut buf = vec![]; f.read_until(b'\n', &mut buf).unwrap(); buf } #[allow(dead_code)] -pub fn read_ready(fd: std::os::unix::io::RawFd) -> bool { +pub fn read_ready(fd: Fd) -> bool { let mut set = nix::sys::select::FdSet::new(); - set.insert(fd); + let raw_fd = fd.as_fd().as_raw_fd(); + set.insert(raw_fd); let timeout = libc::timeval { tv_sec: 0, tv_usec: 100_000, @@ -137,7 +138,7 @@ pub fn read_ready(fd: std::os::unix::io::RawFd) -> bool { ) { Ok(n) => { if n > 0 { - set.contains(fd) + set.contains(raw_fd) } else { false } diff --git a/tests/input.rs b/tests/input.rs index 5b23b6a..1799cde 100644 --- a/tests/input.rs +++ b/tests/input.rs @@ -1,7 +1,6 @@ #![allow(clippy::collapsible_if)] use std::io::Write as _; -use std::os::unix::io::AsRawFd as _; mod fixtures; @@ -335,8 +334,7 @@ fn assert_line( fn assert_no_more_lines( f: &mut std::io::BufReader<&mut pty_process::blocking::Pty>, ) { - if fixtures::read_ready(f.get_ref().as_raw_fd()) || !f.buffer().is_empty() - { + if fixtures::read_ready(f.get_ref()) || !f.buffer().is_empty() { use std::io::Read as _; let mut buf = vec![0; 4096]; let bytes = f.read(&mut buf).unwrap(); -- cgit v1.2.3-54-g00ecf