{"action":"created","issue":{"url":"https://api.github.com/repos/bazelbuild/rules_go/issues/64","repository_url":"https://api.github.com/repos/bazelbuild/rules_go","labels_url":"https://api.github.com/repos/bazelbuild/rules_go/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/rules_go/issues/64/comments","events_url":"https://api.github.com/repos/bazelbuild/rules_go/issues/64/events","html_url":"https://github.com/bazelbuild/rules_go/issues/64","id":170307783,"number":64,"title":"go_test rule doesn't support TestMain","user":{"login":"adrianludwin","id":20559844,"avatar_url":"https://avatars.githubusercontent.com/u/20559844?v=3","gravatar_id":"","url":"https://api.github.com/users/adrianludwin","html_url":"https://github.com/adrianludwin","followers_url":"https://api.github.com/users/adrianludwin/followers","following_url":"https://api.github.com/users/adrianludwin/following{/other_user}","gists_url":"https://api.github.com/users/adrianludwin/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianludwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianludwin/subscriptions","organizations_url":"https://api.github.com/users/adrianludwin/orgs","repos_url":"https://api.github.com/users/adrianludwin/repos","events_url":"https://api.github.com/users/adrianludwin/events{/privacy}","received_events_url":"https://api.github.com/users/adrianludwin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-10T01:22:47Z","updated_at":"2016-08-17T02:35:49Z","closed_at":"2016-08-17T02:35:49Z","body":"I should be able to create a function with the signature:\r\n\r\n`func TestMain(m *testing.M)`\r\n\r\nwhich is used to setup/teardown common work before/after each test. But `go/tools/generate_test_main.go` includes this function as one of the tests, which is incorrect. \r\n\r\nThe following patch _appears_ to fix the problem:\r\n\r\n~~~~\r\ndiff --git a/go/tools/generate_test_main.go b/go/tools/generate_test_main.go\r\nindex b78f124..29fc4b9 100644\r\n--- a/go/tools/generate_test_main.go\r\n+++ b/go/tools/generate_test_main.go\r\n@@ -76,6 +76,10 @@ func main() {\r\n                        if !strings.HasPrefix(fn.Name.Name, \"Test\") {\r\n                                continue\r\n                        }\r\n+                       if fn.Name.Name == \"TestMain\" {\r\n+                               // TestMain is not, itself, a test\r\n+                               continue\r\n+                       }\r\n                        cases.Names = append(cases.Names, fn.Name.Name)\r\n                }\r\n        }\r\n~~~~\r\n\r\nBut I don't see any tests for this rule so I'm not sure how to verify this change. \r\n\r\nCC @yugui - I hear you're the guru on these rules :) Also CCing @kchodorow - are you the owner of this file/repo?"},"comment":{"url":"https://api.github.com/repos/bazelbuild/rules_go/issues/comments/240297946","html_url":"https://github.com/bazelbuild/rules_go/issues/64#issuecomment-240297946","issue_url":"https://api.github.com/repos/bazelbuild/rules_go/issues/64","id":240297946,"user":{"login":"yugui","id":8161,"avatar_url":"https://avatars.githubusercontent.com/u/8161?v=3","gravatar_id":"","url":"https://api.github.com/users/yugui","html_url":"https://github.com/yugui","followers_url":"https://api.github.com/users/yugui/followers","following_url":"https://api.github.com/users/yugui/following{/other_user}","gists_url":"https://api.github.com/users/yugui/gists{/gist_id}","starred_url":"https://api.github.com/users/yugui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yugui/subscriptions","organizations_url":"https://api.github.com/users/yugui/orgs","repos_url":"https://api.github.com/users/yugui/repos","events_url":"https://api.github.com/users/yugui/events{/privacy}","received_events_url":"https://api.github.com/users/yugui/received_events","type":"User","site_admin":false},"created_at":"2016-08-17T02:35:48Z","updated_at":"2016-08-17T02:35:48Z","body":"Fixed with #68.\r\n\r\n@adrianludwin Thank you for your contribution!"}}
{"actor":{"display_login":"yugui"}}