diff --git a/client/client_test.go b/client/client_test.go index e4458a2..15eaf9f 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -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) } diff --git a/client/lib/goldens/TestFish-table b/client/lib/goldens/TestFish-table index 3491deb..fa4eaed 100644 --- a/client/lib/goldens/TestFish-table +++ b/client/lib/goldens/TestFish-table @@ -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 diff --git a/client/testutils.go b/client/testutils.go index 9d83488..e967f20 100644 --- a/client/testutils.go +++ b/client/testutils.go @@ -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 }