[tools] gopls/internal/cache: detect testmain without GOCACHE

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jun 30, 2026, 1:09:53 PM (23 hours ago) Jun 30
to Jake Bailey, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Junyang Shao, Alex Putman, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
gopls/internal/cache: detect testmain without GOCACHE

If someone has a GOCACHEPROG, that GOCACHEPROG may place files outside
of GOCACHE (since reasonably, an outside tool should not put stuff in
GOCACHE; that's Go's domain).

But, isTestMain detected generated testmain files by looking for them
inside GOCACHE, leading to odd errors like:

could not import testing/internal/testdeps (invalid use of internal package "testing/internal/testdeps")

Rather than checking GOCACHE, check and see if the loaded files are just
outside pkg.Dir. In my testing, I was seeing:

pkg.Dir="/home/jake/work/TypeScript-go/internal/parser"
GoFiles=["/home/jake/.cache/gocachez/v1/live/run-1630688891/0da230d43268bd7a7351aefd6900d761eed9c58cd4791093b331b16b6a3bce12-2791091722"]

Which I think is enough of a signal to also be reliable.
Change-Id: I563c10d4ef6dccbfe1cd0ffd5bbd49092b03adfc
Reviewed-by: Junyang Shao <shaoj...@google.com>
Auto-Submit: Alan Donovan <adon...@google.com>
Reviewed-by: Alan Donovan <adon...@google.com>
Files:
  • M gopls/internal/cache/load.go
Change size: S
Delta: 1 file changed, 16 insertions(+), 6 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I563c10d4ef6dccbfe1cd0ffd5bbd49092b03adfc
Gerrit-Change-Number: 795221
Gerrit-PatchSet: 3
Gerrit-Owner: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alex Putman <apu...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Jake Bailey <jacob.b...@gmail.com>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages