-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add a multi package line format #326
base: main
Are you sure you want to change the base?
Conversation
c78a9f4
to
76d4d7b
Compare
Thank you for your interest in contributing new gotestsum formats! Looking at the example output, the two changes from the existing
Does that sound right? What's the motivation for the grouping of packages? It might be difficult to predict how to group packages, as many projects use very different package layouts. |
Thanks! Yes. I added versions with and without -time. Maybe a separate command line option would be better to control things like this? Same with -and-test-fails for both this formatter and pkgname.
It uses a super simple heuristic for this: as long as the next package is another subpackage on the same level, it will combine them (with one additional small special case). I think this might work fairly well for many projects. As soon as there are multiple sub packages on the same level it should pick up many of them. It should always be obvious which package the shortened names refer to, but for clarity it line breaks and outputs the full package name on failure. My motivation: For the current project I'm working on, this changes the output from some 65+ lines that I have to scroll through, to just one short overview of 15-20 lines. It struggles a bit when there are many deeply nested packages. |
Updated to allow backing up one step with |
Only use …/ on a new line when the package level at the end of a line matches the start of the line. (Otherwise, start the new line with a full package path.)
I think this is a cool idea! Instead of Maybe this new format could be called something like I like your idea of using a Do we need both the time at the start of the line and after the package name? Keeping it only after the package name seems like it works well. |
Hide the pkgname-and-test-fails format in usage()
Thanks!
At first I read this as just showing the last part of the package name, and this gives a spectacularly short output! Failures still get printed with the full name, so I actually think it might be a useful option. But then I realized you meant printing the full (relative) package paths. This adds quite a bit to the output. For influxdb, many lines fit only two packages for example. But I agree it would be the most obvious format to use by default. I would love to experiment a bit more around this. I'll add it as a hidden option. I'll also try printing only sibling packages but without any extra line breaks, and just skip all ↶ and .../:s in that case.
Updated.
Updated, pkgname-and-test-fails still works but is hidden.
I wanted this to see the actual wall-clock time of the messages, from exec.Elapsed(). I updated to use a --wall-time flag, and added support in pkgname and testname as well. |
Use exec.Elapsed() to get the elapsed real time. "Elapsed real time, real time, wall-clock time, wall time, or walltime is the actual time taken from the start of a computer program to the end." (https://en.wikipedia.org/wiki/Elapsed_real_time)
Print packages as relative, short, partial (newly entered paths), or partial with back indication.
Added --format-compact with the options I updated the examples at the top. I think controlling the format might be useful for projects of different sizes and package layouts?
I wanted this one to interactively see the time progress, since the test times only give total partial times for lots of things that are running in parallel. Should this be --format-wall-time to be listed with other format options? Do you think it's useful?
I think both of the two versions might be useful. The dotwriter one (pkgname-compact2) for terminal usage, where it is ok to rewrite lines. And the plain one (pkgname-compact), for CI usage for example. Maybe this should also be controlled by some option? |
Add -dots[N] to --format-compact to add dots summary
I updated to control this by just adding Also added ∅ . ✓ cmd (10.602s)···[62] ✓ cmd/tool/matrix (406ms)···[10] ✓ cmd/tool/slowest (486ms)·· ∅ contrib/notify |
b74104a
to
da0ce7d
Compare
return short package path directly
Any news on this PR please? Is it ready to review? Thank you! |
Add a couple of formatters that outputs multiple packages per line.
Example output:
With
-dots[N]
, output a short dots summary for each package.Failures always start a new line, with the full package name:
go-coap(add-error) % gotestsum --format pkgname-compact --format-with-fails --format-hide-empty-pkg \ --format-compact dots7 -- -short -count 1 ./... === RUN TestMessageSetPath message_test.go:17: foo --- FAIL: TestMessageSetPath (0.00s) ✓ dtls (5.623s)·······[25] ✓ examples/dtls/pki (382ms)· ✓ message (315ms)·······[31] ✓ message/codes (247ms)····· ✓ message/noresponse (241ms)······ ✖ message/pool (240ms)✖·[24] ✓ message/status (233ms)· ✓ mux (221ms)········· ✓ net (2.266s)·······[17] ✓ net/blockwise (249ms)·······[45] ✓ net/client/limitParallelRequests (245ms)·······[12] ✓ net/observation (325ms)········· ✓ pkg/cache (233ms)······ ✓ pkg/fn (232ms)· ✓ pkg/sync (236ms)········· ✓ tcp (6.062s)·······[31] ✓ tcp/coder (326ms)·· ✓ udp (8.036s)·······[30] ✓ udp/client (1.983s)·······[44] ✓ udp/coder (311ms)·· 311 tests, 1 failure in 10.818s
A bigger example, with
--format-compact short
orpartial-back
, compared torelative
(default):