fix(lsp): make real-gopls integration test opt-in via env var#691
fix(lsp): make real-gopls integration test opt-in via env var#691PierrunoYT wants to merge 2 commits into
Conversation
TestManagerCheckRealGopls ran whenever a gopls binary was on PATH, so an installed but unusable gopls (e.g. a broken persistent-index cache) failed the default go test ./... suite with 'lsp error -1: EOF'. Gate the test behind ZERO_LSP_REAL_GOPLS_TEST=1, following the existing opt-in convention for smoke tests, so the default hermetic suite never depends on the health of a developer's global language server. Default coverage continues to use the fake LSP server. Fixes Gitlawb#684 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR makes the real-gopls integration test in internal/lsp explicitly opt-in via an environment variable so the default go test ./... suite remains hermetic and doesn’t fail due to a developer’s local gopls installation health/cache state.
Changes:
- Gate
TestManagerCheckRealGoplsbehindZERO_LSP_REAL_GOPLS_TEST(skip by default with a clear message). - Keep the existing secondary guard that skips when
goplsis not onPATH.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Warning Review limit reached
Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe real gopls manual test is now opt-in through ChangesReal gopls test gating
Estimated code review effort: 2 (Simple) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/lsp/real_gopls_manual_test.go`:
- Around line 18-19: Update the environment guard in the real gopls test to
enable execution only when ZERO_LSP_REAL_GOPLS_TEST equals the exact string "1";
skip for unset, empty, "0", "false", and all other values, while preserving the
existing skip message.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 31c1d621-9c2b-4431-b8fd-bd04ab1aafd7
📒 Files selected for processing (1)
internal/lsp/real_gopls_manual_test.go
Any non-empty value (including 0 or false) enabled the real gopls test, contradicting the documented =1 contract in the skip message. Compare against "1" exactly, per PR review. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
anandh8x
left a comment
There was a problem hiding this comment.
LGTM. Hermetic-by-default, opt-in via ZERO_LSP_REAL_GOPLS_TEST=1, matches existing ZERO_*_TEST convention. The == "1" strict match fix in 23390b0 is correct. Ship it.
Follow-up (non-blocking): add a short CONTRIBUTING.md note listing the ZERO_LSP_*_TEST env vars so future real-LSP tests for other languages follow the same pattern.
There was a problem hiding this comment.
Read the diff the ZERO_LSP_REAL_GOPLS_TEST=1 guard goes in before the LookPath check, which is the right order, and the skip message is clear. Confirmed gofmt and go vet ./internal/lsp/ are clean on the touched file, and without the env var set the test skips and the full ./internal/lsp/ suite passes. Test-only and low risk, so I'm approving. Good call gating this behind an env var so a globally installed gopls can't flake the hermetic suite.
Summary
Fixes #684 —
TestManagerCheckRealGoplsran as part of the defaultgo test ./...suite whenever anygoplsbinary was onPATH, so an installed but unusable gopls (e.g. a broken persistent-index cache) failed the whole suite withlsp error -1: EOF.Changes
The test is now gated behind an explicit
ZERO_LSP_REAL_GOPLS_TEST=1opt-in, following the repo's existing convention for real-dependency smoke tests (ZERO_STT_DOWNLOAD_TEST,ZERO_STT_STREAM_SERVER, …). Thegopls-on-PATH skip is kept as a secondary guard for the opt-in path. Default hermetic coverage continues to run against the fake LSP server.Verification
On Windows (go1.26.5 windows/amd64):
go test ./internal/lsp -run '^TestManagerCheckRealGopls$' -v→ SKIP with a clear opt-in message.ZERO_LSP_REAL_GOPLS_TEST=1 go test ...→ PASS against a real gopls (1 compiler diagnostic reported).go test ./internal/lsppasses.🤖 Generated with Claude Code
Summary by CodeRabbit
ZERO_LSP_REAL_GOPLS_TESTenvironment variable.