Skip to content

Commit

Permalink
go/ssa: reenable TestStdlib
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
  • Loading branch information
adonovan committed Sep 10, 2024
1 parent b7af269 commit b0f680c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions go/ssa/stdlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ func bytesAllocated() uint64 {
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
// returned by the 'std' query, the set is essentially transitively
// closed, so marginal per-dependency costs are invisible.
func TestStdlib(t *testing.T) {
t.Skip("broken; see https://go.dev/issues/69287")
testLoad(t, 500, "std", "cmd")
}

Expand Down Expand Up @@ -78,6 +83,9 @@ func testLoad(t *testing.T, minPkgs int, patterns ...string) {
if err != nil {
t.Fatal(err)
}
if packages.PrintErrors(pkgs) > 0 {
t.Fatal("there were errors loading the packages")
}

t1 := time.Now()
alloc1 := bytesAllocated()
Expand Down Expand Up @@ -195,9 +203,13 @@ func srcFunctions(prog *ssa.Program, pkgs []*packages.Package) (res []*ssa.Funct
if decl, ok := decl.(*ast.FuncDecl); ok {
obj := pkg.TypesInfo.Defs[decl.Name].(*types.Func)
if obj == nil {
panic("nil *Func")
panic("nil *types.Func: " + decl.Name.Name)
}
fn := prog.FuncValue(obj)
if fn == nil {
panic("nil *ssa.Function: " + obj.String())
}
addSrcFunc(prog.FuncValue(obj))
addSrcFunc(fn)
}
}
}
Expand Down

0 comments on commit b0f680c

Please sign in to comment.