fix(test): strip colour codes before looking for the lint skip notice (CI run 8937)
CI / Lint / Test / Vet (pull_request) Successful in 30s
CI / Build & Import (pull_request) Skipped
CI / Deploy via GitOps (pull_request) Skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 21:18:05 +02:00
co-authored by Claude Sonnet 5.5
parent 228bcc77da
commit 5baffd0189
+5 -1
View File
@@ -10,6 +10,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"regexp"
"strings" "strings"
"testing" "testing"
) )
@@ -40,10 +41,13 @@ func scratchModule(t *testing.T) string {
return dir return dir
} }
// ansi matches the colour escape sequences task prints when it thinks it has a terminal.
var ansi = regexp.MustCompile("\x1b\\[[0-9;]*m")
// hasSkipNotice reports whether the skip notice was printed as output. Task echoes the command // hasSkipNotice reports whether the skip notice was printed as output. Task echoes the command
// line first, and that line contains the same words, so a substring match would be vacuous. // line first, and that line contains the same words, so a substring match would be vacuous.
func hasSkipNotice(out string) bool { func hasSkipNotice(out string) bool {
for _, line := range strings.Split(out, "\n") { for _, line := range strings.Split(ansi.ReplaceAllString(out, ""), "\n") {
if strings.HasPrefix(line, "golangci-lint not installed") { if strings.HasPrefix(line, "golangci-lint not installed") {
return true return true
} }