зеркало из https://github.com/golang/tools.git
go/ssa: reenable TestStdlib
It wasn't broken on the builder--only with my local go toolchain. (There was some cgo-related problem with cmd/cgo/internal/test.) At least that explains why we didn't notice the failures... This CL also adds a missing error check that made the real cause of the problem hard to spot, and improves some comments and assertions. Fixes golang/go#69287 Change-Id: Iccbe2a72770499749ca780f78e2a61d5576f613b Reviewed-on: https://go-review.googlesource.com/c/tools/+/612044 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Родитель
b7af269531
Коммит
b0f680ccb8
|
@ -35,13 +35,18 @@ func bytesAllocated() uint64 {
|
||||||
return stats.Alloc
|
return stats.Alloc
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestStdlib loads the entire standard library and its tools.
|
// TestStdlib loads the entire standard library and its tools and all
|
||||||
|
// their dependencies.
|
||||||
|
//
|
||||||
|
// (As of go1.23, std is transitively closed, so adding the -deps flag
|
||||||
|
// doesn't increase its result set. The cmd pseudomodule of course
|
||||||
|
// depends on a good chunk of std, but the std+cmd set is also
|
||||||
|
// transitively closed, so long as -pgo=off.)
|
||||||
//
|
//
|
||||||
// Apart from a small number of internal packages that are not
|
// Apart from a small number of internal packages that are not
|
||||||
// returned by the 'std' query, the set is essentially transitively
|
// returned by the 'std' query, the set is essentially transitively
|
||||||
// closed, so marginal per-dependency costs are invisible.
|
// closed, so marginal per-dependency costs are invisible.
|
||||||
func TestStdlib(t *testing.T) {
|
func TestStdlib(t *testing.T) {
|
||||||
t.Skip("broken; see https://go.dev/issues/69287")
|
|
||||||
testLoad(t, 500, "std", "cmd")
|
testLoad(t, 500, "std", "cmd")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +83,9 @@ func testLoad(t *testing.T, minPkgs int, patterns ...string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if packages.PrintErrors(pkgs) > 0 {
|
||||||
|
t.Fatal("there were errors loading the packages")
|
||||||
|
}
|
||||||
|
|
||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
alloc1 := bytesAllocated()
|
alloc1 := bytesAllocated()
|
||||||
|
@ -195,9 +203,13 @@ func srcFunctions(prog *ssa.Program, pkgs []*packages.Package) (res []*ssa.Funct
|
||||||
if decl, ok := decl.(*ast.FuncDecl); ok {
|
if decl, ok := decl.(*ast.FuncDecl); ok {
|
||||||
obj := pkg.TypesInfo.Defs[decl.Name].(*types.Func)
|
obj := pkg.TypesInfo.Defs[decl.Name].(*types.Func)
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
panic("nil *Func")
|
panic("nil *types.Func: " + decl.Name.Name)
|
||||||
}
|
}
|
||||||
addSrcFunc(prog.FuncValue(obj))
|
fn := prog.FuncValue(obj)
|
||||||
|
if fn == nil {
|
||||||
|
panic("nil *ssa.Function: " + obj.String())
|
||||||
|
}
|
||||||
|
addSrcFunc(fn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче