style: add colors to test run output
This commit is contained in:
@@ -88,7 +88,7 @@ func runTests(path string, tio testIO) error {
|
|||||||
|
|
||||||
summary := testSummary{total: len(scenarios)}
|
summary := testSummary{total: len(scenarios)}
|
||||||
for _, scenario := range scenarios {
|
for _, scenario := range scenarios {
|
||||||
output.Fprintf(tio.out, "RUN %s\n", scenario.relPath)
|
output.Fprintf(tio.out, "%s %s\n", output.LabelInfo("RUN"), scenario.relPath)
|
||||||
|
|
||||||
if err := replayScenario(scenario, shellPath, tio, cfg.Sandbox); err != nil {
|
if err := replayScenario(scenario, shellPath, tio, cfg.Sandbox); err != nil {
|
||||||
summary.failed++
|
summary.failed++
|
||||||
|
|||||||
@@ -9,25 +9,43 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
palette = struct {
|
palette = struct {
|
||||||
miroPrefixGreen uint32
|
miroGreen uint32
|
||||||
miroChevronTeal uint32
|
chevronTeal uint32
|
||||||
|
info uint32
|
||||||
|
pass uint32
|
||||||
|
fail uint32
|
||||||
}{
|
}{
|
||||||
miroPrefixGreen: 0x70E000,
|
miroGreen: 0x70E000,
|
||||||
miroChevronTeal: 0x1DD3B0,
|
chevronTeal: 0x1DD3B0,
|
||||||
|
info: 0xf5f2e1,
|
||||||
|
pass: 0x7bf1a8,
|
||||||
|
fail: 0xff8fa3,
|
||||||
}
|
}
|
||||||
|
|
||||||
chevron = NewStyle().FG(palette.miroChevronTeal).Bold().Italic().Apply("›")
|
chevron = NewStyle().FG(palette.chevronTeal).Bold().Italic().Apply("›")
|
||||||
prefix = NewStyle().FG(palette.miroPrefixGreen).Bold().Italic().Apply("miro") + " " + chevron + " "
|
prefix = NewStyle().FG(palette.miroGreen).Bold().Italic().Apply("miro") + " " + chevron + " "
|
||||||
)
|
)
|
||||||
|
|
||||||
func Prefix() string {
|
func label(text string, color uint32) string {
|
||||||
return prefix
|
return NewStyle().FG(color).Apply(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LabelPass(text string) string {
|
||||||
|
return label(text, palette.pass)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LabelFail(text string) string {
|
||||||
|
return label(text, palette.fail)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LabelInfo(text string) string {
|
||||||
|
return label(text, palette.info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Format(msg string) string {
|
func Format(msg string) string {
|
||||||
body := strings.TrimRight(msg, "\n")
|
body := strings.TrimRight(msg, "\n")
|
||||||
suffix := msg[len(body):]
|
suffix := msg[len(body):]
|
||||||
return Prefix() + body + suffix
|
return prefix + body + suffix
|
||||||
}
|
}
|
||||||
|
|
||||||
func Println(msg string) {
|
func Println(msg string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user