Update colored goldens to take into account OS version, since different macos versions have different behavior here

This commit is contained in:
David Dworken 2024-02-24 09:58:39 -08:00
parent d578fb3506
commit 283cec66a3
No known key found for this signature in database
7 changed files with 145 additions and 135 deletions

View File

@ -1853,19 +1853,19 @@ func testTui_color(t *testing.T) {
// from inspection and primarily servers to detect unintended changes in hishtory's output.
out := captureTerminalOutputComplex(t, TmuxCaptureConfig{tester: tester, complexCommands: []TmuxCommand{{Keys: "hishtory SPACE tquery ENTER"}}, includeEscapeSequences: true})
out = stripTuiCommandPrefix(t, out)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutput-"+runtime.GOOS)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutput-"+runtime.GOOS+"-"+testutils.GetOsVersion(t))
// And the same once a search query has been typed in
out = captureTerminalOutputComplex(t, TmuxCaptureConfig{tester: tester, complexCommands: []TmuxCommand{{Keys: "hishtory SPACE tquery ENTER"}, {Keys: "ech"}}, includeEscapeSequences: true})
out = stripTuiCommandPrefix(t, out)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithSearch-"+runtime.GOOS)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithSearch-"+runtime.GOOS+"-"+testutils.GetOsVersion(t))
// And one more time with highlight-matches
tester.RunInteractiveShell(t, ` hishtory config-set highlight-matches true`)
require.Equal(t, "true", strings.TrimSpace(tester.RunInteractiveShell(t, `hishtory config-get highlight-matches`)))
out = captureTerminalOutputComplex(t, TmuxCaptureConfig{tester: tester, complexCommands: []TmuxCommand{{Keys: "hishtory SPACE tquery ENTER"}, {Keys: "ech"}}, includeEscapeSequences: true})
out = stripTuiCommandPrefix(t, out)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithSearch-Highlight-"+runtime.GOOS)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithSearch-Highlight-"+runtime.GOOS+"-"+testutils.GetOsVersion(t))
// And one more time with customized colors
testutils.CompareGoldens(t, tester.RunInteractiveShell(t, ` hishtory config-get color-scheme`), "TestTui-DefaultColorScheme")
@ -1874,7 +1874,7 @@ func testTui_color(t *testing.T) {
tester.RunInteractiveShell(t, ` hishtory config-set color-scheme border-color #f54272`)
out = captureTerminalOutputComplex(t, TmuxCaptureConfig{tester: tester, complexCommands: []TmuxCommand{{Keys: "hishtory SPACE tquery ENTER"}, {Keys: "ech"}}, includeEscapeSequences: true})
out = stripTuiCommandPrefix(t, out)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithCustomColorScheme-"+runtime.GOOS)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithCustomColorScheme-"+runtime.GOOS+"-"+testutils.GetOsVersion(t))
// And one more time with a default filter
require.Equal(t, "\"\"", strings.TrimSpace(tester.RunInteractiveShell(t, `hishtory config-get default-filter`)))
@ -1882,7 +1882,7 @@ func testTui_color(t *testing.T) {
require.Equal(t, "\"exit_code:0\"", strings.TrimSpace(tester.RunInteractiveShell(t, `hishtory config-get default-filter`)))
out = captureTerminalOutputComplex(t, TmuxCaptureConfig{tester: tester, complexCommands: []TmuxCommand{{Keys: "hishtory SPACE tquery ENTER"}, {Keys: "ech"}}, includeEscapeSequences: true})
out = stripTuiCommandPrefix(t, out)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithDefaultFilter-"+runtime.GOOS)
testutils.CompareGoldens(t, out, "TestTui-ColoredOutputWithDefaultFilter-"+runtime.GOOS+"-"+testutils.GetOsVersion(t))
}
func testTui_delete(t *testing.T) {

View File

@ -1,27 +1,27 @@
Search Query: > ls
Search Query: > ls
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost /tmp/ Oct 17 2022 21:43:21 PDT 3s 2 echo 'aaaaaa bbbb' │
 localhost /tmp/ Oct 17 2022 21:43:16 PDT 3s 2 ls ~/ │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost /tmp/ Oct 17 2022 21:43:21 PDT 3s 2 echo 'aaaaaa bbbb' │
 localhost /tmp/ Oct 17 2022 21:43:16 PDT 3s 2 ls ~/ │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help 

View File

@ -1,27 +1,27 @@
Search Query: > ech 
Search Query: > ech 
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost  /tmp/  Oct 17 2022 21:43:21 PDT  3s  2  echo 'aaaaaa bbbb'  │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost  /tmp/  Oct 17 2022 21:43:21 PDT  3s  2  echo 'aaaaaa bbbb'  │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help 

View File

@ -1,27 +1,27 @@
Search Query: [exit_code:0] ech 
Search Query: [exit_code:0] ech 
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help 

View File

@ -1,27 +1,27 @@
Search Query: > ech 
Search Query: > ech 
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost  /tmp/  Oct 17 2022 21:43:21 PDT  3s  2  echo 'aaaaaa bbbb'  │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost  /tmp/  Oct 17 2022 21:43:21 PDT  3s  2  echo 'aaaaaa bbbb'  │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help 

View File

@ -1,27 +1,27 @@
Search Query: > ech 
Search Query: > ech 
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost /tmp/ Oct 17 2022 21:43:21 PDT 3s 2 echo 'aaaaaa bbbb' │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
 Hostname CWD Timestamp Runtime Exit Code Command │
│────────────────────────────────────────────────────────────────────────────────────────────────────────│
 localhost /tmp/ Oct 17 2022 21:43:21 PDT 3s 2 echo 'aaaaaa bbbb' │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hiSHtory: Search your shell history  • ctrl+h help 

View File

@ -19,6 +19,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"golang.org/x/sys/unix"
)
const (
@ -405,3 +406,12 @@ func normalizeHostnames(data string) string {
}
return data
}
func GetOsVersion(t *testing.T) string {
var uts unix.Utsname
if err := unix.Uname(&uts); err != nil {
panic(err)
}
return unix.ByteSliceToString(uts.Release[:])
}