mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 21:05:48 +02:00
Fix flaky integration test (#4432)
- **PR Description**
The integration test `stash/rename.go` occasionally fails for me
locally. This PR fixes it.
In 8b8343b8a9
we made a change to run newPtyTask from AfterLayout; this
is needed so that the PTY gets the new, updated view size. However, this
created a race condition for integration tests that select a line in a
list view and then expect the main view to have certain content;
sometimes that content gets rendered too late.
I'm surprised that this didn't cause more tests to fail; right now I
only know of one test that occasionally fails because of this, which is
`stash/rename.go`.
Fix this by moving the AfterLayout to inside newPtyTask, and do it only
when we are actually using a PTY (we don't when no pager is configured,
which is the case for integration tests).
The diff is best viewed with "ignore whitespace" turned on.
This commit is contained in:
commit
cd2286276c
2 changed files with 39 additions and 36 deletions
|
@ -20,10 +20,7 @@ func (gui *Gui) runTaskForView(view *gocui.View, task types.UpdateTask) error {
|
||||||
return gui.newCmdTask(view, v.Cmd, v.Prefix)
|
return gui.newCmdTask(view, v.Cmd, v.Prefix)
|
||||||
|
|
||||||
case *types.RunPtyTask:
|
case *types.RunPtyTask:
|
||||||
gui.afterLayout(func() error {
|
|
||||||
return gui.newPtyTask(view, v.Cmd, v.Prefix)
|
return gui.newPtyTask(view, v.Cmd, v.Prefix)
|
||||||
})
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -54,6 +54,13 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
||||||
return gui.newCmdTask(view, cmd, prefix)
|
return gui.newCmdTask(view, cmd, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run the pty after layout so that it gets the correct size
|
||||||
|
gui.afterLayout(func() error {
|
||||||
|
// Need to get the width and the pager again because the layout might have
|
||||||
|
// changed the size of the view
|
||||||
|
width = view.InnerWidth()
|
||||||
|
pager = gui.git.Config.GetPager(width)
|
||||||
|
|
||||||
cmdStr := strings.Join(cmd.Args, " ")
|
cmdStr := strings.Join(cmd.Args, " ")
|
||||||
|
|
||||||
// This communicates to pagers that we're in a very simple
|
// This communicates to pagers that we're in a very simple
|
||||||
|
@ -90,9 +97,8 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
linesToRead := gui.linesToReadFromCmdTask(view)
|
linesToRead := gui.linesToReadFromCmdTask(view)
|
||||||
if err := manager.NewTask(manager.NewCmdTask(start, prefix, linesToRead, onClose), cmdStr); err != nil {
|
return manager.NewTask(manager.NewCmdTask(start, prefix, linesToRead, onClose), cmdStr)
|
||||||
return err
|
})
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue