Skip to content

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

Closed

Description

@mitchellh
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.

Activity

  1. mitchellh commented on Aug 19, 2014

    @mitchellh
    Author

    Comment 1:

    Verified this happens with go version devel +7e00313f3b3a Tue Aug 19 08:50:35 2014 -0700
    darwin/amd64
  2. gopherbot commented on Aug 20, 2014

    @gopherbot
    Contributor

    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]
  3. gopherbot commented on Aug 20, 2014

    @gopherbot
    Contributor

    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
  4. gopherbot commented on Aug 20, 2014

    @gopherbot
    Contributor

    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
  5. ianlancetaylor commented on Aug 20, 2014

    @ianlancetaylor
    Contributor

    Comment 5:

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

  6. josharian commented on Sep 17, 2014

    @josharian
    Contributor

    Comment 6:

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

    Status changed to Duplicate.

    Merged into issue #8337.

  7. added this to the Go1.4 milestone on Apr 14, 2015
  8. locked and limited conversation to collaborators on Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions