diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-02-19 14:49:19 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-02-19 15:48:09 +1100 |
commit | a51f64814ce9aab9405ad64e65645694cad5c8e3 (patch) | |
tree | 356c4a3305bc2ce1df550db6abbb39219ed5082f /pkg/gui/gui_driver.go | |
parent | b5e325b0a487f9ae6122d8410c393f60ea40251d (diff) |
show snapshot of lazygit when test fails for easier investigation
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 cf1e3bbb4..d9735c2fe 100644 --- a/pkg/gui/gui_driver.go +++ b/pkg/gui/gui_driver.go @@ -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` |