diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-15 20:49:47 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-19 10:50:49 +1100 |
commit | ab3004bcd56792a0caba4c6436567ca92c904d61 (patch) | |
tree | bdd463c87265dbf8bf122e681ce36e6c24ce7144 /pkg/gui/gui_driver.go | |
parent | 1ea0c270df13f30d2e74cea7ec78ea3a62df1d82 (diff) |
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.
Diffstat (limited to 'pkg/gui/gui_driver.go')
-rw-r--r-- | pkg/gui/gui_driver.go | 10 |
1 files changed, 9 insertions, 1 deletions
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"), ) |