diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-03-06 03:03:18 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-03-06 03:03:18 -0500 |
commit | 1a6ada9a4df3b33ef111d807ffbd61ba5ee326ba (patch) | |
tree | dae97deefe38720c023fc793770550dfad7cb79c | |
parent | 3c94117b577667b6c34a23529a0aa18ac354404b (diff) | |
download | pty-process-1a6ada9a4df3b33ef111d807ffbd61ba5ee326ba.tar.gz pty-process-1a6ada9a4df3b33ef111d807ffbd61ba5ee326ba.zip |
test that SIGWINCH is sent properly
-rw-r--r-- | tests/winch.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/winch.rs b/tests/winch.rs new file mode 100644 index 0000000..234afeb --- /dev/null +++ b/tests/winch.rs @@ -0,0 +1,27 @@ +use pty_process::Command as _; +use std::io::{Read as _, Write as _}; + +#[cfg(feature = "backend-std")] +#[test] +fn test_winch() { + let mut child = std::process::Command::new("perl") + .args(&[ + "-E", + "$|++; $SIG{WINCH} = sub { say 'WINCH' }; say 'started'; <>", + ]) + .spawn_pty(Some(&pty_process::Size::new(24, 80))) + .unwrap(); + + let mut buf = [0u8; 1024]; + let bytes = child.pty().read(&mut buf).unwrap(); + assert_eq!(&buf[..bytes], b"started\r\n"); + + child.resize_pty(&pty_process::Size::new(25, 80)).unwrap(); + + let bytes = child.pty().read(&mut buf).unwrap(); + assert_eq!(&buf[..bytes], b"WINCH\r\n"); + + child.pty().write_all(b"\n").unwrap(); + let status = child.wait().unwrap(); + assert_eq!(status.code().unwrap(), 0); +} |