Skip to content

Commit

Permalink
Add environment variable for setting format icons
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Aug 30, 2023
1 parent 85de782 commit b543676
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ is used to print the test names, and possibly test output, as the tests run. Mos
outputs use color to highlight pass, fail, or skip.

The `--format-icons` flag changes the icons used by `pkgname` and `testdox` formats.
You can set the `GOTESTSUM_FORMAT_ICONS` environment variable, instead of the flag.
The nerdfonts icons requires a font from [Nerd Fonts](https://www.nerdfonts.com/).

Commonly used formats (see `--help` for a full list):
Expand Down
1 change: 1 addition & 0 deletions cmd/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestPostRunHook(t *testing.T) {
}

env.Patch(t, "GOTESTSUM_FORMAT", "short")
env.Patch(t, "GOTESTSUM_FORMAT_ICONS", "default")

exec := newExecFromTestData(t)
err = postRunHook(opts, exec)
Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func setupFlags(name string) (*pflag.FlagSet, *options) {
flags.BoolVar(&opts.formatOptions.UseHiVisibilityIcons, "format-hivis",
false, "use high visibility characters in some formats")
_ = flags.MarkHidden("format-hivis")
flags.StringVar(&opts.formatOptions.Icons, "format-icons", "",
flags.StringVar(&opts.formatOptions.Icons, "format-icons",
lookEnvWithDefault("GOTESTSUM_FORMAT_ICONS", ""),
"use different icons, see help for options")
flags.BoolVar(&opts.rawCommand, "raw-command", false,
"don't prepend 'go test -json' to the 'go test' command")
Expand Down
1 change: 1 addition & 0 deletions cmd/testdata/post-run-hook-expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
GOTESTSUM_ELAPSED=0.000s
GOTESTSUM_FORMAT=short
GOTESTSUM_FORMAT_ICONS=default
GOTESTSUM_JSONFILE=events.json
GOTESTSUM_JSONFILE_TIMING_EVENTS=timing.json
GOTESTSUM_JUNITFILE=junit.xml
Expand Down

0 comments on commit b543676

Please sign in to comment.