Skip to content

Commit d3c938e

Browse files
committed
refactor: inline PTY wait result set and remove unit tests
1 parent 40eb45b commit d3c938e

1 file changed

Lines changed: 1 addition & 37 deletions

File tree

crates/pty_terminal/src/terminal.rs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,6 @@ impl ChildHandle {
244244
}
245245
}
246246

247-
fn set_exit_status_from_wait_result(
248-
exit_status: &OnceLock<std::io::Result<ExitStatus>>,
249-
wait_result: std::io::Result<ExitStatus>,
250-
) {
251-
let _ = exit_status.set(wait_result);
252-
}
253-
254247
impl Terminal {
255248
/// Spawns a new child process in a headless terminal with the given size and command.
256249
///
@@ -284,7 +277,7 @@ impl Terminal {
284277
let writer = Arc::clone(&writer);
285278
let exit_status = Arc::clone(&exit_status);
286279
move || {
287-
set_exit_status_from_wait_result(&exit_status, child.wait());
280+
let _ = exit_status.set(child.wait());
288281
// Close writer to signal EOF to the reader
289282
*writer.lock().unwrap() = None;
290283
}
@@ -307,32 +300,3 @@ impl Terminal {
307300
})
308301
}
309302
}
310-
311-
#[cfg(test)]
312-
mod tests {
313-
use super::*;
314-
315-
#[test]
316-
fn set_exit_status_from_wait_result_preserves_error() {
317-
let exit_status = OnceLock::new();
318-
set_exit_status_from_wait_result(
319-
&exit_status,
320-
Err(std::io::Error::other("forced wait error for test")),
321-
);
322-
323-
let status = exit_status.wait();
324-
assert!(status.is_err());
325-
assert_eq!(status.as_ref().unwrap_err().kind(), std::io::ErrorKind::Other);
326-
assert_eq!(status.as_ref().unwrap_err().to_string(), "forced wait error for test");
327-
}
328-
329-
#[test]
330-
fn set_exit_status_from_wait_result_preserves_child_status() {
331-
let exit_status = OnceLock::new();
332-
set_exit_status_from_wait_result(&exit_status, Ok(ExitStatus::with_exit_code(42)));
333-
334-
let status = exit_status.wait();
335-
assert!(!status.as_ref().unwrap().success());
336-
assert_eq!(status.as_ref().unwrap().exit_code(), 42);
337-
}
338-
}

0 commit comments

Comments
 (0)