Investigating failures of gopls/internal/regtest/diagnostics.TestResolveImportCycles with @matloob, we discovered that gopls is not locating import cycle errors on all packages involved in an import cycle.
In go list json output, the Error field is only set for one package, but the rest can be inferred from the cycle information.
The text was updated successfully, but these errors were encountered:
In JSON output, the Go command was only setting the Error field for one
package involved in an import cycle. As a result, TestResolveImportCycle
was dependent on the chosen package, causing flakes when the chosen
package is not deterministic.
Arguably this behavior should be fixed, both in the go command and in
gopls, but for now make the test resilient to choice by asserting on any
of the possible errors.
Add a new AnyOf expectation to support this type of assertion and tweak the
test output formatting. Also update the test to eagerly fail once the
didOpen notification has been fully processed, so that we don't have to
wait for the assertion timeout.
Reviewed-by: Michael Matloob <firstname.lastname@example.org>
Run-TryBot: Robert Findley <email@example.com>
TryBot-Result: Gopher Robot <firstname.lastname@example.org>
gopls-CI: kokoro <email@example.com>