Refactor fish tests to use the existing API

This commit is contained in:
David Dworken 2022-10-30 18:01:53 -07:00
parent 0e70347c0d
commit de99d60f7c
2 changed files with 29 additions and 28 deletions

View File

@ -1698,34 +1698,16 @@ func TestFish(t *testing.T) {
installHishtory(t, tester, "")
// Test recording in fish
fishLocation, err := exec.LookPath("fish")
if err != nil {
t.Fatalf("fish is not installed")
}
// TODO: migrate this to the wrapper function
out := tester.RunInteractiveShell(t, ` export SHELL=`+fishLocation+`
tmux kill-session -t foo || true
tmux -u new-session -d -x 200 -y 50 -s foo
tmux send -t foo ps -p $$ ENTER
sleep 0.5
tmux send -t foo echo SPACE foo ENTER
sleep 0.5
tmux send -t foo ENTER
sleep 0.5
tmux send -t foo SPACE echo SPACE baz ENTER
sleep 0.5
tmux send -t foo echo SPACE bar ENTER
sleep 0.5
tmux send -t foo ls SPACE /tmp/ ENTER
sleep 0.5
tmux send -t foo SPACE echo SPACE foobar ENTER
tmux send -t foo ls SPACE /bar/ SPACE '&' ENTER
sleep 0.5
tmux capture-pane -p
tmux kill-session -t foo`)
if !strings.Contains(out, "fish") {
t.Fatalf("unexpected shell")
}
out := captureTerminalOutputWithShellName(t, tester, "fish", []string{
"echo SPACE foo ENTER",
"ENTER",
"SPACE echo SPACE baz ENTER",
"echo SPACE bar ENTER",
"ls SPACE /tmp/ ENTER",
"SPACE echo SPACE foobar ENTER",
"ls SPACE /bar/ SPACE '&' ENTER",
})
compareGoldens(t, out, "TestFish-capturedPane")
out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail | grep -v ps`)
expectedOutput := "echo foo\necho bar\nls /tmp/\nls /bar/ &\n"

View File

@ -0,0 +1,19 @@
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
david@Davids-MacBook-Air ~/c/hishtory (master)> echo foo
foo
david@Davids-MacBook-Air ~/c/hishtory (master)>
david@Davids-MacBook-Air ~/c/hishtory (master)> echo baz
baz
david@Davids-MacBook-Air ~/c/hishtory (master)> echo bar
bar
david@Davids-MacBook-Air ~/c/hishtory (master)> ls /tmp/
client* com.google.Keystone/ powerlog/ tmux-501/
com.apple.launchd.vphqfEpkYH/ fseventsd-uuid server*
david@Davids-MacBook-Air ~/c/hishtory (master)> echo foobar
foobar
david@Davids-MacBook-Air ~/c/hishtory (master)> ls /bar/ &
ls: /bar/: No such file or directory
fish: Job 1, 'ls /bar/ &' has ended
david@Davids-MacBook-Air ~/c/hishtory (master) [1]>