summaryrefslogtreecommitdiffstats
path: root/pkg/gui/recording.go
diff options
context:
space:
mode:
authorCI <CI@example.com>2020-10-06 08:01:25 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-10-10 00:23:01 +1100
commit2657060aa28d88e3089686ca1ab0a6343b653b01 (patch)
tree6ef3e563a08994d9d13234e6117c541c24ba1238 /pkg/gui/recording.go
parent2724f3888a288aed1d5075465e7905cff1b8923e (diff)
support running integration tests in parallel
Diffstat (limited to 'pkg/gui/recording.go')
-rw-r--r--pkg/gui/recording.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/pkg/gui/recording.go b/pkg/gui/recording.go
index e47dac0ae..0f8f9a370 100644
--- a/pkg/gui/recording.go
+++ b/pkg/gui/recording.go
@@ -28,6 +28,11 @@ func (gui *Gui) replayRecordedEvents() {
return
}
+ go func() {
+ time.Sleep(time.Second * 20)
+ log.Fatal("20 seconds is up, lazygit recording took too long to complete")
+ }()
+
events, err := gui.loadRecordedEvents()
if err != nil {
log.Fatal(err)
@@ -49,13 +54,26 @@ func (gui *Gui) replayRecordedEvents() {
}
}
- for _, event := range events {
+ // The playback could be paused at any time because integration tests run concurrently.
+ // Therefore we can't just check for a given event whether we've passed its timestamp,
+ // or else we'll have an explosion of keypresses after the test is resumed.
+ // We need to check if we've waited long enough since the last event was replayed.
+ for i, event := range events {
+ var prevEventTimestamp int64 = 0
+ if i > 0 {
+ prevEventTimestamp = events[i-1].Timestamp
+ }
+ timeToWait := (event.Timestamp - prevEventTimestamp) / int64(speed)
+ if i == 0 {
+ timeToWait += leeway
+ }
+ var timeWaited int64 = 0
middle:
for {
select {
case <-ticker.C:
- now := gui.timeSinceStart()*int64(speed) - leeway
- if gui.g != nil && now >= event.Timestamp {
+ timeWaited += 1
+ if gui.g != nil && timeWaited >= timeToWait {
gui.g.ReplayedEvents <- *event.Event
break middle
}