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.
What version of Go are you using (
go version
)?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 thePackage
andTime
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: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.