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: better error for test functions with wrong signature #14226

Closed
dominikh opened this issue Feb 4, 2016 · 4 comments
Closed

cmd/go: better error for test functions with wrong signature #14226

dominikh opened this issue Feb 4, 2016 · 4 comments
Milestone

Comments

@dominikh
Copy link
Member

dominikh commented Feb 4, 2016

Running go test against test code that declares a Test* function with a wrong signature results in a somewhat unpleasant compile error:

dominikh-pc /tmp $ cat foo_test.go
package foo

func TestBroken(wrong, signature int) {}
dominikh-pc /tmp $ go test
# testmain
go-build299431253/_/tmp/_test/_testmain.go:22: cannot use foo.TestBroken (type func(int, int)) as type func(*testing.T) in field value
FAIL    _/tmp [build failed]
dominikh-pc 2? /tmp $ 

It might be nice to check for the signature before compiling the test binary, to print a customized error.

@dominikh
Copy link
Member Author

dominikh commented Feb 4, 2016

The same applies to benchmarks.

@bradfitz
Copy link
Contributor

bradfitz commented Feb 4, 2016

I hit this the other day too.

@bradfitz bradfitz added this to the Go1.7 milestone Feb 4, 2016
@gopherbot
Copy link

CL https://golang.org/cl/19763 mentions this issue.

@cmarcelo
Copy link
Contributor

@bradfitz or @dominikh could one of you take a look at the CL above?

@golang golang locked and limited conversation to collaborators Feb 28, 2017
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

4 participants