Skip to content

Commit

Permalink
dev: fix linter tests (#3128)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Aug 23, 2022
1 parent f48530e commit 77962e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/linters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func testSourcesFromDir(t *testing.T, dir string) {
t.Run(filepath.Base(source), func(subTest *testing.T) {
subTest.Parallel()

rel, err := filepath.Rel(dir, sources[0])
rel, err := filepath.Rel(dir, source)
require.NoError(t, err)

testOneSource(subTest, log, binPath, rel)
Expand Down
12 changes: 11 additions & 1 deletion test/testshared/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,17 @@ func (b *RunnerBuilder) WithRunContext(rc *RunContext) *RunnerBuilder {
return b
}

return b.WithConfigFile(rc.ConfigPath).WithArgs(rc.Args...)
dir, err := os.Getwd()
require.NoError(b.tb, err)

configPath := filepath.FromSlash(rc.ConfigPath)

base := filepath.Base(dir)
if strings.HasPrefix(configPath, base) {
configPath = strings.TrimPrefix(configPath, base+string(filepath.Separator))
}

return b.WithConfigFile(configPath).WithArgs(rc.Args...)
}

func (b *RunnerBuilder) WithDirectives(sourcePath string) *RunnerBuilder {
Expand Down

0 comments on commit 77962e9

Please sign in to comment.