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

x/playground: test files that provide TestMain without other Test functions fail to compile #45431

Open
bcmills opened this issue Apr 7, 2021 · 0 comments

Comments

@bcmills
Copy link
Member

@bcmills bcmills commented Apr 7, 2021

This test source file fails to compile in the Playground (https://play.golang.org/p/LabCgwBLD6d):

package main

import (
	"os"
	"testing"
)

func TestMain(m *testing.M) {
	os.Exit(0)
}
runtime.main_main·f: function main is undeclared in the main package

Go build failed.

However, it compiles and runs successfully with the actual go command:

$ go test .
ok      example.com     0.008s

-- go.mod --
module example.com

go 1.17
-- main_test.go --
package main

import (
        "os"
        "testing"
)

func TestMain(m *testing.M) {
        os.Exit(0)
}

CC @golang/release

(Compare to the failure mode in #32403.)

@gopherbot gopherbot added this to the Unreleased milestone Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants