gotestsum icon indicating copy to clipboard operation
gotestsum copied to clipboard

suppress printing package names with no tests

Open renkam opened this issue 4 years ago • 4 comments

Is there a way to avoid printing packages when only skipped tests or no tests at all are in package?

renkam avatar Jan 11 '22 15:01 renkam

Currently there is no way to hide output for empty packages. Are you looking for option for the pkgname format , or one of the others?

dnephin avatar Jan 15 '22 16:01 dnephin

Probably pkgname. I am using -f dots-v2 and in my project there is a lot of packages that have no tests. Printing those packages names gives me no value and pollutes the output.

renkam avatar Jan 18 '22 20:01 renkam

I used this:

gotestsum -f pkgname-and-test-fails | grep -v ∅ 
# or
gotestsum -f testname | grep -v EMPTY

but the color is gone

kokizzu avatar Feb 25 '22 11:02 kokizzu

As a workaround to the missing color, you can use this:

gotestsum --no-color=false

I think it would also be ok to add an option to hide empty packages, but I'm not sure yet how that should work.

dnephin avatar Feb 28 '22 17:02 dnephin

I made a PR for this, adding a --skip-empty option that only works if you are testing ./..., since that's the probably the only situation where you would want to transparently skip missing tests, and would be the situation where you would encounter them the most. If you're being explicit about testing targets, then you should see output for everything you specify, missing or not.

This was a bit tricky as I had to track missing stuff in two places to intercept it both before it is tracked for summary and before it's streamed to the formatters. In both cases I use the initial output starting with a ? to mark the package as empty from that point forward, after which all entries from that package are dropped. There might be a better method, but this seemed the most straightforward.

Wasn't sure where to add tests beyond arg checking, since AFAICT all of the testing harnesses that do golden file comparison on output are geared strictly to formatters, which my solution bypasses to avoid adding skipping behavior to all formatters.

flowchartsman avatar Nov 03 '22 14:11 flowchartsman

Done in #288 and #283

dnephin avatar Dec 17 '22 18:12 dnephin