#![allow(clippy::literal_string_with_formatting_args)]
use anyhow::Context;
use ntest::timeout;
mod support;
use crate::support::daemon::DaemonArgs;
#[test]
#[timeout(30000)]
fn screen_restore() -> anyhow::Result<()> {
let mut daemon_proc = support::daemon::Proc::new("vterm_screen.toml", DaemonArgs::default())
.context("starting daemon proc")?;
let bidi_done_w = daemon_proc.events.take().unwrap().waiter(["daemon-bidi-stream-done"]);
{
let mut attach_proc =
daemon_proc.attach("sh1", Default::default()).context("starting attach proc")?;
let mut line_matcher = attach_proc.line_matcher()?;
attach_proc.run_cmd("echo foo")?;
line_matcher.scan_until_re("foo$")?;
}
daemon_proc.events = Some(bidi_done_w.wait_final_event("daemon-bidi-stream-done")?);
{
let mut attach_proc =
daemon_proc.attach("sh1", Default::default()).context("starting attach proc")?;
let mut line_matcher = attach_proc.line_matcher()?;
line_matcher.scan_until_re("foo$")?;
attach_proc.proc.kill()?;
}
Ok(())
}
#[test]
#[timeout(30000)]
fn lines_restore() -> anyhow::Result<()> {
let mut daemon_proc = support::daemon::Proc::new("vterm_lines.toml", DaemonArgs::default())
.context("starting daemon proc")?;
let bidi_done_w = daemon_proc.events.take().unwrap().waiter(["daemon-bidi-stream-done"]);
{
let mut attach_proc =
daemon_proc.attach("sh1", Default::default()).context("starting attach proc")?;
let mut line_matcher = attach_proc.line_matcher()?;
attach_proc.run_cmd("echo foo")?;
line_matcher.scan_until_re("foo$")?;
}
daemon_proc.events = Some(bidi_done_w.wait_final_event("daemon-bidi-stream-done")?);
{
let mut attach_proc =
daemon_proc.attach("sh1", Default::default()).context("starting attach proc")?;
let mut line_matcher = attach_proc.line_matcher()?;
line_matcher.scan_until_re("foo$")?;
}
Ok(())
}