mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
give CI longer wait times before failing assertions
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user