summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-25 21:33:52 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-02-25 21:37:16 +1100
commit9c645088bf2dc7baea950f39d11ceb02f5eb9721 (patch)
tree4d36bf12735db90c1c43b20834a01363072c3e00
parentdd1bf629b87db297a6336511a4e1ba39ba7afbc8 (diff)
give CI longer wait times before failing assertions
-rw-r--r--.github/workflows/ci.yml3
-rw-r--r--pkg/integration/components/assertion_helper.go13
2 files changed, 13 insertions, 3 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d09b8a53a..646fdde7f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -98,8 +98,9 @@ jobs:
restore-keys: |
${{runner.os}}-go-
- name: Test code
+ # LONG_WAIT_BEFORE_FAIL means that for a given test assertion, we'll wait longer before failing
run: |
- go test pkg/integration/clients/*.go
+ LONG_WAIT_BEFORE_FAIL=true go test pkg/integration/clients/*.go
build:
runs-on: ubuntu-latest
env:
diff --git a/pkg/integration/components/assertion_helper.go b/pkg/integration/components/assertion_helper.go
index 23539a8d3..b60bda17b 100644
--- a/pkg/integration/components/assertion_helper.go
+++ b/pkg/integration/components/assertion_helper.go
@@ -1,6 +1,7 @@
package components
import (
+ "os"
"time"
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
@@ -11,7 +12,15 @@ type assertionHelper struct {
}
// milliseconds we'll wait when an assertion fails.
-var retryWaitTimes = []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000}
+func retryWaitTimes() []int {
+ if os.Getenv("LONG_WAIT_BEFORE_FAIL") == "true" {
+ // CI has limited hardware, may be throttled, runs tests in parallel, etc, so we
+ // give it more leeway compared to when we're running things locally.
+ return []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000}
+ } else {
+ return []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100}
+ }
+}
func (self *assertionHelper) matchString(matcher *Matcher, context string, getValue func() string) {
self.assertWithRetries(func() (bool, string) {
@@ -22,7 +31,7 @@ func (self *assertionHelper) matchString(matcher *Matcher, context string, getVa
func (self *assertionHelper) assertWithRetries(test func() (bool, string)) {
var message string
- for _, waitTime := range retryWaitTimes {
+ for _, waitTime := range retryWaitTimes() {
time.Sleep(time.Duration(waitTime) * time.Millisecond)
var ok bool