Add tests to verify the fix for #117

This commit is contained in:
David Dworken 2023-10-21 08:59:27 -07:00
parent 1fc17e3296
commit 08e734a1fe
No known key found for this signature in database
3 changed files with 21 additions and 5 deletions

View File

@ -1581,13 +1581,27 @@ func TestFish(t *testing.T) {
"SPACE echo SPACE foobar ENTER",
"ls SPACE /tmp/ SPACE '&' ENTER",
})
if !strings.Contains(out, "Welcome to fish, the friendly interactive shell") || !strings.Contains(out, "foo") || !strings.Contains(out, "bar") || !strings.Contains(out, "baz") {
t.Fatalf("fish output looks wrong")
}
require.Contains(t, out, "Welcome to fish, the friendly interactive shell")
require.Contains(t, out, "\nfoo\n")
require.Contains(t, out, "\nbar\n")
require.Contains(t, out, "\nbaz\n")
require.Contains(t, out, "\nfoobar\n")
// And test that fish exits properly, for #117
out = captureTerminalOutputWithShellName(t, tester, "bash", []string{
"fish ENTER",
"echo SPACE foo ENTER",
"exit ENTER",
})
require.Contains(t, out, "Welcome to fish, the friendly interactive shell")
require.Contains(t, out, "\nfoo\n")
require.NotContains(t, out, "There are still jobs active")
require.NotContains(t, out, "A second attempt to exit will terminate them.")
require.Contains(t, out, "exit\nbash")
// Check export
out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail | grep -v ps`)
expectedOutput := "echo foo\necho bar\necho \"foo\"\nls /tmp/ &\n"
expectedOutput := "echo foo\necho bar\necho \"foo\"\nls /tmp/ &\necho foo\nfish\n"
if diff := cmp.Diff(expectedOutput, out); diff != "" {
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
}

View File

@ -1,5 +1,7 @@
CWD Hostname Exit Code Command
/ ghaction-runner-hostname 0 hishtory config-set displayed-columns CWD Hostname 'Exit Code' Command
/ ghaction-runner-hostname 0 fish
/ ghaction-runner-hostname 0 echo foo
/ ghaction-runner-hostname 0 ls /tmp/ &
/ ghaction-runner-hostname 0 echo "foo"
/ ghaction-runner-hostname 0 echo bar

View File

@ -41,7 +41,7 @@ func (b bashTester) RunInteractiveShell(t testing.TB, script string) string {
out, err := b.RunInteractiveShellRelaxed(t, "set -emo pipefail\n"+script)
if err != nil {
_, filename, line, _ := runtime.Caller(1)
t.Fatalf("error when running command at %s:%d: %v", filename, line, err)
require.NoError(t, err, fmt.Sprintf("error when running command at %s:%dv", filename, line))
}
return out
}