Skip to content

Commit

Permalink
Show unacknowledged toast message upon integration test failure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jesseduffield committed Jan 18, 2024
1 parent 1ea0c27 commit ab3004b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/gui/gui_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,18 @@ func (self *GuiDriver) ContextForView(viewName string) types.Context {

func (self *GuiDriver) Fail(message string) {
currentView := self.gui.g.CurrentView()

// Check for unacknowledged toast: it may give us a hint as to why the test failed
toastMessage := ""
if t := self.NextToast(); t != nil {
toastMessage = fmt.Sprintf("Unacknowledged toast message: %s\n", *t)
}

fullMessage := fmt.Sprintf(
"%s\nFinal Lazygit state:\n%s\nUpon failure, focused view was '%s'.\nLog:\n%s", message,
"%s\nFinal Lazygit state:\n%s\nUpon failure, focused view was '%s'.\n%sLog:\n%s", message,
self.gui.g.Snapshot(),
currentView.Name(),
toastMessage,
strings.Join(self.gui.GuiLog, "\n"),
)

Expand Down

0 comments on commit ab3004b

Please sign in to comment.