mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-21 04:17:45 +02:00
Add presaving test for fish
This commit is contained in:
parent
caac6ac9ee
commit
18ef74656c
@ -93,11 +93,12 @@ func TestParam(t *testing.T) {
|
|||||||
t.Run("testHandleUpgradedFeatures/"+tester.ShellName(), func(t *testing.T) { testHandleUpgradedFeatures(t, tester) })
|
t.Run("testHandleUpgradedFeatures/"+tester.ShellName(), func(t *testing.T) { testHandleUpgradedFeatures(t, tester) })
|
||||||
t.Run("testCustomColumns/"+tester.ShellName(), func(t *testing.T) { testCustomColumns(t, tester) })
|
t.Run("testCustomColumns/"+tester.ShellName(), func(t *testing.T) { testCustomColumns(t, tester) })
|
||||||
t.Run("testUninstall/"+tester.ShellName(), func(t *testing.T) { testUninstall(t, tester) })
|
t.Run("testUninstall/"+tester.ShellName(), func(t *testing.T) { testUninstall(t, tester) })
|
||||||
t.Run("testPresaving/"+tester.ShellName(), func(t *testing.T) { testPresaving(t, tester) })
|
t.Run("testPresaving/"+tester.ShellName(), func(t *testing.T) { testPresaving(t, tester, tester.ShellName()) })
|
||||||
t.Run("testPresavingDisabled/"+tester.ShellName(), func(t *testing.T) { testPresavingDisabled(t, tester) })
|
t.Run("testPresavingDisabled/"+tester.ShellName(), func(t *testing.T) { testPresavingDisabled(t, tester) })
|
||||||
t.Run("testControlR/online/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Online) })
|
t.Run("testControlR/online/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Online) })
|
||||||
t.Run("testControlR/offline/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Offline) })
|
t.Run("testControlR/offline/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Offline) })
|
||||||
}
|
}
|
||||||
|
t.Run("testPresaving/fish", func(t *testing.T) { testPresaving(t, zshTester{}, "fish") })
|
||||||
t.Run("testControlR/fish", func(t *testing.T) { testControlR(t, bashTester{}, "fish", Online) })
|
t.Run("testControlR/fish", func(t *testing.T) { testControlR(t, bashTester{}, "fish", Online) })
|
||||||
t.Run("testTui/search/online", func(t *testing.T) { testTui_search(t, Online) })
|
t.Run("testTui/search/online", func(t *testing.T) { testTui_search(t, Online) })
|
||||||
t.Run("testTui/search/offline", func(t *testing.T) { testTui_search(t, Offline) })
|
t.Run("testTui/search/offline", func(t *testing.T) { testTui_search(t, Offline) })
|
||||||
@ -2178,7 +2179,7 @@ func testPresavingDisabled(t *testing.T, tester shellTester) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPresaving(t *testing.T, tester shellTester) {
|
func testPresaving(t *testing.T, tester shellTester, shellName string) {
|
||||||
// Setup
|
// Setup
|
||||||
defer testutils.BackupAndRestore(t)()
|
defer testutils.BackupAndRestore(t)()
|
||||||
userSecret := installHishtory(t, tester, "")
|
userSecret := installHishtory(t, tester, "")
|
||||||
@ -2192,7 +2193,16 @@ func testPresaving(t *testing.T, tester shellTester) {
|
|||||||
// Start a command that will take a long time to execute in the background, so
|
// Start a command that will take a long time to execute in the background, so
|
||||||
// we can check that it was recorded even though it never finished.
|
// we can check that it was recorded even though it never finished.
|
||||||
require.NoError(t, os.Chdir("/"))
|
require.NoError(t, os.Chdir("/"))
|
||||||
require.NoError(t, tester.RunInteractiveShellBackground(t, `sleep 13371337`))
|
if tester.ShellName() == shellName {
|
||||||
|
require.NoError(t, tester.RunInteractiveShellBackground(t, `sleep 13371337`))
|
||||||
|
} else {
|
||||||
|
tmuxCommandToRunInBackground := buildTmuxInputCommands(t, TmuxCaptureConfig{
|
||||||
|
tester: tester,
|
||||||
|
overriddenShellName: shellName,
|
||||||
|
commands: []string{`sleep SPACE 13371337 ENTER`},
|
||||||
|
})
|
||||||
|
tester.RunInteractiveShell(t, tmuxCommandToRunInBackground)
|
||||||
|
}
|
||||||
time.Sleep(time.Millisecond * 500)
|
time.Sleep(time.Millisecond * 500)
|
||||||
|
|
||||||
// Test that it shows up in hishtory export
|
// Test that it shows up in hishtory export
|
||||||
|
@ -197,8 +197,7 @@ type TmuxCaptureConfig struct {
|
|||||||
includeEscapeSequences bool
|
includeEscapeSequences bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func captureTerminalOutputComplex(t testing.TB, captureConfig TmuxCaptureConfig) string {
|
func buildTmuxInputCommands(t testing.TB, captureConfig TmuxCaptureConfig) string {
|
||||||
require.NotNil(t, captureConfig.tester)
|
|
||||||
if captureConfig.overriddenShellName == "" {
|
if captureConfig.overriddenShellName == "" {
|
||||||
captureConfig.overriddenShellName = captureConfig.tester.ShellName()
|
captureConfig.overriddenShellName = captureConfig.tester.ShellName()
|
||||||
}
|
}
|
||||||
@ -252,6 +251,13 @@ func captureTerminalOutputComplex(t testing.TB, captureConfig TmuxCaptureConfig)
|
|||||||
if testutils.IsGithubAction() {
|
if testutils.IsGithubAction() {
|
||||||
fullCommand += " sleep 2.5\n"
|
fullCommand += " sleep 2.5\n"
|
||||||
}
|
}
|
||||||
|
return fullCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
func captureTerminalOutputComplex(t testing.TB, captureConfig TmuxCaptureConfig) string {
|
||||||
|
require.NotNil(t, captureConfig.tester)
|
||||||
|
fullCommand := ""
|
||||||
|
fullCommand += buildTmuxInputCommands(t, captureConfig)
|
||||||
fullCommand += " tmux capture-pane -t foo -p"
|
fullCommand += " tmux capture-pane -t foo -p"
|
||||||
if captureConfig.includeEscapeSequences {
|
if captureConfig.includeEscapeSequences {
|
||||||
// -e ensures that tmux runs the command in an environment that supports escape sequences. Used for rendering colors in the TUI.
|
// -e ensures that tmux runs the command in an environment that supports escape sequences. Used for rendering colors in the TUI.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user