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: adding a test file to test-data package breaks RunWithSuggestedFixes #40574

Closed
benjaminjkraft opened this issue Aug 4, 2020 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@benjaminjkraft
Copy link

Suppose you run analysistest.Run on a package with a test file (say to test test-specific behavior of the analyzer). What apparently happens is that analysistest calls the analyzer once on the package without its tests, and once on the package with its tests. This is not a big deal; you get some duplicate error messages.

But now suppose you instead run analysistest.RunWithSuggestedFixes. In this case, analysistest ends up combining the fixes from both runs. This means you get all your fixes applied twice, which surely doesn't match your .golden file! it's a very confusing error.

A workaround is to change the test file to mypackage_test, such that the two runs will be entirely disjoint.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Aug 4, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 4, 2020
@gopherbot
Copy link

Change https://golang.org/cl/246737 mentions this issue: Fix issue in RunWithSuggestedFixes on a package with tests

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 4, 2020
@toothrot
Copy link
Contributor

toothrot commented Aug 4, 2020

/cc @matloob

benjaminjkraft added a commit to benjaminjkraft/tools that referenced this issue Aug 7, 2020
…kage with tests

The issue is described further in golang/go#40574.  The fix is simply to do the
suggested-fixes checking on each result separately.  We still get
duplicate messages, which is arguably the correct behavior but certainly
not so bad, and we no longer get a bunch of spurious errors.

Fixes golang/go#40574.
benjaminjkraft added a commit to benjaminjkraft/tools that referenced this issue Aug 7, 2020
…kage with tests

The issue is described further in golang/go#40574.  The fix is simply to do the
suggested-fixes checking on each result separately.  We still get
duplicate messages, which is arguably the correct behavior but certainly
not so bad, and we no longer get a bunch of spurious errors.

Fixes golang/go#40574.
benjaminjkraft added a commit to benjaminjkraft/tools that referenced this issue Aug 11, 2020
…kage with tests

The issue is described further in golang/go#40574.  The fix is simply to do the
suggested-fixes checking on each result separately.  We still get
duplicate messages, which is arguably the correct behavior but certainly
not so bad, and we no longer get a bunch of spurious errors.

Fixes golang/go#40574.
@golang golang locked and limited conversation to collaborators Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
3 participants