Skip to content

Commit

Permalink
Restore default format
Browse files Browse the repository at this point in the history
Only use github-actions format if format is set to testname. The current default
pkgname is much more compact. Maybe we could add a github-actions-pkgname format
in the future that folds the entire package.

For now it seems safe to use github-actions instead of pkgname if the GITHUB_ACTIONS
environment variable is set.  If someone really wants the output expanded by default
they can unset or overwrite that env var for the 'gotestsum' process.
  • Loading branch information
dnephin committed Aug 26, 2023
1 parent f814ba5 commit 178a95b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
go-version: '1.20'
cache: true
- run: go build .
- run: ./gotestsum
- run: ./gotestsum -f testname
8 changes: 3 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,9 @@ func setupFlags(name string) (*pflag.FlagSet, *options) {
flags.Usage = func() {
usage(os.Stdout, name, flags)
}
defaultFormat := "pkgname"
if os.Getenv("GITHUB_ACTIONS") == "true" {
defaultFormat = "github-actions"
}

flags.StringVarP(&opts.format, "format", "f",
lookEnvWithDefault("GOTESTSUM_FORMAT", defaultFormat),
lookEnvWithDefault("GOTESTSUM_FORMAT", "pkgname"),
"print format of test input")
flags.BoolVar(&opts.formatOptions.HideEmptyPackages, "format-hide-empty-pkg",
false, "do not print empty packages in compact formats")
Expand Down Expand Up @@ -143,6 +140,7 @@ Formats:
pkgname print a line for each package
pkgname-and-test-fails print a line for each package and failed test output
testname print a line for each test and package
github-actions testname format with github actions log grouping
standard-quiet standard go test format
standard-verbose standard go test -v format
Expand Down
4 changes: 4 additions & 0 deletions testjson/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"io"
"os"
"strings"

"github.com/fatih/color"
Expand Down Expand Up @@ -312,6 +313,9 @@ func NewEventFormatter(out io.Writer, format string, formatOpts FormatOptions) E
case "dots-v2":
return newDotFormatter(out, formatOpts)
case "testname", "short-verbose":
if os.Getenv("GITHUB_ACTIONS") == "true" {
return githubActionsFormat(out)
}
return testNameFormat(out)
case "pkgname", "short":
return pkgNameFormat(out, formatOpts)
Expand Down

0 comments on commit 178a95b

Please sign in to comment.