-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add e2e tests for all non-windows shells
- Loading branch information
1 parent
185b35d
commit 2a65052
Showing
4 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::{env, process::Command, time::Duration}; | ||
|
||
use expectrl::Session; | ||
use rstest::{fixture, rstest}; | ||
use tempfile::NamedTempFile; | ||
|
||
#[fixture] | ||
fn fish() -> (Session, NamedTempFile) { | ||
let histfile = NamedTempFile::new().unwrap(); | ||
|
||
let mut fish = Command::new("fish"); | ||
fish.args(["--no-config", "--interactive", "--private"]) | ||
.env( | ||
"PATH", | ||
&format!("./target/debug/:{}", env::var("PATH").unwrap()), | ||
) | ||
.env("FIXIT_QUICK_ENABLE", "false") | ||
.env("fish_history", histfile.path()) | ||
.env("SHELL", "fish") | ||
.env("fish_command_not_found_path", ""); | ||
|
||
let mut p = Session::spawn(fish).expect("Failed to spawn fish"); | ||
|
||
// Initialize Fish | ||
p.send_line("fixit init fish | source").unwrap(); | ||
|
||
(p, histfile) | ||
} | ||
|
||
#[rstest] | ||
fn fixed(fish: (Session, NamedTempFile)) { | ||
let (mut p, _histfile) = fish; | ||
|
||
p.set_expect_timeout(Some(Duration::from_secs(5))); | ||
|
||
p.send_line("eco 'Hello, world!'").unwrap(); | ||
p.expect("Unknown command").unwrap(); | ||
p.send_line("fix").unwrap(); | ||
p.send_line("").unwrap(); | ||
p.expect("Hello, world!").unwrap(); | ||
p.send_line("exit").unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::{env, process::Command, time::Duration}; | ||
|
||
use expectrl::Session; | ||
use rstest::{fixture, rstest}; | ||
use tempfile::NamedTempFile; | ||
|
||
#[fixture] | ||
fn zsh() -> (Session, NamedTempFile) { | ||
let histfile = NamedTempFile::new().unwrap(); | ||
|
||
let mut zsh = Command::new("zsh"); | ||
zsh.args(["-f", "-i"]) // -f means no RC files, -i for interactive | ||
.env( | ||
"PATH", | ||
&format!("./target/debug/:{}", env::var("PATH").unwrap()), | ||
) | ||
.env("FIXIT_QUICK_ENABLE", "false") | ||
.env("HISTFILE", histfile.path()) | ||
.env("SHELL", "zsh"); | ||
// ZSH specific history settings | ||
// .env("SAVEHIST", "1000") | ||
// .env("HISTSIZE", "1000"); | ||
|
||
let mut p = Session::spawn(zsh).expect("Failed to spawn zsh"); | ||
|
||
// Initialize ZSH history | ||
// p.send_line("setopt APPEND_HISTORY").unwrap(); | ||
// p.send_line("setopt INC_APPEND_HISTORY").unwrap(); | ||
p.send_line("eval \"$(fixit init zsh)\"").unwrap(); | ||
|
||
(p, histfile) | ||
} | ||
|
||
#[rstest] | ||
fn fixed(zsh: (Session, NamedTempFile)) { | ||
let (mut p, _histfile) = zsh; | ||
|
||
p.set_expect_timeout(Some(Duration::from_secs(5))); | ||
|
||
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(); | ||
} |