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 -timeout flag behavior doesn't match test binary -timeout flag behavior #20025

Closed
josharian opened this issue Apr 18, 2017 · 4 comments

Comments

@josharian
Copy link
Contributor

Running a test binary with -h prints:

  -test.timeout d
    	fail test binary execution after duration d (0 means unlimited)

But that doesn't seem to work:

package p

import (
	"testing"
	"time"
)

func BenchmarkSlow(b *testing.B) {
	for i := 0; i < b.N; i++ {
		time.Sleep(15 * time.Minute)
	}
}

Running this with go test -bench=. -timeout=0 x_test.go results (eventually) in *** Test killed with quit: ran too long (10m0s).

@josharian josharian added this to the Go1.9 milestone Apr 18, 2017
@josharian josharian changed the title testing: -timeout=0 does not disable timeouts cmd/go: go test -timeout flag behavior doesn't match test binary -timeout flag behavior Apr 18, 2017
@josharian
Copy link
Contributor Author

Ick. Looks like this is implemented correctly in package testing, but that this timeout comes from 'go test', so to disable timeouts you need to use 'go test -c' and then execute. It'd be much nicer if test binaries and cmd/go agreed on behavior, and there was a way to disable timeouts directly via 'go test'.

I guess a workaround is 'go test -timeout=1000h'.

@josharian josharian modified the milestones: Go1.9Maybe, Go1.9 Apr 18, 2017
@ianlancetaylor
Copy link
Contributor

It's really just a bug in cmd/go. Explicitly passing -test.timeout=0 should disable testKillTimeout in cmd/go/internal/test/test.go.

In fact this is #18490.

@ianlancetaylor
Copy link
Contributor

And I have to respect the fact that you did a thumbs up on my suggestion in #18490 which would also fix this issue....

@josharian
Copy link
Contributor Author

Hahaha. My mental github issue index clearly failed me. Thanks, Ian. :)

@golang golang locked and limited conversation to collaborators Apr 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants