Skip to content

Commit

Permalink
Renamed variables to reflect test results (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbn committed Jun 7, 2020
1 parent 3d36ebc commit 29d015f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
)

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

const paletteEnv = "GOTEST_PALETTE"
Expand Down Expand Up @@ -80,23 +80,28 @@ func parse(line string) {
defer color.Unset()

switch {
// success
case strings.HasPrefix(trimmed, "=== RUN"):
fallthrough
case strings.HasPrefix(trimmed, "?"):
c = nil

// passed
case strings.HasPrefix(trimmed, "--- PASS"):
fallthrough
case strings.HasPrefix(trimmed, "ok"):
fallthrough
case strings.HasPrefix(trimmed, "PASS"):
color.Set(success)
c = pass

// skipped
case strings.HasPrefix(trimmed, "--- SKIP"):
color.Set(skipped)
c = skip

// failure
// failed
case strings.HasPrefix(trimmed, "--- FAIL"):
fallthrough
case strings.HasPrefix(trimmed, "FAIL"):
color.Set(fail)
c = fail
}

fmt.Printf("%s\n", line)
Expand Down Expand Up @@ -131,7 +136,7 @@ func setPalette() {
fail = c
}
if c, ok := colors[vals[1]]; ok {
success = c
pass = color.New(c)
}
}

Expand Down

0 comments on commit 29d015f

Please sign in to comment.