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

testing: inconsistent formatting of Test() vs. Example() timing #8175

Closed
gopherbot opened this issue Jun 9, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@gopherbot
Copy link

commented Jun 9, 2014

by jsimsa@google.com:

What does 'go version' print?
go version go1.2.2 darwin/amd64

What steps reproduce the problem?
Running the following program with "go test -v":

package simple

import (
        "testing"
        "time"
)

func TestEmpty(*testing.T) {}

func TestNanosecond(*testing.T) {
        time.Sleep(time.Nanosecond)
}

func TestMicrosecond(*testing.T) {
        time.Sleep(time.Microsecond)
}

func TestMillisecond(*testing.T) {
        time.Sleep(time.Millisecond)
}

func TestSecond(*testing.T) {
        time.Sleep(time.Second)
}

func ExampleEmpty() {
        // Output:                                                                                                                                                                                                
}

func ExampleNanosecond() {
        time.Sleep(time.Nanosecond)
        // Output:                                                                                                                                                                                                
}

func ExampleMicroSecond() {
        time.Sleep(time.Microsecond)
        // Output:                                                                                                                                                                                                
}

func ExampleMillisecond() {
        time.Sleep(time.Millisecond)
        // Output:                                                                                                                                                                                                
}

func ExampleSecond() {
        time.Sleep(time.Second)
        // Output:                                                                                                                                                                                                
}

results in the following output:

=== RUN TestEmpty
--- PASS: TestEmpty (0.00 seconds)
=== RUN TestNanosecond
--- PASS: TestNanosecond (0.00 seconds)
=== RUN TestMicrosecond
--- PASS: TestMicrosecond (0.00 seconds)
=== RUN TestMillisecond
--- PASS: TestMillisecond (0.00 seconds)
=== RUN TestSecond
--- PASS: TestSecond (1.00 seconds)
=== RUN: ExampleEmpty
--- PASS: ExampleEmpty (408ns)
=== RUN: ExampleNanosecond
--- PASS: ExampleNanosecond (61.263us)
=== RUN: ExampleMicroSecond
--- PASS: ExampleMicroSecond (42.937us)
=== RUN: ExampleMillisecond
--- PASS: ExampleMillisecond (1.126604ms)
=== RUN: ExampleSecond
--- PASS: ExampleSecond (1.001000532s)
PASS
ok      _/Users/jsimsa/tmp  2.011s

As you can see the formatting of the timing of tests and examples is inconsistent. I
suggest that examples use the same formatting of timing as tests. (The Go distribution
my team uses employs a simple patch to that end in order to simplify post-processing of
test results).
@robpike

This comment has been minimized.

Copy link
Contributor

commented Jun 9, 2014

Comment 1:

Just the kind of inconsistency that gets stuck in my craw. Will fix for next release.
Note: the use of 'us' for microseconds also sticks in my craw.

Labels changed: added release-go1.4.

Owner changed to @robpike.

Status changed to Accepted.

@gopherbot

This comment has been minimized.

Copy link
Author

commented Jun 11, 2014

Comment 2:

CL https://golang.org/cl/103320043 mentions this issue.
@robpike

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2014

Comment 3:

This issue was closed by revision 0e92b53.

Status changed to Fixed.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015

@rsc rsc removed the release-go1.4 label Apr 14, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018

testing: fix timing format inconsistency
Fixes golang#8175.

LGTM=r
R=golang-codereviews, r, gobot
CC=golang-codereviews
https://golang.org/cl/103320043

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.