mirror of
https://github.com/golang/go
synced 2024-11-18 16:44:43 -07:00
go/packages: sort root list in Load
The builders are currently flaky failing because of a root order being wrong. This causes all root lists to be sorted before being returned, so the order is always stable no matter which underlying driver is running. Fixes golang/go#27594 Change-Id: I09db45c67ad00f23dfaec8e271acbd13fc338888 Reviewed-on: https://go-review.googlesource.com/c/143737 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
9aea6da185
commit
2d2de62981
@ -131,7 +131,6 @@ extractQueries:
|
||||
return nil, err
|
||||
}
|
||||
response.Roots = append(response.Roots, namedResults...)
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
@ -246,11 +246,6 @@ func golistDriverFallback(cfg *Config, words ...string) (*driverResponse, error)
|
||||
createTestVariants(&response, v.pkg, v.xtestPkg)
|
||||
}
|
||||
|
||||
// TODO(matloob): Is this the right ordering?
|
||||
sort.SliceStable(response.Packages, func(i, j int) bool {
|
||||
return response.Packages[i].PkgPath < response.Packages[j].PkgPath
|
||||
})
|
||||
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@ -173,6 +174,7 @@ func Load(cfg *Config, patterns ...string) ([]*Package, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sort.Strings(response.Roots) // make all driver responses deterministic
|
||||
return l.refine(response.Roots, response.Packages...)
|
||||
}
|
||||
|
||||
|
@ -298,8 +298,9 @@ func TestLoadAbsolutePath(t *testing.T) {
|
||||
for _, p := range initial {
|
||||
got = append(got, p.ID)
|
||||
}
|
||||
if !reflect.DeepEqual(got, []string{"golang.org/gopatha/a", "golang.org/gopathb/b"}) {
|
||||
t.Fatalf("initial packages loaded: got [%s], want [a b]", got)
|
||||
want := []string{"golang.org/gopatha/a", "golang.org/gopathb/b"}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("initial packages loaded: got [%s], want [%s]", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user