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.06k stars 122 forks source link

Order of packages when using pkgname #392

Closed mitar closed 6 months ago

mitar commented 6 months ago

Currently it looks like it is arbitrary (probably the order returned by go test), but I would prefer if there was an option to have them sorted so that sub-packages are listed first and the last package is the main one, the one with . as name. So maybe list them in alphabetical order with sub-packages first. Then it is easier to remember the position in the package and look there. Currently the order changes between runs and I am always then scanning and searching for the package I care about at the moment.

dnephin commented 6 months ago

Currently gotestsum doesn't order the packages at all. You are correct that output is printed as go test emits the "package pass/fail" event. I believe the reason that the order changes is because go test will run packages in parallel, and that can change the order of when they complete.

If you run

gotestsum -fpkgname -- -p 1 ./...

That tells go test to only run a single package at a time, and I think that may give you predictable ordering.

For gotestsum to order things it would have to buffer all of the output, which doesn't seem worth it.

mitar commented 6 months ago

My main motivation for this was because I thought that getting coverage for top-level (.) package is the same as coverage across all packages (when using -coverpkg ./.... And having it be last would then work with GitLab coverage extraction. But top-level coverage is not really total coverage. I made https://github.com/golang/go/issues/66506 to request total coverage output. Closing this.