File tree 6 files changed +26
-23
lines changed
6 files changed +26
-23
lines changed Original file line number Diff line number Diff line change 9
9
"github.com/stretchr/testify/require"
10
10
"gopkg.in/yaml.v3"
11
11
12
+ "github.com/golangci/golangci-lint/pkg/exitcodes"
12
13
"github.com/golangci/golangci-lint/test/testshared"
13
14
)
14
15
@@ -52,7 +53,19 @@ func TestFix(t *testing.T) {
52
53
cfg , err := yaml .Marshal (rc .config )
53
54
require .NoError (t , err )
54
55
55
- testshared .NewLintRunner (t ).RunWithYamlConfig (string (cfg ), args ... )
56
+ var runResult * testshared.RunResult
57
+ if rc .configPath != "" {
58
+ args = append (args , "-c" , rc .configPath )
59
+ runResult = testshared .NewLintRunner (t ).RunCommand ("run" , args ... )
60
+ } else {
61
+ runResult = testshared .NewLintRunner (t ).RunWithYamlConfig (string (cfg ), args ... )
62
+ }
63
+
64
+ // nolintlint test uses non existing linters (bob, alice)
65
+ if rc .expectedLinter != "nolintlint" {
66
+ runResult .ExpectExitCode (exitcodes .Success )
67
+ }
68
+
56
69
output , err := os .ReadFile (input )
57
70
require .NoError (t , err )
58
71
Original file line number Diff line number Diff line change
1
+ linters-settings :
2
+ gocritic :
3
+ enabled-checks :
4
+ - ruleguard
5
+ settings :
6
+ ruleguard :
7
+ rules : ' ruleguard/rangeExprCopy.go,ruleguard/strings_simplify.go'
8
+
Original file line number Diff line number Diff line change 1
- //args: -Egocritic
2
- //config: linters-settings.gocritic.enabled-checks=ruleguard
3
- //config: linters-settings.gocritic.settings.ruleguard.rules=ruleguard/rangeExprCopy.go,ruleguard/strings_simplify.go
1
+ // args: -Egocritic
2
+ // config_path: testdata/configs/gocritic-fix.yml
4
3
package p
5
4
6
5
import (
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- //args: -Egocritic
2
- //config: linters-settings.gocritic.enabled-checks=ruleguard
3
- //config: linters-settings.gocritic.settings.ruleguard.rules=ruleguard/rangeExprCopy.go,ruleguard/strings_simplify.go
1
+ // args: -Egocritic
2
+ // config_path: testdata/configs/gocritic-fix.yml
4
3
package p
5
4
6
5
import (
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments