Skip to content

Commit

Permalink
analysis/lint/testutil: don't run tests for too new versions of Go
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikh committed Jun 3, 2024
1 parent ac76929 commit dbad790
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions analysis/lint/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testutil

import (
"crypto/sha256"
"go/build"
"go/version"
"io"
"os"
Expand Down Expand Up @@ -68,9 +69,17 @@ func Run(t *testing.T, a *lint.Analyzer) {
}
c.SetSalt(salt)

tags := build.Default.ReleaseTags
maxVersion := tags[len(tags)-1]
for _, dir := range dirs {
vers := filepath.Base(dir)
t.Run(vers, func(t *testing.T) {
if !version.IsValid(vers) {
t.Fatalf("%q is not a valid Go version", dir)
}
if version.Compare(vers, maxVersion) == 1 {
t.Skipf("%s is newer than our Go version (%s), skipping", vers, maxVersion)
}
r, err := runner.New(config.Config{}, c)
if err != nil {
t.Fatal(err)
Expand All @@ -81,9 +90,6 @@ func Run(t *testing.T, a *lint.Analyzer) {
if err != nil {
t.Fatal(err)
}
if !version.IsValid(vers) {
t.Fatalf("%q is not a valid Go version", dir)
}
cfg := &packages.Config{
Dir: dir,
Tests: true,
Expand Down

0 comments on commit dbad790

Please sign in to comment.