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

Use a more unique name for the cover variable #1764

Merged
merged 1 commit into from Oct 12, 2018

Conversation

ixdy
Copy link
Contributor

@ixdy ixdy commented Oct 11, 2018

In kubernetes, we get a build failure when running bazel coverage:

GoCompile: error running subcommand: exit status 2
pkg/kubelet/container/testing/os.go:143: Cover_os redeclared in this block
        previous declaration during import "k8s.io/kubernetes/pkg/kubelet/container"
pkg/kubelet/container/testing/runtime_mock.go:32: Cover_os redeclared during import "k8s.io/kubernetes/pkg/kubelet/container"
        previous declaration at pkg/kubelet/container/testing/os.go:143

The root cause appears to be at least partially self-inflicted; we have a pkg/kubelet/container/os.go file (in package container), and a pkg/kubelet/container/testing/os.go file (in package testing).

The existing rules_go coverage generator creates a Cover_os variable in each package, which would be unique, except that pkg/kubelet/container/testing/runtime_mock.go dot-imports pkg/kubelet/container, causing the conflict.

I've attempted to fix the issue here by just including the package path in the variable name, e.g. Cover_k8s_io_kubernetes_pkg_kubelet_container_os instead of Cover_os. This seems to work, though I'm not sure if there are corner cases I'm missing.

Copy link
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jayconrod jayconrod merged commit 6f55a50 into bazelbuild:master Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants