Skip to content

Commit fc2120c

Browse files
committed
Show unacknowledged toast message upon integration test failure
Often if a test fails and there's an unaknowledged toast message, that message will explain why the test failed. Given that we don't display toast messages in integration tests when they run (for reasons I can't recall right now), we need to log it as part of the error message.
1 parent bbf2159 commit fc2120c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/gui/gui_driver.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,18 @@ func (self *GuiDriver) ContextForView(viewName string) types.Context {
8888

8989
func (self *GuiDriver) Fail(message string) {
9090
currentView := self.gui.g.CurrentView()
91+
92+
// Check for unacknowledged toast: it may give us a hint as to why the test failed
93+
toastMessage := ""
94+
if t := self.NextToast(); t != nil {
95+
toastMessage = fmt.Sprintf("Unacknowledged toast message: %s\n", *t)
96+
}
97+
9198
fullMessage := fmt.Sprintf(
92-
"%s\nFinal Lazygit state:\n%s\nUpon failure, focused view was '%s'.\nLog:\n%s", message,
99+
"%s\nFinal Lazygit state:\n%s\nUpon failure, focused view was '%s'.\n%sLog:\n%s", message,
93100
self.gui.g.Snapshot(),
94101
currentView.Name(),
102+
toastMessage,
95103
strings.Join(self.gui.GuiLog, "\n"),
96104
)
97105

0 commit comments

Comments
 (0)