-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Go: Make diagnostics unit-testable and add test for EmitCannotFindPackages
#21214
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
base: mbg/go/improve-package-not-found
Are you sure you want to change the base?
Go: Make diagnostics unit-testable and add test for EmitCannotFindPackages
#21214
Conversation
7e91ac5 to
f837d90
Compare
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.
Pull request overview
This PR makes the Go extractor diagnostics output mechanism injectable to enable unit testing, and adds unit tests for the go/autobuilder/package-not-found diagnostic emitted by EmitCannotFindPackages.
Changes:
- Introduce a
DiagnosticsWriterabstraction and a file-backed default writer for diagnostics emission. - Update the extractor to call
EmitCannotFindPackageswith an explicit writer. - Add unit tests for
EmitCannotFindPackagesand wire them into Bazel.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| go/extractor/diagnostics/diagnostics.go | Adds DiagnosticsWriter + file writer and routes EmitCannotFindPackages through an injected writer. |
| go/extractor/extractor.go | Updates call site to pass diagnostics.DefaultWriter into EmitCannotFindPackages. |
| go/extractor/diagnostics/diagnostics_test.go | Adds unit tests covering default/dynamic/actions messaging variants. |
| go/extractor/diagnostics/BUILD.bazel | Adds a go_test target for the new unit tests. |
| go/extractor/go.mod | Adds new module deps needed for tests (testify + transitive deps). |
| go/extractor/go.sum | Updates dependency checksums accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f262616 to
1fba381
Compare
1fba381 to
45e0a92
Compare
Mostly a follow-up from (and based on) #21213 which:
diagnostics.gomore easily testable by abstracting over the diagnostics output mechanism.EmitCannotFindPackages