{"action":"opened","issue":{"url":"https://api.github.com/repos/golang/go/issues/23786","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/23786/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/23786/comments","events_url":"https://api.github.com/repos/golang/go/issues/23786/events","html_url":"https://github.com/golang/go/issues/23786","id":296291219,"number":23786,"title":"Unintuitive behavior when using -coverpkg","user":{"login":"F21","id":2263040,"avatar_url":"https://avatars0.githubusercontent.com/u/2263040?v=4","gravatar_id":"","url":"https://api.github.com/users/F21","html_url":"https://github.com/F21","followers_url":"https://api.github.com/users/F21/followers","following_url":"https://api.github.com/users/F21/following{/other_user}","gists_url":"https://api.github.com/users/F21/gists{/gist_id}","starred_url":"https://api.github.com/users/F21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/F21/subscriptions","organizations_url":"https://api.github.com/users/F21/orgs","repos_url":"https://api.github.com/users/F21/repos","events_url":"https://api.github.com/users/F21/events{/privacy}","received_events_url":"https://api.github.com/users/F21/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-12T08:02:30Z","updated_at":"2018-02-12T08:02:30Z","closed_at":null,"author_association":"NONE","body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n\r\n### What version of Go are you using (`go version`)?\r\n1.10 RC2\r\n\r\n### Does this issue reproduce with the latest release?\r\nYes\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\nWindows 10 64-bit (latest release + updates)\r\n\r\n### What did you do?\r\nCode is available here: https://github.com/F21/coverpkgtest.git\r\n\r\nI have a project arranged like so:\r\n```\r\ncoverpkgtest (package at the root)\r\n- somepkg\r\n  - dontcover\r\n    - some generated files\r\n  - some tests\r\n- some tests\r\n```\r\n\r\nThis uses [Ben Johnson's standard layout](https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1) where the domain model is in the package root.\r\n\r\n`dontcover` represents things like protobufs or other generated code that I don't want to include in the coverage report.\r\n\r\nI want to run my tests for the package and all other subpackages and get a coverage report excluding packages containing the generated code.\r\n\r\n### What did you expect to see?\r\nThis runs all tests in all packages (expected).\r\n```\r\n$ go test -coverpkg=./... -coverprofile=cover.out -v ./...\r\n=== RUN   TestSomething\r\n--- PASS: TestSomething (0.00s)\r\nPASS\r\ncoverage: 0.0% of statements in ./...\r\nok      github.com/F21/coverpkgtest     1.157s  coverage: 0.0% of statements in ./...\r\n=== RUN   TestSomePkg\r\n--- PASS: TestSomePkg (0.00s)\r\nPASS\r\ncoverage: 0.0% of statements in ./...\r\nok      github.com/F21/coverpkgtest/somepkg     2.896s  coverage: 0.0% of statements in ./...\r\n?       github.com/F21/coverpkgtest/somepkg/dontcover   [no test files]\r\n```\r\n\r\nThis only runs tests in `somepkg`. The `./...` at the end of the `go test` command being ignored is also surprising. In addition, `go list` lists all packages, so it was also surprising that tests in the root package was skipped\r\n```\r\n$ go test -coverpkg=$(go list ./...) -coverprofile=cover.out -v ./...\r\n=== RUN   TestSomePkg\r\n--- PASS: TestSomePkg (0.00s)\r\nPASS\r\ncoverage: 0.0% of statements in github.com/F21/coverpkgtest\r\nok      github.com/F21/coverpkgtest/somepkg     1.581s  coverage: 0.0% of statements in github.com/F21/coverpkgtest\r\n?       github.com/F21/coverpkgtest/somepkg/dontcover   [no test files]\r\n```\r\n\r\nThis runs all tests. Adding a space between the equals the the packages to test runs all tests. I am not sure why the space makes a difference\r\n```\r\n$ go test -coverpkg= $(go list ./...) -coverprofile=cover.out -v ./...\r\n=== RUN   TestSomething\r\n--- PASS: TestSomething (0.00s)\r\nPASS\r\ncoverage: 0.0% of statements\r\nok      github.com/F21/coverpkgtest     1.370s  coverage: 0.0% of statements\r\n=== RUN   TestSomePkg\r\n--- PASS: TestSomePkg (0.00s)\r\nPASS\r\ncoverage: 0.0% of statements\r\nok      github.com/F21/coverpkgtest/somepkg     2.652s  coverage: 0.0% of statements\r\n?       github.com/F21/coverpkgtest/somepkg/dontcover   [no test files]\r\n```\r\n\r\nThis works as expected:\r\n```\r\n$ go test -coverpkg=github.com/F21/coverpkgtest,github.com/F21/coverpkgtest/somepkg -v ./...\r\n=== RUN   TestSomething\r\n--- PASS: TestSomething (0.00s)\r\nPASS\r\ncoverage: 0.0% of statements in github.com/F21/coverpkgtest, github.com/F21/coverpkgtest/somepkg\r\nok      github.com/F21/coverpkgtest     2.923s  coverage: 0.0% of statements in github.com/F21/coverpkgtest, github.com/F21/coverpkgtest/somepkg\r\n=== RUN   TestSomePkg\r\n--- PASS: TestSomePkg (0.00s)\r\nPASS\r\ncoverage: 0.0% of statements in github.com/F21/coverpkgtest, github.com/F21/coverpkgtest/somepkg\r\nok      github.com/F21/coverpkgtest/somepkg     1.545s  coverage: 0.0% of statements in github.com/F21/coverpkgtest, github.com/F21/coverpkgtest/somepkg\r\n?       github.com/F21/coverpkgtest/somepkg/dontcover   [no test files]\r\n```\r\n\r\n### What did you see instead?\r\nSee above\r\n"}}
{"actor":{"display_login":"F21"}}