Этот коммит содержится в:
hgouchet 2018-09-29 13:12:16 +02:00
родитель b03bcc9c55
коммит 2604810f50
7 изменённых файлов: 27 добавлений и 28 удалений

Просмотреть файл

@ -16,8 +16,8 @@ const (
red red
green green
yellow yellow
blue blue // unused
magenta magenta // unused
cyan cyan
white white
) )

Просмотреть файл

@ -16,7 +16,7 @@ type outputMode int
const ( const (
_ outputMode = iota _ outputMode = iota
discardNonColorEscSeq discardNonColorEscSeq
outputNonColorEscSeq outputNonColorEscSeq // unused
) )
// Colored creates and initializes a new ansiColorWriter // Colored creates and initializes a new ansiColorWriter

Просмотреть файл

@ -148,11 +148,13 @@ func (j *junitFormatter) Summary() {
j.current().Time = timeNowFunc().Sub(j.featStarted).String() j.current().Time = timeNowFunc().Sub(j.featStarted).String()
} }
j.suite.Time = timeNowFunc().Sub(j.started).String() j.suite.Time = timeNowFunc().Sub(j.started).String()
io.WriteString(j.out, xml.Header) _, err := io.WriteString(j.out, xml.Header)
if err != nil {
fmt.Fprintln(os.Stderr, "failed to write junit string:", err)
}
enc := xml.NewEncoder(j.out) enc := xml.NewEncoder(j.out)
enc.Indent("", s(2)) enc.Indent("", s(2))
if err := enc.Encode(j.suite); err != nil { if err = enc.Encode(j.suite); err != nil {
fmt.Fprintln(os.Stderr, "failed to write junit xml:", err) fmt.Fprintln(os.Stderr, "failed to write junit xml:", err)
} }
} }

Просмотреть файл

@ -152,19 +152,18 @@ func TestJUnitFormatterOutput(t *testing.T) {
}, },
}}, }},
} }
s.run() s.run()
s.fmt.Summary() s.fmt.Summary()
var exp bytes.Buffer var exp bytes.Buffer
io.WriteString(&exp, xml.Header) if _, err = io.WriteString(&exp, xml.Header); err != nil {
t.Fatalf("unexpected error: %v", err)
enc := xml.NewEncoder(&exp) }
enc.Indent("", " ") enc := xml.NewEncoder(&exp)
if err := enc.Encode(expected); err != nil { enc.Indent("", " ")
if err = enc.Encode(expected); err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
} }
if buf.String() != exp.String() { if buf.String() != exp.String() {
t.Fatalf("expected output does not match: %s", buf.String()) t.Fatalf("expected output does not match: %s", buf.String())
} }

Просмотреть файл

@ -178,8 +178,8 @@ func TestFailsWithUnknownFormatterOptionError(t *testing.T) {
} }
out := strings.TrimSpace(string(b)) out := strings.TrimSpace(string(b))
if strings.Index(out, `unregistered formatter name: "unknown", use one of`) == -1 { if !strings.Contains(out, `unregistered formatter name: "unknown", use one of`) {
t.Fatalf("unexpected error output: \"%s\"", out) t.Fatalf("unexpected error output: %q", out)
} }
} }

Просмотреть файл

@ -805,7 +805,7 @@ func matchesTags(filter string, tags []string) (ok bool) {
okComma = hasTag(tags, tag) || okComma okComma = hasTag(tags, tag) || okComma
} }
} }
ok = (false != okComma && ok && okComma) || false ok = ok && okComma
} }
return return
} }

Просмотреть файл

@ -7,18 +7,16 @@ import (
"github.com/DATA-DOG/godog/colors" "github.com/DATA-DOG/godog/colors"
) )
// empty struct value takes no space allocation var (
type void struct{} red = colors.Red
redb = colors.Bold(colors.Red)
var red = colors.Red green = colors.Green
var redb = colors.Bold(colors.Red) black = colors.Black
var green = colors.Green yellow = colors.Yellow
var black = colors.Black cyan = colors.Cyan
var blackb = colors.Bold(colors.Black) cyanb = colors.Bold(colors.Cyan)
var yellow = colors.Yellow whiteb = colors.Bold(colors.White)
var cyan = colors.Cyan )
var cyanb = colors.Bold(colors.Cyan)
var whiteb = colors.Bold(colors.White)
// repeats a space n times // repeats a space n times
func s(n int) string { func s(n int) string {