Skip to content

Commit

Permalink
e2e bash test
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko committed Nov 15, 2024
1 parent f8d4166 commit 0e3be79
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/bash.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::time::Duration;
use std::{env, process::Command};

use expectrl::Session;
use tempfile::NamedTempFile;

#[test]
fn bash() {
let histfile = NamedTempFile::new().unwrap();

let mut bash = Command::new("bash");
bash.args(["--norc", "-i", "-o", "history"])
.env(
"PATH",
&format!("./target/debug/:{}", env::var("PATH").unwrap()),
)
.env("FIXIT_QUICK_ENABLE", "false")
.env("HISTFILE", histfile.path())
.env("SHELL", "/bin/bash");

let mut p = Session::spawn(bash).expect("Failed to spawn bash");

p.set_expect_timeout(Some(Duration::from_secs(1000)));

p.send_line("eval \"$(fixit init bash)\"").unwrap();
p.send_line("eco 'Hello, world!'").unwrap();
p.expect("command not found").unwrap();
p.send_line("fix").unwrap();
p.send_line("").unwrap();
p.expect("Hello, world!").unwrap();
p.send_line("exit").unwrap();
}

0 comments on commit 0e3be79

Please sign in to comment.