mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-21 21:47:32 +02:00
give CI longer wait times before failing assertions
This commit is contained in:
parent
dd1bf629b8
commit
9c645088bf
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -98,8 +98,9 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{runner.os}}-go-
|
${{runner.os}}-go-
|
||||||
- name: Test code
|
- name: Test code
|
||||||
|
# LONG_WAIT_BEFORE_FAIL means that for a given test assertion, we'll wait longer before failing
|
||||||
run: |
|
run: |
|
||||||
go test pkg/integration/clients/*.go
|
LONG_WAIT_BEFORE_FAIL=true go test pkg/integration/clients/*.go
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package components
|
package components
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||||
@ -11,7 +12,15 @@ type assertionHelper struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// milliseconds we'll wait when an assertion fails.
|
// 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) {
|
func (self *assertionHelper) matchString(matcher *Matcher, context string, getValue func() string) {
|
||||||
self.assertWithRetries(func() (bool, 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)) {
|
func (self *assertionHelper) assertWithRetries(test func() (bool, string)) {
|
||||||
var message string
|
var message string
|
||||||
for _, waitTime := range retryWaitTimes {
|
for _, waitTime := range retryWaitTimes() {
|
||||||
time.Sleep(time.Duration(waitTime) * time.Millisecond)
|
time.Sleep(time.Duration(waitTime) * time.Millisecond)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user