Skip to content

Commit

Permalink
Use --format-compact -plain to not use dotwriter
Browse files Browse the repository at this point in the history
  • Loading branch information
zalenskivolt committed Apr 25, 2023
1 parent 009e162 commit 60c5d83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 11 additions & 2 deletions testjson/compactformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"golang.org/x/term"
)

const CompactFormats = "relative, short, partial, partial-back, -dots"
const CompactFormats = "relative, short, partial, partial-back, -dots, -plain"

func CompactFormatUsage(out io.Writer, name string) {
fmt.Fprintf(out, `
Expand All @@ -26,6 +26,7 @@ Formats:
partial print newly entered path segments for each package
partial-back partial with an indication when it backs out
-dots[N] print test dots summary after the package
-plain do not rewrite lines, print each package when finished
`)
}
Expand All @@ -47,6 +48,7 @@ type pkgLine struct {

func shouldJoinPkgs(opts FormatOptions, lastPkg, pkg string) (join bool, commonPrefix string, backUp int) {
pkgNameFormat := dotFmtRe.ReplaceAllString(opts.CompactPkgNameFormat, "")
pkgNameFormat = strings.TrimSuffix(pkgNameFormat, "-plain")
switch pkgNameFormat {
case "relative":
return true, "", 0
Expand All @@ -67,6 +69,13 @@ func shouldJoinPkgs(opts FormatOptions, lastPkg, pkg string) (join bool, commonP
}

func pkgNameCompactFormat(out io.Writer, opts FormatOptions) eventFormatterFunc {
if strings.Contains(opts.CompactPkgNameFormat, "-plain") {
return pkgNameCompactFormatPlain(out, opts)
}
return pkgNameCompactFormatDotwriter(out, opts)
}

func pkgNameCompactFormatPlain(out io.Writer, opts FormatOptions) eventFormatterFunc {
buf := bufio.NewWriter(out)
pt := &PkgTracker{
opts: opts,
Expand Down Expand Up @@ -187,7 +196,7 @@ func noColorLen(s string) int {

// ---

func pkgNameCompactFormat2(out io.Writer, opts FormatOptions) eventFormatterFunc {
func pkgNameCompactFormatDotwriter(out io.Writer, opts FormatOptions) eventFormatterFunc {
pt := &PkgTracker{
opts: opts,
pkgs: map[string]*pkgLine{},
Expand Down
2 changes: 0 additions & 2 deletions testjson/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ func NewEventFormatter(out io.Writer, format string, formatOpts FormatOptions) E
return pkgNameFormat(out, formatOpts)
case "pkgname-compact":
return pkgNameCompactFormat(out, formatOpts)
case "pkgname-compact2":
return pkgNameCompactFormat2(out, formatOpts)
default:
return nil
}
Expand Down

0 comments on commit 60c5d83

Please sign in to comment.