-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from golangci/support/fix-no-results-for-gocyclo
#45: fix no results for gocyclo
- Loading branch information
Showing
6 changed files
with
193 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package commands | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/golangci/golangci-lint/pkg" | ||
"github.com/golangci/golangci-lint/pkg/astcache" | ||
"github.com/golangci/golangci-lint/pkg/config" | ||
"github.com/golangci/golangci-lint/pkg/fsutils" | ||
"github.com/golangci/golangci-lint/pkg/golinters" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestASTCacheLoading(t *testing.T) { | ||
ctx := context.Background() | ||
linters := []pkg.Linter{golinters.Errcheck{}} | ||
|
||
inputPaths := []string{"./...", "./", "./run.go", "run.go"} | ||
for _, inputPath := range inputPaths { | ||
paths, err := fsutils.GetPathsForAnalysis(ctx, []string{inputPath}, true) | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, paths.Files) | ||
|
||
prog, _, err := loadWholeAppIfNeeded(ctx, linters, &config.Run{ | ||
AnalyzeTests: true, | ||
}, paths) | ||
assert.NoError(t, err) | ||
|
||
astCacheFromProg, err := astcache.LoadFromProgram(prog) | ||
assert.NoError(t, err) | ||
|
||
astCacheFromFiles := astcache.LoadFromFiles(paths.Files) | ||
|
||
filesFromProg := astCacheFromProg.GetAllValidFiles() | ||
filesFromFiles := astCacheFromFiles.GetAllValidFiles() | ||
if len(filesFromProg) != len(filesFromFiles) { | ||
t.Logf("files: %s", paths.Files) | ||
t.Logf("from prog:") | ||
for _, f := range filesFromProg { | ||
t.Logf("%+v", *f) | ||
} | ||
t.Logf("from files:") | ||
for _, f := range filesFromFiles { | ||
t.Logf("%+v", *f) | ||
} | ||
t.Fatalf("lengths differ") | ||
} | ||
|
||
if len(filesFromProg) != len(paths.Files) { | ||
t.Fatalf("filesFromProg differ from path.Files") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters