Navigation Menu

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: go test -json has inconsistent Time precision #44588

Open
rittneje opened this issue Feb 24, 2021 · 1 comment
Open

cmd/go: go test -json has inconsistent Time precision #44588

rittneje opened this issue Feb 24, 2021 · 1 comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rittneje
Copy link

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

$ go version
go version go1.14.13 darwin/amd64

Does this issue reproduce with the latest release?

Yes (go1.16)

What did you do?

Ran go test -json on a package, and attempted to sort the resulting JSON via jq using the Package and Time fields.

What did you expect to see?

I expected jq to sort the results correctly.

What did you see instead?

I noticed that the decimal precision of the Time field is inconsistent. My guess is that it is chopping off trailing zeros. However, this means that the resulting timestamps cannot be sorted properly. For example, we might get the following two entries:

{"Time":"2021-02-24T14:14:25.8589Z","Action":"output","Package":"my-package","Test":"TestFoo","Output":"=== RUN TestFoo\n"}
{"Time":"2021-02-24T14:14:25.8589131Z","Action":"output","Package":"my-package","Test":"TestFoo","Output":" --- PASS: TestFoo (0.00s)\n"}

Since 'Z' > '1', this causes the "PASS" line to get sorted before the "RUN" line. This is especially a problem when dealing with older (< 1.6) versions of jq that do not perform a stable sort.

@seankhliao seankhliao added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 24, 2021
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
@ChandanChainani
Copy link

ChandanChainani commented Mar 14, 2023

@rittneje please can you check with go version 1.19 and 1.20, if still fails please share steps and cmd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants