gotestyourself / gotestsum

'go test' runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results.
Apache License 2.0
2.03k stars 119 forks source link

Add format-icons flag for nerdfonts instead of unicode #366

Closed afbjorklund closed 11 months ago

afbjorklund commented 1 year ago

https://www.nerdfonts.com/

Icons from the VS Code glyphs:

Or from the GitHub octicons:

Screenshots with Ubuntu Mono:

gotestsum-unicode

gotestsum-nerdfonts

Other screenshots with Roboto Mono.

afbjorklund commented 1 year ago

Having shared parameter for icon formats sounds good to me

Maybe color needs a separate function and separate controls too?

gotestsum-monochrome

Currently it is hardcoded "on" and "off", for the different icons.

Probably should recognize the NO_COLOR environment variable.

EDIT: already done by github.com/fatih/color

NO_COLOR=true ./gotestsum --format-icons default

gotestsum-nocolor

afbjorklund commented 1 year ago

Funny story: when I went to school, the teacher gave me either 𝓡 (right) or ✓ (wrong).

If you got all of them correct, you were awarded with the sought for golden ⭐ sticker...

afbjorklund commented 1 year ago

Maybe "nerdfonts" is a bad name, too generic (similar to "unicode", emojis are unicode glyphs too)

For instance, one might want to use some other icon set that is also available in it (like Octicons).

image

another three icon options...

image

EDIT: One variant would be to use "dash" (‐) instead of "empty set" (∅), since it looks a lot like Ø*

* Which is a regular character in Danish, like in https://en.wikipedia.org/wiki/%C3%98resund

afbjorklund commented 1 year ago

The format from "testname", while not strictly icons, also has its merits...

image

For screen readers, or simple terminals without proper unicode support

        return icons{
            pass: color.GreenString("PASS"),
            skip: color.YellowString("SKIP"),
            fail: color.RedString("FAIL"),
        }.forAction
afbjorklund commented 1 year ago

And these icons are rather subtle, for higher resolution screens:

gotestsum-emoticons

afbjorklund commented 1 year ago

Now up to 10 different icons, if you count the emojis (hivis)

afbjorklund commented 1 year ago

Rebased and added proper help and environment variable for the format icons:

gotestsum-formaticons

afbjorklund commented 1 year ago

Side note: you can check the result of the "text" icons with a screen reader:

gotestsum --format-icons text --hide-summary all | espeak -k20

The -k20 causes it to indicate the TEST capital letters with using an increased pitch...

You can also add -x -q, if you just want to see and not hear the phoneme mnemonics


sk'Ip_
sk'Ip_ s,i:;,Emd'i: sl'aS Int'3:n@L sl'aS s'Igna#lh,and@L@dr,aIv3
p'aas_ s,i:;,Emd'i:_:_: k'aSt
p'aas_ s,i:;,Emd'i: sl'aS t'u:l sl'aS m'eItrIks_:_: k'aSt
sk'Ip_ k'0ntrIb sl'aS n'oUtI2f,aI
p'aas_ s,i:;,Emd'i: sl'aS t'u:l sl'aS sl'oUI2st_:_: k'aSt
sk'Ip_ Int'3:n@L sl'aS d'0traIt3
sk'Ip_ Int'3:n@L sl'aS t'Ekst
sk'Ip_ Int'3:n@L sl'aS l'0g
p'aas_ Int'3:n@L sl'aS 'agrI2g,eIt_:_: k'aSt
p'aas_ Int'3:n@L sl'aS dZ'u:nItksm@L_:_: k'aSt
p'aas_ Int'3:n@L sl'aS f'aIlw0tS3_:_: k'aSt
p'aas_ t'EstdZs@n_:_: k'aSt

d'Vn_ w'0nh'VndrI2d@n n'aInti; 'eIt t'Ests
t'u: sk'Ipt In z'i@roU pOInt f'o@ n'aIn t'u: z
∅  .
∅  cmd/internal/signalhandlerdriver
✓  cmd (cached)
✓  cmd/tool/matrix (cached)
∅  contrib/notify
✓  cmd/tool/slowest (cached)
∅  internal/dotwriter
∅  internal/log
∅  internal/text
✓  internal/junitxml (cached)
✓  internal/aggregate (cached)
✓  internal/filewatcher (cached)
✓  testjson (cached)

DONE 198 tests, 2 skipped in 0.460s
afbjorklund commented 1 year ago

Final tweak, added alternative.

Format icons:
    default                  the original unicode (✓, ∅, ✖)
    alternative              an alternative unicode (✓, ‐, ✗)
    hivis                    higher visibility unicode (✅, ➖, ❌)
    text                     simple text characters (PASS, SKIP, FAIL)
...