feat(internal/testhelper): check managed protoc in RequireCommand - #7521
Bhaumik-99 wants to merge 6 commits into
Conversation
RequireCommand now checks for a librarian-managed protoc binary in the cache bin directory before skipping tests when protoc is not on the system PATH. This allows tests relying on protoc to run without requiring a global protoc installation. Fixes googleapis#7493
There was a problem hiding this comment.
Code Review
This pull request updates RequireCommand to support librarian-managed protoc installations, preventing tests from being skipped if a managed binary is available. The review feedback points out that simply not skipping the test is insufficient because subsequent executions of protoc will still fail if it is not in the system PATH. The reviewer suggests updating RequireCommand to temporarily add the managed protoc directory to the PATH environment variable using t.Setenv, using absolute paths for reliability, and adding tests to verify this behavior.
Update findManagedProtoc to return the absolute binary path and boolean status. Ensure RequireCommand prepends the managed protoc directory to PATH via t.Setenv so subsequent executions within the test can discover and invoke it. Update unit tests to verify protoc discovery on PATH.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates RequireCommand in internal/testhelper/testhelper.go to locate a librarian-managed protoc binary in the cache directory and prepend its path to the PATH environment variable for tests, with accompanying unit tests added in internal/testhelper_test.go. Feedback recommends documenting that tests using RequireCommand for protoc cannot be run in parallel due to the use of t.Setenv. Additionally, it is suggested to replace filepath.Glob with os.ReadDir in findManagedProtoc to more robustly find and prefer the latest version of protoc without glob escaping issues.
|
Hi maintainers, I’ve addressed the review feedback and updated the implementation and tests for managed The focused tests and lint checks are passing. The remaining blockers appear to be the required internal approvals and approval of the pending workflows from the fork. Could a maintainer please approve the pending workflows and review the PR when available? Thank you! |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances the test helper to locate and use librarian-managed protoc binaries when they are not present in the system PATH, including logic to parse, compare, and select the newest installed version. The review feedback suggests several important improvements to make this logic more robust: avoiding a trailing path separator when PATH is empty to prevent security risks, and extending the version parsing and comparison logic to support 3-component semantic versions (e.g., v3.20.3) rather than assuming exactly two components.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for locating and using a librarian-managed protoc binary from the cache directory when it is not found in the system PATH. It introduces version parsing and comparison logic to select the newest installed version, along with comprehensive unit tests. The review feedback highlights an issue in the version comparison logic where lexicographical comparison of prerelease tags (e.g., "-rc2" vs "-rc10") incorrectly ranks them, and suggests parsing trailing numeric suffixes numerically. Additionally, it recommends adding a test case to verify double-digit release candidate comparisons.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the RequireCommand helper in internal/testhelper/testhelper.go to automatically locate and use a librarian-managed protoc binary from the cache directory if it is not found in the system PATH. It introduces robust version parsing and comparison logic to ensure the newest installed version is selected, and updates the test environment's PATH accordingly. Additionally, a comprehensive suite of unit tests has been added in internal/testhelper/testhelper_test.go to verify this behavior. There are no review comments, so I have no feedback to provide.
RequireCommand now checks for a librarian-managed protoc binary in the cache bin directory before skipping tests when protoc is not on the system PATH. This allows tests relying on protoc to run without requiring a global protoc installation.
Fixes #7493