Add additional check against hishtory export to help debug control-r test failures that only reproduce in github actions

This commit is contained in:
David Dworken 2023-11-20 21:00:37 -08:00
parent fb07d53839
commit ad7ca2dffc
No known key found for this signature in database
3 changed files with 10 additions and 2 deletions

View File

@ -1970,15 +1970,17 @@ func testControlR(t *testing.T, tester shellTester, shellName string, onlineStat
require.NoError(t, db.Create(testutils.MakeFakeHistoryEntry("echo 'aaaaaa bbbb'")).Error) require.NoError(t, db.Create(testutils.MakeFakeHistoryEntry("echo 'aaaaaa bbbb'")).Error)
require.NoError(t, db.Create(testutils.MakeFakeHistoryEntry("echo 'bar' &")).Error) require.NoError(t, db.Create(testutils.MakeFakeHistoryEntry("echo 'bar' &")).Error)
// Check that they're there // Check that they're there (and there aren't any other entries)
var historyEntries []*data.HistoryEntry var historyEntries []*data.HistoryEntry
db.Model(&data.HistoryEntry{}).Find(&historyEntries) db.Model(&data.HistoryEntry{}).Find(&historyEntries)
if len(historyEntries) != 5 { if len(historyEntries) != 5 {
t.Fatalf("expected to find 6 history entries, actual found %d: %#v", len(historyEntries), historyEntries) t.Fatalf("expected to find 6 history entries, actual found %d: %#v", len(historyEntries), historyEntries)
} }
out := tester.RunInteractiveShell(t, `hishtory export`)
testutils.CompareGoldens(t, out, "testControlR-InitialExport")
// And check that the control-r binding brings up the search // And check that the control-r binding brings up the search
out := captureTerminalOutputWithShellName(t, tester, shellName, []string{"C-R"}) out = captureTerminalOutputWithShellName(t, tester, shellName, []string{"C-R"})
split := strings.Split(out, "\n\n\n") split := strings.Split(out, "\n\n\n")
out = strings.TrimSpace(split[len(split)-1]) out = strings.TrimSpace(split[len(split)-1])
testutils.CompareGoldens(t, out, "testControlR-Initial") testutils.CompareGoldens(t, out, "testControlR-Initial")

View File

@ -0,0 +1,5 @@
ls ~/
ls ~/foo/
ls ~/bar/
echo 'aaaaaa bbbb'
echo 'bar' &

View File

@ -260,6 +260,7 @@ func captureTerminalOutputComplex(t testing.TB, captureConfig TmuxCaptureConfig)
fullCommand += "\n" fullCommand += "\n"
fullCommand += " tmux kill-session -t foo\n" fullCommand += " tmux kill-session -t foo\n"
testutils.TestLog(t, "Running tmux command: "+fullCommand) testutils.TestLog(t, "Running tmux command: "+fullCommand)
// TODO: Can this use the strict version instead?
out, err := captureConfig.tester.RunInteractiveShellRelaxed(t, fullCommand) out, err := captureConfig.tester.RunInteractiveShellRelaxed(t, fullCommand)
require.NoError(t, err) require.NoError(t, err)
return strings.TrimSpace(out) return strings.TrimSpace(out)