From ab3004bcd56792a0caba4c6436567ca92c904d61 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 15 Jan 2024 20:49:47 +1100 Subject: [PATCH] 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. --- pkg/gui/gui_driver.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go index e7fa097d3..3421602e9 100644 --- a/pkg/gui/gui_driver.go +++ b/pkg/gui/gui_driver.go @@ -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"), )