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
x/tools/internal/lsp/regtest: change behavior when awaiting diagnostics #38113
Comments
I started working on something related to this in https://golang.org/cl/225158 earlier this week, but ran into strange problems with the non-standard request that I haven't figured out. You can also change the timeout in reg_test.go -- that's what I do when writing a new test. |
Change https://golang.org/cl/226842 mentions this issue: |
One of the tricky things about asserting on conditions in regtests is the asynchronous nature of LSP. For example, as the LSP client we cannot be sure when we've received all diagnostics for a given file. Currently, regtests are implemented by awaiting specific diagnostic expectations. This means that if gopls generates diagnostics that do not match those expectations, we can only time out the test. Ideally, we would want to know that gopls is done generating all diagnostics for the current file state. This is not possible without knowing the status of diagnostics for. Barring this, we would want to know that diagnostics are done for the current file version. Unfortunately, that also is not possible, because a new version of file B can affect diagnostics in file A. So in lieu of this information, this CL exposes a few tools that can be used to improve the experience of writing new regtests. - A new expectation is added: AnyDiagnosticAtCurrentVersion, that is satisfied if any diagnostics have been received for the current buffer version. - ExpectDiagnostics is added to Env, to help check whether the current diagnostics matches expectations. Updates golang/go#38113 Change-Id: I48d2c3db87c13ac3ab424d01d9444cbc285af9e1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/226842 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@stamblerre I think this was fixed (at least as well as it can be) by https://golang.org/cl/229977. Do you agree? |
Yep! Let's close. |
Struggled to come up with a good issue description, so sorry if it's not clear.
As I've been writing more regtests, I've noticed that waiting on diagnostics can be tedious if you're not certain what the diagnostic should be - you end up having to wait 30 seconds for the tests to run just to confirm that you made a mistake in the column number or something like that. Is it reasonable for the regtests to see that a diagnostic came in for the file in question, but it was just not the expected one, and then exit early?
/cc @findleyr
The text was updated successfully, but these errors were encountered: