1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

show snapshot of lazygit when test fails for easier investigation

This commit is contained in:
Jesse Duffield
2023-02-19 14:49:19 +11:00
parent b5e325b0a4
commit a51f64814c
5 changed files with 40 additions and 5 deletions

View File

@@ -50,10 +50,18 @@ func (self *GuiDriver) CurrentContext() types.Context {
}
func (self *GuiDriver) Fail(message string) {
currentView := self.gui.g.CurrentView()
fullMessage := fmt.Sprintf(
"%s\nFinal Lazygit state:\n%s\nUpon failure, focused view was '%s'.\nLog:\n%s", message,
self.gui.g.Snapshot(),
currentView.Name(),
strings.Join(self.gui.CmdLog, "\n"),
)
self.gui.g.Close()
// need to give the gui time to close
time.Sleep(time.Millisecond * 100)
panic(fmt.Sprintf("%s\nLog:\n%s", message, strings.Join(self.gui.CmdLog, "\n")))
panic(fullMessage)
}
// logs to the normal place that you log to i.e. viewable with `lazygit --logs`