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: syntax errors not picked up if no tests cases #8555

Closed
mitchellh opened this issue Aug 19, 2014 · 6 comments
Closed

testing: syntax errors not picked up if no tests cases #8555

mitchellh opened this issue Aug 19, 2014 · 6 comments
Milestone

Comments

@mitchellh
Copy link

go version go1.3 darwin/amd64

Create two files:

"foo.go": 

package foo

func foo() {
    NOPE I AM A SYNTAX ERROR
}
j

"foo_test.go":

package foo

Then run `go test` and the test passes. If you add a single test case to `foo_test.go`,
then it errors as expected. I believe that this was not the behavior with Go 1.2 but
haven't verified. I have a lot of test cases for really basic packages that I just want
to test compilation, and it no longer is testing that, when it was before.
@mitchellh
Copy link
Author

Comment 1:

Verified this happens with go version devel +7e00313f3b3a Tue Aug 19 08:50:35 2014 -0700
darwin/amd64

@gopherbot
Copy link

Comment 2 by jason.beranek:

go 1.1.1 on windows/amd64 returned the following:
.\foo.go:4: syntax error: unexpected name, expecting semicolon or newline or }
.\foo.go:6: non-declaration statement outside function body
FAIL    _/Z_/Downloads/foo_test [build failed]

@gopherbot
Copy link

Comment 3:

I can confirm it did fail on 1.2 and it does not on 1.3.1:
$ go version
go version go1.2 linux/amd64
$ go test
# github.com/vdemario/foo
/home/vitordemario/ssd/golang/src/github.com/vdemario/foo/foo.go:4: syntax error:
unexpected name, expecting semicolon or newline or }
FAIL    github.com/vdemario/foo [build failed]
$ go version
go version go1.3.1 linux/amd64
$ go test
testing: warning: no tests to run
PASS
ok      github.com/vdemario/foo 0.001s

@gopherbot
Copy link

Comment 4:

I can confirm it did fail on 1.2 and it does not on 1.3.1:
$ go version
go version go1.2 linux/amd64
$ go test
(...)
syntax error: unexpected name, expecting semicolon or newline or }
FAIL    github.com/vdemario/foo [build failed]
$ go version
go version go1.3.1 linux/amd64
$ go test
testing: warning: no tests to run
PASS
ok      github.com/vdemario/foo 0.001s

@ianlancetaylor
Copy link
Contributor

Comment 5:

Labels changed: added repo-main, release-go1.4.

@josharian
Copy link
Contributor

Comment 6:

Looks like a duplicate of 8337. Please holler if I'm wrong.

Status changed to Duplicate.

Merged into issue #8337.

@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
This issue was closed.
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

5 participants