Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: test / tool cover: colours alone can be difficult to use for coverage, add additional indicators #27553

Closed
soumya92 opened this issue Sep 7, 2018 · 9 comments

Comments

Projects
None yet
7 participants
@soumya92
Copy link

commented Sep 7, 2018

What version of Go are you using (go version)?

go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/soumya/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/soumya/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build682315615=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go test -covermode=atomic -coverprofile=/tmp/coverage.out -race; and go tool cover -html=/tmp/coverage.out

What did you expect to see?

Easily distinguishable colours for covered, uncovered, and low coverage lines.

What did you see instead?

Red/green/grey, which are very hard to distinguish for quite a few people.

Possible solutions:

  • Provide the ability to specify the colours
  • Add additional indicators for coverage, maybe on the gutter or on the right side.
  • Add a few preset colour schemes (and ideally persist them somehow)
@agnivade

This comment has been minimized.

Copy link
Member

commented Sep 7, 2018

@dsymonds

This comment has been minimized.

Copy link
Member

commented Sep 7, 2018

Interesting. @robpike picked the colours specifically because they were distinguishable by people with the most common forms of colour blindness. They aren't plain red/green. Do you have a specific form of colour blindness?

Note that the HTML output has CSS classes for the elements, so you can completely customise the chosen colours with a user stylesheet.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Sep 7, 2018

I am surprised because the colors were specifically chosen by me because I am red-green colorblind. We mixed a lot of blue into the green and were careful to adjust the saturations.

@bcmills

This comment has been minimized.

Copy link
Member

commented Sep 7, 2018

@katiehockman

This comment has been minimized.

Copy link
Contributor

commented Sep 7, 2018

From an accessibility perspective, it's generally better to not rely on color as the sole means of representing something. In this case, the hue of the green conveys how much test coverage exists for a line of code, and that's difficult to interpret in general (I personally found it a bit challenging). Even if this will work for people with a specific type of colorblindness, it is important to consider users who use modes like high contrast or grayscale. Many screen reader users will not be able to rely on color at all, so having some other option to convey the information can be helpful.
One option: there could be a "coverage percentage" number that appears at the start of each line of code, which can be toggled on/off if users want it? I could see that extra granularity of information being useful in general.

Side note: great that usability for colorblind users was considered in this design!

@soumya92

This comment has been minimized.

Copy link
Author

commented Sep 7, 2018

Ah, now that it's bright again, I see that the red/green are indeed easier to distinguish. So partly this was just because it was late and my screen was very dim.

I still think that colour intensity alone is not very usable as a form of coverage indication (especially in light of the screen reader concern, but also in general I find it hard to use even now with a brighter screen).

As for user stylesheets, that's a good idea but it appears that Chrome only supports user stylesheets via an extension that by design requires very invasive permissions, so maybe a way to just add arbitrary content to generated coverage reports would still be useful.

Thanks for taking a look!

@soumya92 soumya92 changed the title cmd/go: test / tool cover: colours are not accessible with red-green colour blindness cmd/go: test / tool cover: colours alone can be difficult to use for coverage, add additional indicators Sep 7, 2018

@soumya92

This comment has been minimized.

Copy link
Author

commented Sep 7, 2018

Heh, this is embarrassing. Apparently I had a blue-light filter running 😳.
So the colour choice itself seems perfectly fine.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Sep 7, 2018

Thanks for following up.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Sep 8, 2018

Happy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.