diff --git a/test/lintgate/lintgate_test.go b/test/lintgate/lintgate_test.go index 279f463..78560ff 100644 --- a/test/lintgate/lintgate_test.go +++ b/test/lintgate/lintgate_test.go @@ -10,6 +10,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" "testing" ) @@ -40,10 +41,13 @@ func scratchModule(t *testing.T) string { 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 // line first, and that line contains the same words, so a substring match would be vacuous. 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") { return true }