mirror of
https://github.com/ddworken/hishtory.git
synced 2024-12-25 16:28:53 +01:00
Add tests to verify the fix for #117
This commit is contained in:
parent
1fc17e3296
commit
08e734a1fe
@ -1581,13 +1581,27 @@ func TestFish(t *testing.T) {
|
|||||||
"SPACE echo SPACE foobar ENTER",
|
"SPACE echo SPACE foobar ENTER",
|
||||||
"ls SPACE /tmp/ SPACE '&' 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") {
|
require.Contains(t, out, "Welcome to fish, the friendly interactive shell")
|
||||||
t.Fatalf("fish output looks wrong")
|
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
|
// Check export
|
||||||
out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail | grep -v ps`)
|
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 != "" {
|
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
||||||
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
|
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
CWD Hostname Exit Code Command
|
CWD Hostname Exit Code Command
|
||||||
/ ghaction-runner-hostname 0 hishtory config-set displayed-columns 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 ls /tmp/ &
|
||||||
/ ghaction-runner-hostname 0 echo "foo"
|
/ ghaction-runner-hostname 0 echo "foo"
|
||||||
/ ghaction-runner-hostname 0 echo bar
|
/ ghaction-runner-hostname 0 echo bar
|
||||||
|
@ -41,7 +41,7 @@ func (b bashTester) RunInteractiveShell(t testing.TB, script string) string {
|
|||||||
out, err := b.RunInteractiveShellRelaxed(t, "set -emo pipefail\n"+script)
|
out, err := b.RunInteractiveShellRelaxed(t, "set -emo pipefail\n"+script)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, filename, line, _ := runtime.Caller(1)
|
_, 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
|
return out
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user