Skip to content

Commit db581b1

Browse files
Use progressWriter.FormatAction
1 parent fb28a16 commit db581b1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

internal/app/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ func Run(option Options) (int, error) {
6868
defer option.FollowOutputWriter.Close()
6969
}
7070

71+
progressWriter := newConsoleWriter(option.Output, option.Format, option.DisableColor)
7172
summary, err := parse.Process(
7273
reader,
7374
parse.WithFollowOutput(option.FollowOutput),
7475
parse.WithFollowVersboseOutput(option.FollowOutputVerbose),
7576
parse.WithWriter(option.FollowOutputWriter),
7677
parse.WithProgress(option.Progress),
77-
parse.WithProgressOutput(option.ProgressOutput),
78+
parse.WithProgressOutput(progressWriter),
7879
)
7980
if err != nil {
8081
return 1, err

parse/process.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func Process(r io.Reader, optionsFunc ...OptionsFunc) (*GoTestSummary, error) {
142142

143143
// printProgress prints a single summary line for each PASS or FAIL package.
144144
// This is useful for long-running test suites.
145-
func printProgress(w io.Writer, e *Event, summary map[string]*Package) {
145+
func printProgress(w progressWriter, e *Event, summary map[string]*Package) {
146146
if !e.LastLine() {
147147
return
148148
}
@@ -174,7 +174,7 @@ func printProgress(w io.Writer, e *Event, summary map[string]*Package) {
174174
//
175175
// We modify this output slightly so it's more consistent and easier to parse.
176176
fmt.Fprintf(w, "[%s]\t%10s\t%s%s\n",
177-
strings.ToUpper(action.String()),
177+
w.FormatAction(action),
178178
strconv.FormatFloat(e.Elapsed, 'f', 2, 64)+"s",
179179
e.Package,
180180
suffix,

parse/process_options.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ import (
44
"io"
55
)
66

7+
type progressWriter interface {
8+
io.Writer
9+
FormatAction(Action) string
10+
}
11+
712
type options struct {
813
w io.Writer
914
follow bool
1015
followVerbose bool
1116
debug bool
1217

1318
progress bool
14-
progressOutput io.Writer
19+
progressOutput progressWriter
1520
}
1621

1722
type OptionsFunc func(o *options)
@@ -36,6 +41,6 @@ func WithProgress(b bool) OptionsFunc {
3641
return func(o *options) { o.progress = b }
3742
}
3843

39-
func WithProgressOutput(w io.Writer) OptionsFunc {
44+
func WithProgressOutput(w progressWriter) OptionsFunc {
4045
return func(o *options) { o.progressOutput = w }
4146
}

0 commit comments

Comments
 (0)