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

Tests with importpath but no sources are not deleted #80

Closed
jayconrod opened this issue Jan 5, 2018 · 0 comments
Closed

Tests with importpath but no sources are not deleted #80

jayconrod opened this issue Jan 5, 2018 · 0 comments
Labels

Comments

@jayconrod
Copy link
Contributor

For example, in https://github.com/kubernetes/sample-controller/blob/master/vendor/k8s.io/api/core/v1/BUILD, the go_default_test rule should be deleted since it has no sources. After running Gazelle, that rule is left behind with name and importpath attributes.

The problem is that importpath is no longer considered a mergeable attribute for go_test and go_binary, so it won't get removed, and the rule won't be considered empty. Currently, rules are considered empty if they have no attributes other than name and visibility.

We should expand the definition of empty: rules generated by Gazelle that have no srcs, deps, or embed attributes after merge should be deleted. This should catch go_binary with manually set goos and goarch as well.

@jayconrod jayconrod added the bug label Jan 5, 2018
jayconrod pushed a commit to jayconrod/bazel-gazelle that referenced this issue Jan 11, 2018
Gazelle will now delete a rule after merging when the following
conditions are true:

* No sources were found for the rule.
* After merging, none of the attributes "srcs", "deps", "embed", or
  "proto" were defined.
* The rule has no "# keep" comment at the top level.

Fixes bazel-contrib#80
jayconrod added a commit that referenced this issue Jan 12, 2018
Gazelle will now delete a rule after merging when the following
conditions are true:

* No sources were found for the rule.
* After merging, none of the attributes "srcs", "deps", "embed", or
  "proto" were defined.
* The rule has no "# keep" comment at the top level.

Fixes #80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant