fix(test): strip colour codes before looking for the lint skip notice (CI run 8937)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user