зеркало из https://github.com/golang/tools.git
gopls/internal/regtest/codelens: use the test's deadline instead of a hard-coded timeout
We may want to generalize this to have regtest.Run always derive the default timeout from the test's deadline. In the meantime, this is a more targeted fix for the specific timeout in TestGCDetails. Fixes golang/go#49902 (Maybe.) Change-Id: Ie15735dc7b0d462ec047d3f3d8a2eceeb4411fa0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/380496 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Родитель
84f205d75e
Коммит
135972eb89
|
@ -292,6 +292,13 @@ func TestGCDetails(t *testing.T) {
|
|||
t.Skipf("the gc details code lens doesn't work on Android")
|
||||
}
|
||||
|
||||
// TestGCDetails seems to suffer from poor performance on certain builders.
|
||||
// Give it as long as it needs to complete.
|
||||
timeout := 60 * time.Second
|
||||
if d, ok := testenv.Deadline(t); ok {
|
||||
timeout = time.Until(d) * 19 / 20 // Leave 5% headroom for cleanup.
|
||||
}
|
||||
|
||||
const mod = `
|
||||
-- go.mod --
|
||||
module mod.com
|
||||
|
@ -311,8 +318,7 @@ func main() {
|
|||
CodeLenses: map[string]bool{
|
||||
"gc_details": true,
|
||||
}},
|
||||
// TestGCDetails seems to suffer from poor performance on certain builders. Give it some more time to complete.
|
||||
Timeout(60*time.Second),
|
||||
Timeout(timeout),
|
||||
).Run(t, mod, func(t *testing.T, env *Env) {
|
||||
env.OpenFile("main.go")
|
||||
env.ExecuteCodeLensCommand("main.go", command.GCDetails)
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
exec "golang.org/x/sys/execabs"
|
||||
)
|
||||
|
@ -307,3 +308,15 @@ func SkipAfterGo1Point(t Testing, x int) {
|
|||
t.Skipf("running Go version %q is version 1.%d, newer than maximum 1.%d", runtime.Version(), Go1Point(), x)
|
||||
}
|
||||
}
|
||||
|
||||
// Deadline returns the deadline of t, if known,
|
||||
// using the Deadline method added in Go 1.15.
|
||||
func Deadline(t Testing) (time.Time, bool) {
|
||||
td, ok := t.(interface {
|
||||
Deadline() (time.Time, bool)
|
||||
})
|
||||
if !ok {
|
||||
return time.Time{}, false
|
||||
}
|
||||
return td.Deadline()
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче