Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: "undefined: testing.InternalFuzzTarget" when attempting to build minimal test package (on tip) #51666

Closed
mark-rushakoff opened this issue Mar 14, 2022 · 2 comments

Comments

@mark-rushakoff
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version devel go1.19-41fe746857 Mon Mar 14 18:03:37 2022 +0000 darwin/amd64

Does this issue reproduce with the latest release?

No.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hh/Library/Caches/go-build"
GOENV="/Users/hh/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/hh/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/hh/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17.8/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17.8/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.19-41fe746857 Mon Mar 14 18:03:37 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/tmp/z/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_m/h25_32y958gbgk67m97141400000gq/T/go-build562485514=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I wrote a minimal test file:

package z_test

import "testing"

func TestZ(t *testing.T) {
}

and a minimal go.mod:

module z

go 1.17

Running go test fails:

What did you expect to see?

$ go test .
ok  	z	0.180s

What did you see instead?

$ gotip test .
# z.test
/var/folders/_m/h25_32y958gbgk67m97141400000gq/T/go-build396096674/b001/_testmain.go:29:21: undefined: testing.InternalFuzzTarget
/var/folders/_m/h25_32y958gbgk67m97141400000gq/T/go-build396096674/b001/_testmain.go:45:24: too many arguments in call to testing.MainStart
FAIL	z [build failed]
FAIL

I also ran with -x in case that is helpful:

gotip test -x output
gotip test -x .
WORK=/var/folders/_m/h25_32y958gbgk67m97141400000gq/T/go-build1267485252
mkdir -p $WORK/b001/
mkdir -p $WORK/b006/
mkdir -p $WORK/b030/
mkdir -p $WORK/b016/
mkdir -p $WORK/b015/
mkdir -p $WORK/b036/
mkdir -p $WORK/b012/
mkdir -p $WORK/b034/
mkdir -p $WORK/b014/
mkdir -p $WORK/b021/
mkdir -p $WORK/b011/
mkdir -p $WORK/b009/
mkdir -p $WORK/b010/
mkdir -p $WORK/b013/
mkdir -p $WORK/b022/
mkdir -p $WORK/b033/
mkdir -p $WORK/b008/
mkdir -p $WORK/b005/
mkdir -p $WORK/b020/
mkdir -p $WORK/b004/
mkdir -p $WORK/b027/
mkdir -p $WORK/b043/
mkdir -p $WORK/b019/
mkdir -p $WORK/b029/
mkdir -p $WORK/b044/
mkdir -p $WORK/b017/
mkdir -p $WORK/b031/
mkdir -p $WORK/b035/
mkdir -p $WORK/b038/
mkdir -p $WORK/b042/
mkdir -p $WORK/b032/
mkdir -p $WORK/b023/
mkdir -p $WORK/b041/
mkdir -p $WORK/b025/
mkdir -p $WORK/b026/
mkdir -p $WORK/b024/
mkdir -p $WORK/b047/
mkdir -p $WORK/b028/
mkdir -p $WORK/b018/
mkdir -p $WORK/b003/
mkdir -p $WORK/b045/
mkdir -p $WORK/b040/
mkdir -p $WORK/b039/
mkdir -p $WORK/b046/
mkdir -p $WORK/b037/
mkdir -p $WORK/b059/
cat >$WORK/b001/importcfg << 'EOF' # internal
# import config
packagefile os=/Users/hh/Library/Caches/go-build/31/3142f0a4fa2248001fa6c3b95fe3ff420011ebe1cbc48d531830a6fbb6ada0f6-d
packagefile reflect=/Users/hh/Library/Caches/go-build/09/09f2184a164458f862dc15c0a13006bea12c31a35efb6b0920d30cd22aecedc3-d
packagefile testing=/Users/hh/Library/Caches/go-build/31/3126f1b99685a140a77b8d98cd47e5d89a589bc5ab0e7263265234f76d4c8a65-d
packagefile testing/internal/testdeps=/Users/hh/Library/Caches/go-build/70/709c2fbe97ebc860a78b7cdb18d8f0ef4959d7105933b8f137ee104ff21d3b5a-d
packagefile runtime=/Users/hh/Library/Caches/go-build/b6/b6495d6d4bd290c135fa21eab02252b68be2a8f63f256c5f6ff2b19410e96f3e-d
packagefile z_test=/Users/hh/Library/Caches/go-build/c9/c9db00b33350ccbd26a1a0c1f8b6cd72e6b2badc63533877b04d7a6f3810d61a-d
EOF
cd /tmp/z
/usr/local/Cellar/go/1.17.8/libexec/pkg/tool/darwin_amd64/compile -o $WORK/b001/_pkg_.a -trimpath "$WORK/b001=>" -p main -lang=go1.17 -complete -buildid 5glPu2yppA15mVXKI1_G/5glPu2yppA15mVXKI1_G -dwarf=false -c=4 -nolocalimports -importcfg $WORK/b001/importcfg -pack $WORK/b001/_testmain.go
cat >$WORK/b059/vet.cfg << 'EOF' # internal
{
	"ID": "z_test",
	"Compiler": "gc",
	"Dir": "/tmp/z",
	"ImportPath": "z_test",
	"GoFiles": [
		"/tmp/z/z_test.go"
	],
	"NonGoFiles": [],
	"IgnoredFiles": [],
	"ImportMap": {
		"testing": "testing"
	},
	"PackageFile": {
		"testing": "/Users/hh/Library/Caches/go-build/31/3126f1b99685a140a77b8d98cd47e5d89a589bc5ab0e7263265234f76d4c8a65-d"
	},
	"Standard": {
		"testing": true
	},
	"PackageVetx": {
		"testing": "/Users/hh/Library/Caches/go-build/9c/9c1171cfe176cfdc7d7a0a718b2d6dc53a1b328b81756d9191df1dfccc2268a9-d"
	},
	"VetxOnly": false,
	"VetxOutput": "$WORK/b059/vet.out",
	"SucceedOnTypecheckFailure": false
}
EOF
TERM='dumb' /usr/local/Cellar/go/1.17.8/libexec/pkg/tool/darwin_amd64/vet -atomic -bool -buildtags -errorsas -ifaceassert -nilfunc -printf -stringintconv $WORK/b059/vet.cfg
# z.test
/var/folders/_m/h25_32y958gbgk67m97141400000gq/T/go-build1267485252/b001/_testmain.go:29:21: undefined: testing.InternalFuzzTarget
/var/folders/_m/h25_32y958gbgk67m97141400000gq/T/go-build1267485252/b001/_testmain.go:45:24: too many arguments in call to testing.MainStart
rm -r $WORK/b001/
FAIL	z [build failed]
FAIL
@seankhliao
Copy link
Member

do you have an explicit GOROOT setting?
the go command is tip, but it's using a 1.17.8 root installed with brew

@mark-rushakoff
Copy link
Contributor Author

Thanks @seankhliao, that was it. This is a new user account on an existing machine, and I did not intend for GOROOT to be set; but after running unset GOROOT, I was able to run tests with gotip properly.

@golang golang locked and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants