1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-19 21:28:28 +02:00

give CI longer wait times before failing assertions

This commit is contained in:
Jesse Duffield 2023-02-25 21:33:52 +11:00
parent dd1bf629b8
commit 9c645088bf
2 changed files with 13 additions and 3 deletions

View File

@ -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:

View File

@ -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