add new integration test pattern

This commit is contained in:
Jesse Duffield 2022-08-07 22:09:39 +10:00
parent c7f9d5801b
commit 77881a9c7d
154 changed files with 1514 additions and 670 deletions

View file

@ -31,6 +31,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/integration"
"github.com/jesseduffield/lazygit/pkg/tasks"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/updates"
@ -418,12 +419,14 @@ var RuneReplacements = map[rune]string{
}
func (gui *Gui) initGocui(headless bool) (*gocui.Gui, error) {
recordEvents := recordingEvents()
recordEvents := integration.RecordingEvents()
playMode := gocui.NORMAL
if recordEvents {
playMode = gocui.RECORDING
} else if replaying() {
} else if integration.Replaying() {
playMode = gocui.REPLAYING
} else if integration.IntegrationTestName() != "" {
playMode = gocui.REPLAYING_NEW
}
g, err := gocui.NewGui(gocui.OutputTrue, OverlappingEdges, playMode, headless, RuneReplacements)
@ -475,7 +478,7 @@ func (gui *Gui) viewTabMap() map[string][]context.TabView {
// Run: setup the gui with keybindings and start the mainloop
func (gui *Gui) Run(startArgs types.StartArgs) error {
g, err := gui.initGocui(headless())
g, err := gui.initGocui(integration.Headless())
if err != nil {
return err
}
@ -490,23 +493,7 @@ func (gui *Gui) Run(startArgs types.StartArgs) error {
})
deadlock.Opts.Disable = !gui.Debug
if replaying() {
gui.g.RecordingConfig = gocui.RecordingConfig{
Speed: getRecordingSpeed(),
Leeway: 100,
}
var err error
gui.g.Recording, err = gui.loadRecording()
if err != nil {
return err
}
go utils.Safe(func() {
time.Sleep(time.Second * 40)
log.Fatal("40 seconds is up, lazygit recording took too long to complete")
})
}
gui.handleTestMode()
gui.g.OnSearchEscape = gui.onSearchEscape
if err := gui.Config.ReloadUserConfig(); err != nil {
@ -593,7 +580,7 @@ func (gui *Gui) RunAndHandleError(startArgs types.StartArgs) error {
}
}
if err := gui.saveRecording(gui.g.Recording); err != nil {
if err := integration.SaveRecording(gui.g.Recording); err != nil {
return err
}
@ -627,7 +614,7 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool,
gui.Mutexes.SubprocessMutex.Lock()
defer gui.Mutexes.SubprocessMutex.Unlock()
if replaying() {
if integration.Replaying() {
// we do not yet support running subprocesses within integration tests. So if
// we're replaying an integration test and we're inside this method, something
// has gone wrong, so we should fail