go: x/tools/go/ssa: CreateTestMainPackage broken by fuzzing changes

~/x/tools$ gotip version
go version devel go1.18-051df0d72 Wed Sep 22 03:45:00 2021 +0000 linux/amd64

~/x/tools$ gotip test ./go/pointer
Entering directory `/usr/local/google/home/bcmills/x/tools/go/pointer'
Entering directory `/usr/local/google/home/bcmills/x/tools/go/pointer'
2021/09/22 11:06:56 internal error type-checking main$testmain: main$testmain.go:43:59: not enough arguments in call to testing.MainStart
FAIL    golang.org/x/tools/go/pointer   2.067s
FAIL

That failure comes from here:

		log.Fatalf("internal error type-checking %s: %v", path, err)

This function is a known technical debt:

// TODO(adonovan): throws this all away now that x/tools/go/packages
// provides access to the actual synthetic test main files.

CC @jayconrod @ianthehat

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (11 by maintainers)

Commits related to this issue

Most upvoted comments

switching x/tools/go/ssa to use x/tools/go/packages instead of rolling its own test binary, or

This is the best option I think. Depending on an unstable API makes it unnecessarily difficult to make changes like this.

Is CreateTestMainPackage deprecated?

Yep! Per https://pkg.go.dev/golang.org/x/tools/go/ssa#Program.CreateTestMainPackage: “Deprecated: Use golang.org/x/tools/go/packages to access synthetic testmain packages.”

Is it possible to use a different API instead, would that be another possible solution?

That is exactly the “switching x/tools/go/ssa to use x/tools/go/packages” option, I think. 🙂

Either approach is ok by me.

I am still working on removing usage of this API from guru, which will hopefully allow us to delete this API altogether.

However, this particular issue might be interpreted as being concerned with ssa only. If that is the case, then we can close this issue and I can open another issue for tracking the progress of getting rid of this API.