Closed dmitshur closed 3 years ago
This is expected behavior today. Those tests only work after make.bash, which will install binaries for internal-to-cmd packages. The fix would be for the tests to use golang.org/x/tools/go/packages, but they can't unless we vendor it, and it seems a bit much to vendor it just for a test.
If you need go test (not go test -short) to work after a binary install, then I would suggest disabling the test entirely. But I also question why you are running go test (without -short) after a binary install.
Just to add a note on the topic of the -short flag, I tried both with and without it before filing the issue, but included only the former.
With -short, only TestCheck
runs and fails.
go/types
can be imported by user code, so I think it's important that users be able to successfully run go test go/types
via go test all
(compare #28387).
The error messages produced by the tests look a lot like the symptom of #34860. I wonder if something in either the tests or in go/types
itself needs to be updated to set the Dir
field on a go/build.Context
struct somewhere (added in Go 1.14).
Ran into this today.
I downloaded the latest tarball (go version go1.16.2 linux/amd64) on a computer with a recent Debian install. I ran go test std
to make sure everything was okay with the new setup. I did not expect any failures caused by how I installed Go itself.
These tests also fail for me when run on a GOROOT from the Windows installer.
I can reproduce both failures by running:
~/go/src$ ./make.bash
~/go/src$ rm -r $(go env GOROOT)/pkg/*/cmd
~/go/src$ go test go/types -run='TestStdlib|TestCheck'
Change https://golang.org/cl/330253 mentions this issue: go/types: in (*Checker).qualifier, mark the current package even if it is not the first
Change https://golang.org/cl/330252 mentions this issue: go/types: in tests, import from source when standard-library export data is unavailable
CL 330252 fixes TestStdlib
, and changes the failure mode of TestCheck
.
The new failure mode of TestCheck
has uncovered some other latent bug: it identifies a transitive import of regexp/syntax
when importing from source, but not when importing from installed export data. The difference in observed dependencies changes which paths are reported in error messages.
Change https://golang.org/cl/330431 mentions this issue: go/types: in TestCheck/issues.src, import regexp/syntax instead of cmd/compile/internal/syntax
This should now be fixed:
~/go-review/src$ go install std cmd
~/go-review/src$ rm -r $(go env GOROOT)/pkg/*/cmd
~/go-review/src$ go test go/types
ok go/types 17.050s
Change https://golang.org/cl/336351 mentions this issue: [dev.typeparams] cmd/compile/internal/types2: import regexp/syntax instead of cmd/compile/internal/syntax
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Installed Go 1.15.6 on an Intel Mac using go1.15.6.darwin-amd64.pkg from https://golang.org/dl/ and ran tests for the
go/types
package.What did you expect to see?
What did you see instead?
TestCheck
andTestStdlib
tests fail.``` $ go test go/types --- FAIL: TestCheck (0.17s) check_test.go:238: testdata/issues.src:9:6: no error expected: "could not import cmd/compile/internal/syntax (can't find import: \"cmd/compile/internal/syntax\")" check_test.go:293: --- issues: 2 source positions with expected (but not reported) errors: check_test.go:296: testdata/issues.src:335:4: "f.foo undefined \\(type \\*syntax.File has no field or method foo\\)" check_test.go:296: testdata/issues.src:360:20: "cannot convert 0 \\(untyped int constant\\) to \\*syntax.File" --- FAIL: TestStdlib (7.56s) stdlib_test.go:233: /usr/local/go/src/cmd/addr2line/main.go:29:2: could not import cmd/internal/objfile (can't find import: "cmd/internal/objfile") stdlib_test.go:233: /usr/local/go/src/cmd/asm/main.go:14:2: could not import cmd/asm/internal/arch (can't find import: "cmd/asm/internal/arch") stdlib_test.go:233: /usr/local/go/src/cmd/asm/main.go:15:2: could not import cmd/asm/internal/asm (can't find import: "cmd/asm/internal/asm") stdlib_test.go:233: /usr/local/go/src/cmd/asm/main.go:16:2: could not import cmd/asm/internal/flags (can't find import: "cmd/asm/internal/flags") stdlib_test.go:233: /usr/local/go/src/cmd/asm/main.go:17:2: could not import cmd/asm/internal/lex (can't find import: "cmd/asm/internal/lex") stdlib_test.go:233: /usr/local/go/src/cmd/asm/main.go:19:2: could not import cmd/internal/bio (can't find import: "cmd/internal/bio") stdlib_test.go:233: /usr/local/go/src/cmd/asm/main.go:20:2: could not import cmd/internal/obj (can't find import: "cmd/internal/obj") stdlib_test.go:233: /usr/local/go/src/cmd/asm/main.go:21:2: could not import cmd/internal/objabi (can't find import: "cmd/internal/objabi") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:9:2: could not import cmd/internal/obj (can't find import: "cmd/internal/obj") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:10:2: could not import cmd/internal/obj/arm (can't find import: "cmd/internal/obj/arm") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:11:2: could not import cmd/internal/obj/arm64 (can't find import: "cmd/internal/obj/arm64") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:12:2: could not import cmd/internal/obj/mips (can't find import: "cmd/internal/obj/mips") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:13:2: could not import cmd/internal/obj/ppc64 (can't find import: "cmd/internal/obj/ppc64") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:14:2: could not import cmd/internal/obj/riscv (can't find import: "cmd/internal/obj/riscv") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:15:2: could not import cmd/internal/obj/s390x (can't find import: "cmd/internal/obj/s390x") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:16:2: could not import cmd/internal/obj/wasm (can't find import: "cmd/internal/obj/wasm") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/arch/arch.go:17:2: could not import cmd/internal/obj/x86 (can't find import: "cmd/internal/obj/x86") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/asm/asm.go:13:2: could not import cmd/asm/internal/arch (can't find import: "cmd/asm/internal/arch") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/asm/asm.go:14:2: could not import cmd/asm/internal/flags (can't find import: "cmd/asm/internal/flags") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/asm/asm.go:15:2: could not import cmd/asm/internal/lex (can't find import: "cmd/asm/internal/lex") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/asm/asm.go:16:2: could not import cmd/internal/obj (can't find import: "cmd/internal/obj") stdlib_test.go:233: /usr/local/go/src/cmd/asm/internal/asm/asm.go:17:2: could not import cmd/internal/obj/x86 (can't find import: "cmd/internal/obj/x86") [...] golang.org/x/tools/go/analysis/passes/structtag (can't find import: "cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag") stdlib_test.go:233: /usr/local/go/src/cmd/vet/main.go:27:2: could not import golang.org/x/tools/go/analysis/passes/tests (can't find import: "cmd/vendor/golang.org/x/tools/go/analysis/passes/tests") stdlib_test.go:233: /usr/local/go/src/cmd/vet/main.go:28:2: could not import golang.org/x/tools/go/analysis/passes/unmarshal (can't find import: "cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal") stdlib_test.go:233: /usr/local/go/src/cmd/vet/main.go:29:2: could not import golang.org/x/tools/go/analysis/passes/unreachable (can't find import: "cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable") stdlib_test.go:233: /usr/local/go/src/cmd/vet/main.go:30:2: could not import golang.org/x/tools/go/analysis/passes/unsafeptr (can't find import: "cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr") stdlib_test.go:233: /usr/local/go/src/cmd/vet/main.go:31:2: could not import golang.org/x/tools/go/analysis/passes/unusedresult (can't find import: "cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult") FAIL FAIL go/types 8.876s FAIL ```