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

x/tools/go/analysis/analysistest: analysistest.Run failing with modules #46041

Open
pawelmitka opened this issue May 7, 2021 · 5 comments
Open

x/tools/go/analysis/analysistest: analysistest.Run failing with modules #46041

pawelmitka opened this issue May 7, 2021 · 5 comments

Comments

@pawelmitka
Copy link

@pawelmitka pawelmitka commented May 7, 2021

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

go version go1.15.7 darwin/amd64
analysistest v0.1.0

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env

What did you do?

I have built a clean architecture go/analysis linter which works pretty well. However, when I was trying to run analysistest on complex test cases with lots of imports it was failing.

analysistest.Run(t, analysistest.TestData(), cleanarch.Analyzer, c.Pattern)

What did you expect to see?

analysistest working does not fail with modules used in test data files

What did you see instead?

valid-simple/pkg/questions/adapter/http_adapter.go:4:2: cannot find package "github.com/$ORGNAME/$REPO/cleanarch/testdata/valid-simple/pkg/questions" in any of:
/usr/local/Cellar/go/1.15.7_1/libexec/src/github.com/$ORGNAME/$REPO/cleanarch/testdata/valid-simple/pkg/questions (from $GOROOT)
/Users/$USER/IdeaProjects/$PRJ/cleanarch/testdata/src/github.com/$ORGNAME/$REPO/cleanarch/testdata/valid-simple/pkg/questions (from $GOPATH)

I determine the root cause is: "GO111MODULE=off", "GOPROXY=off" introduced in change: golang/tools@211dcd1

What puzzled me is that analysis itself worked perfectly, however, I determined modules are not disabled in the main path: https://github.com/golang/tools/blob/fe37c9e135b934191089b245ac29325091462508/go/analysis/internal/checker/checker.go#L152

When I reverted change locally it worked like a charm for me. Let me know if I can just make a PR to resolve this issue once and for all.

@timothy-king
Copy link
Contributor

@timothy-king timothy-king commented May 7, 2021

golang/tools@211dcd1 was part of a series of changes to address #27858

/cc @bcmills who was involved in #27858.

Loading

@timothy-king timothy-king changed the title analysistest does not work with modules go/analysis/analysistest: analysistest.Run failing with modules May 7, 2021
@bcmills
Copy link
Member

@bcmills bcmills commented May 7, 2021

Let me know if I can just make a PR to resolve this issue once and for all.

If you want to send a PR, if it's simple enough we can at least run it through the TryBots and see what sticks!

(CC @matloob @jayconrod @ianthehat)

Loading

@bcmills bcmills added this to the Unreleased milestone May 7, 2021
@bcmills bcmills changed the title go/analysis/analysistest: analysistest.Run failing with modules x/tools/go/analysis/analysistest: analysistest.Run failing with modules May 7, 2021
@gopherbot gopherbot added the Tools label May 7, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented May 11, 2021

Change https://golang.org/cl/318709 mentions this issue: fix: using modules in analysistest

Loading

@pawelmitka
Copy link
Author

@pawelmitka pawelmitka commented May 17, 2021

Let me know if I can just make a PR to resolve this issue once and for all.

If you want to send a PR, if it's simple enough we can at least run it through the TryBots and see what sticks!

(CC @matloob @jayconrod @ianthehat)

Looks like all bots are happy! 😄

Loading

@pawelmitka
Copy link
Author

@pawelmitka pawelmitka commented Sep 24, 2021

@bcmills Could you answer a question in https://golang.org/cl/318709? I would love to complete and close this change.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants