Skip to content

Commit 8a0f8da

Browse files
committed
dev: fix: linter tests
1 parent f48530e commit 8a0f8da

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

test/linters_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func testSourcesFromDir(t *testing.T, dir string) {
6161
t.Run(filepath.Base(source), func(subTest *testing.T) {
6262
subTest.Parallel()
6363

64-
rel, err := filepath.Rel(dir, sources[0])
64+
rel, err := filepath.Rel(dir, source)
6565
require.NoError(t, err)
6666

6767
testOneSource(subTest, log, binPath, rel)

test/output_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,10 @@ func TestOutput_Multiple(t *testing.T) {
9696
ExpectHasIssue("testdata/misspell.go:6:38: `occured` is a misspelling of `occurred`").
9797
ExpectOutputContains(expectedJSONOutput)
9898
}
99+
100+
func TestName(t *testing.T) {
101+
// testdata/configs/cyclop.yml /home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata
102+
103+
fmt.Println(filepath.Base("testdata/configs/cyclop.yml"))
104+
fmt.Println(filepath.Base("/home/ldez/sources/go/src/github.com/golangci/golangci-lint/test/testdata"))
105+
}

test/testshared/runner.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,17 @@ func (b *RunnerBuilder) WithRunContext(rc *RunContext) *RunnerBuilder {
104104
return b
105105
}
106106

107-
return b.WithConfigFile(rc.ConfigPath).WithArgs(rc.Args...)
107+
dir, err := os.Getwd()
108+
require.NoError(b.tb, err)
109+
110+
configPath := filepath.FromSlash(rc.ConfigPath)
111+
112+
base := filepath.Base(dir)
113+
if strings.HasPrefix(configPath, base) {
114+
configPath = strings.TrimPrefix(configPath, base+string(filepath.Separator))
115+
}
116+
117+
return b.WithConfigFile(configPath).WithArgs(rc.Args...)
108118
}
109119

110120
func (b *RunnerBuilder) WithDirectives(sourcePath string) *RunnerBuilder {

0 commit comments

Comments
 (0)