@@ -8,37 +8,29 @@ import (
88
99 "github.com/stretchr/testify/require"
1010
11- "github.com/golangci/golangci-lint/pkg/exitcodes"
1211 "github.com/golangci/golangci-lint/test/testshared"
1312)
1413
1514func TestFix (t * testing.T ) {
16- findSources := func (pathPatterns ... string ) []string {
17- sources , err := filepath .Glob (filepath .Join (pathPatterns ... ))
18- require .NoError (t , err )
19- require .NotEmpty (t , sources )
20- return sources
21- }
22-
2315 tmpDir := filepath .Join (testdataDir , "fix.tmp" )
24- os .RemoveAll (tmpDir ) // cleanup after previous runs
16+ _ = os .RemoveAll (tmpDir ) // cleanup previous runs
2517
2618 if os .Getenv ("GL_KEEP_TEMP_FILES" ) == "1" {
2719 t .Logf ("Temp dir for fix test: %s" , tmpDir )
2820 } else {
29- t .Cleanup (func () {
30- os .RemoveAll (tmpDir )
31- })
21+ t .Cleanup (func () { _ = os .RemoveAll (tmpDir ) })
3222 }
3323
34- fixDir := filepath .Join (testdataDir , "fix" )
35- err := exec .Command ("cp" , "-R" , fixDir , tmpDir ).Run ()
24+ sourcesDir := filepath .Join (testdataDir , "fix" )
25+
26+ err := exec .Command ("cp" , "-R" , sourcesDir , tmpDir ).Run ()
3627 require .NoError (t , err )
3728
3829 testshared .InstallGolangciLint (t )
3930
40- inputs := findSources (tmpDir , "in" , "*.go" )
41- for _ , input := range inputs {
31+ sources := findSources (t , tmpDir , "in" , "*.go" )
32+
33+ for _ , input := range sources {
4234 input := input
4335 t .Run (filepath .Base (input ), func (t * testing.T ) {
4436 t .Parallel ()
@@ -49,22 +41,19 @@ func TestFix(t *testing.T) {
4941 return
5042 }
5143
52- runResult := testshared .NewRunnerBuilder (t ).
53- WithRunContext (rc ).
54- WithTargetPath (input ).
44+ testshared .NewRunnerBuilder (t ).
5545 WithArgs (
5646 "--disable-all" ,
5747 "--print-issued-lines=false" ,
5848 "--print-linter-name=false" ,
5949 "--out-format=line-number" ,
60- "--fix" ).
50+ "--fix" ,
51+ ).
52+ WithRunContext (rc ).
53+ WithTargetPath (input ).
6154 Runner ().
62- Run ()
63-
64- // nolintlint test uses non existing linters (bob, alice)
65- if rc .ExpectedLinter != "nolintlint" {
66- runResult .ExpectExitCode (exitcodes .Success )
67- }
55+ Run ().
56+ ExpectExitCode (rc .ExitCode )
6857
6958 output , err := os .ReadFile (input )
7059 require .NoError (t , err )
0 commit comments