Skip to content

Commit

Permalink
gopls/internal/test/integration: fix flakiness of TestResolveImportCycle
Browse files Browse the repository at this point in the history
Avoid flaky dependence on go list error messages in
TestResolveImportCycle. It would be better if we could guarantee that
the error is from go list, but since the error from golang/go#64899 is
reasonable, it is best to just avoid the flake for now.

Fixes golang/go#64899

Change-Id: If5038acbdf020323d8fa9db0d8e1e8e054cfe464
Reviewed-on: https://go-review.googlesource.com/c/tools/+/556495
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
  • Loading branch information
findleyr committed Jan 17, 2024
1 parent d517112 commit 0d1b478
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gopls/internal/test/integration/diagnostics/diagnostics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1672,12 +1672,17 @@ const B = a.B
env.OpenFile("b/b.go")
env.AfterChange(
// The Go command sometimes tells us about only one of the import cycle
// errors below. For robustness of this test, succeed if we get either.
// errors below. Also, sometimes we get an error during type checking
// instead of during list, due to missing metadata. This is likely due to
// a race.
// For robustness of this test, succeed if we get any reasonable error.
//
// TODO(golang/go#52904): we should get *both* of these errors.
// TODO(golang/go#64899): we should always get an import cycle error
// rather than a missing metadata error.
AnyOf(
Diagnostics(env.AtRegexp("a/a.go", `"mod.test/b"`), WithMessage("import cycle")),
Diagnostics(env.AtRegexp("b/b.go", `"mod.test/a"`), WithMessage("import cycle")),
Diagnostics(env.AtRegexp("a/a.go", `"mod.test/b"`)),
Diagnostics(env.AtRegexp("b/b.go", `"mod.test/a"`)),
),
)
env.RegexpReplace("b/b.go", `const B = a\.B`, "")
Expand Down

0 comments on commit 0d1b478

Please sign in to comment.