-
Notifications
You must be signed in to change notification settings - Fork 8
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
support gcexportdata export files for loading packages instead of golang.org/x/tools/go/packages.Load
#50
base: main
Are you sure you want to change the base?
Conversation
4c3cd04
to
010a2c1
Compare
…lang.org/x/tools/go/packages.Load`
010a2c1
to
87f69a6
Compare
golang.org/x/tools/go/packages.Load
golang.org/x/tools/go/packages.Load
Quality Gate passedIssues Measures |
@@ -67,7 +71,7 @@ func parseFlags() (*generation.Options, error) { | |||
app := kingpin.New(consts.Name, consts.Description).Version(consts.Version) | |||
app.UsageWriter(os.Stdout) | |||
|
|||
app.Arg("path", "The import paths used to search for eligible interfaces").Required().StringsVar(&opts.PackageOptions[0].ImportPaths) | |||
app.Arg("path", "The import paths used to search for eligible interfaces").StringsVar(&opts.PackageOptions[0].ImportPaths) |
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.
This change should be covered later by https://github.com/derision-test/go-mockgen/pull/50/files#diff-bec68f6a8e7a9ffdba1264a1140ed04a177aade22c6e516c9d47cd36cd6e1656R334-R336.
It has to be non-required so that --manifest-dir can be passed in isolation
Adds a new: - gazelle generator - rule + rule targets + catchall target for generating go-mockgen mocks & testing for their being up-to-date. Each go_mockgen macro invocation adds targets for generating mocks, copying to the source tree, as well as testing whether the current source tree mocks are up-to-date. How to use this: `bazel run //dev:go_mockgen` for the catch-all, or `bazel run //some/target:generate_mocks` for an individual package, and `bazel test //some/target:generate_mocks_tests` to test for up-to-date-ness. There is no catch-all for testing This currently uses a fork of go-mockgen, with an open PR for upstream here: derision-test/go-mockgen#50. Closes https://github.com/sourcegraph/sourcegraph/issues/60099 ## Test plan Extensive testing during development, including the following cases: - Deleting a generated file and its entry in a go_library/go_test `srcs` attribute list and then re-running `sg bazel configure` - Adding a non-existent output directory to mockgen.test.yaml and running the bash one-liner emitted to prepare the workspace for rerunning `sg bazel configure` The existing config tests a lot of existing paths anyway (creating mocks for a 3rd party library's interface, entries for a given output file in >1 config file etc)
@@ -126,6 +131,10 @@ func parseManifest() ([]*generation.Options, error) { | |||
opts.ForTest = true | |||
} | |||
|
|||
if len(opts.Paths) > 0 && len(opts.Archives) > 0 { | |||
return nil, fmt.Errorf("multiple import paths and archives are mutually exclusive") |
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.
return nil, fmt.Errorf("multiple import paths and archives are mutually exclusive") | |
return nil, fmt.Errorf("import paths and archives are mutually exclusive") |
Is this more correct? They're both >0, not >1.
@@ -139,11 +148,15 @@ func parseManifest() ([]*generation.Options, error) { | |||
|
|||
var packageOptions []generation.PackageOptions | |||
if len(opts.Sources) > 0 { | |||
if len(opts.Paths) > 0 || len(opts.Interfaces) > 0 { | |||
if len(opts.Paths) > 0 || len(opts.Interfaces) > 0 || opts.Path != "" { |
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.
Is this necessary? I thought we rolled in the single path into the slice somewhere.
Adds support for recreating
packages.Package
andpackages.TypeInfo
data from gcexportdata, which is data about the public API of a compiled package (what types does it export, what packages are indirectly exposed by it etc).Both the gcexportdata for the sum of the transitive closures of package dependenices we are generating mocks from , as well as the source files of the packages of which we are generating mocks from are required as new inputs.
This is as an alternative to
packages.Load
, which is not available (or cheaply available) in certain environments (this in particular was spurred by a Bazel environment, but the idea likely extends to others like Buck{,2}).