-
Notifications
You must be signed in to change notification settings - Fork 655
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
Avoid calling go_path rule in source mode #3121
Conversation
This looks good to me. Is there any chance we could use add a test? Even just something that used it would provide a lot of confidence for me. We could also add a test in https://github.com/bazelbuild/rules_go/tree/master/tests/integration to confirm it if you're feeling it. Also, what would you think about explicitly adding some docs onto this that say the API on the gomock rules isn't stable yet? Then we can make some changes, wait for it to solidify and then promote it? |
Good ideas. I added a unit test, instead of an integration test, to generate mocks using the |
@@ -0,0 +1,33 @@ | |||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "gomock") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this shouldn't be in tests/core
since it isn't a part of the core go
package, it is a part of extras
. Should we put this inside extras/tests/gomock
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to be consistent with go_embed_data, which is also in extras. I can create a follow up PR to move both tests/core/go_embed_data
and tests/core/gomock
to tests/extras
.
What type of PR is this?
Performance optimization. This is also a breaking change from original
gomock
rule implementation, because it changes the types ofaux_files
attribute.What does this PR do? Why is it needed?
Running mockgen in source mode does not require all its dependencies in GOPATH. It only need the source file and some aux files. We can copy them to form a GOPATH structure without calling
go_path
rule.Before this patch:
After this patch:
The experiment can be reproduced in the following workspace:
go mod tidy
bazel run //:gazelle-update-repos
bazel build --profile=/tmp/mocks.gz //:mocks
bazel analyze-profile /tmp/mocks.gz