Skip to content

Commit

Permalink
Fix the colors broken by #23
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyll committed Jun 8, 2020
1 parent d29163f commit e60feff
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
)

var (
pass = color.New(color.FgGreen)
skip = color.New(color.FgYellow)
fail = color.New(color.FgHiRed)
pass = color.FgGreen
skip = color.FgYellow
fail = color.FgHiRed
)

const paletteEnv = "GOTEST_PALETTE"
Expand Down Expand Up @@ -94,17 +94,16 @@ func consume(wg *sync.WaitGroup, r io.Reader) {
}
}

var c *color.Color

func parse(line string) {
trimmed := strings.TrimSpace(line)
defer color.Unset()

var c color.Attribute
switch {
case strings.HasPrefix(trimmed, "=== RUN"):
fallthrough
case strings.HasPrefix(trimmed, "?"):
c = nil
color.Unset()

// passed
case strings.HasPrefix(trimmed, "--- PASS"):
Expand All @@ -125,6 +124,7 @@ func parse(line string) {
c = fail
}

color.Set(c)
fmt.Printf("%s\n", line)
}

Expand Down Expand Up @@ -154,10 +154,10 @@ func setPalette() {
return
}
if c, ok := colors[vals[0]]; ok {
fail = color.Set(c)
fail = c
}
if c, ok := colors[vals[1]]; ok {
pass = color.New(c)
pass = c
}
}

Expand Down

0 comments on commit e60feff

Please sign in to comment.