1
0
mirror of https://github.com/golang/go synced 2024-11-19 11:44:45 -07:00
go/internal/lsp/fake/doc.go
Rob Findley f9587291b6 internal/lsp/fake: add fakes for testing editor interaction
A lot of bug reports originating from LSP clients are related to either
the timing or sequence of editor interactions with gopls (or at least
they're originally reported this way). For example: "when I open a
package and then create a new file, I lose diagnostics for existing
files".  These conditions are often hard to reproduce, and to isolate as
either a gopls bug or a bug in the editor.

Right now we're relying on govim integration tests to catch these
regressions, but it's important to also have a testing framework that
can exercise this functionality in-process.  As a starting point this CL
adds test fakes that implement a high level API for scripting editor
interactions. A fake workspace can be used to sandbox file operations; a
fake editor provides an interface for text editing operations; a fake
LSP client can be used to connect the fake editor to a gopls instance.
Some tests are added to the lsprpc package to demonstrate the API.

The primary goal of these fakes should be to simulate an client that
complies to the LSP spec. Put another way: if we have a bug report that
we can't reproduce with our regression tests, it should either be a bug
in our test fakes or a bug in the LSP client originating the report.

I did my best to comply with the spec in this implementation, but it
will certainly develop as we write more tests. We will also need to add
to the editor API in the future for testing more language features.

Updates golang/go#36879
Updates golang/go#34111

Change-Id: Ib81188683a7066184b8a254275ed5525191a2d68
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217598
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-10 17:44:19 +00:00

20 lines
945 B
Go

// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package fake provides fake implementations of a text editor, LSP client
// plugin, and workspace for use in tests.
//
// The Editor type provides a high level API for text editor operations
// (open/modify/save/close a buffer, jump to definition, etc.), and the Client
// type exposes an LSP client for the editor that can be connected to a
// language server. By default, the Editor and Client should be compliant with
// the LSP spec: their intended use is to verify server compliance with the
// spec in a variety of environment. Possible future enhancements of these
// types may allow them to misbehave in configurable ways, but that is not
// their primary use.
//
// The Workspace type provides a facility for executing tests in a clean
// workspace and GOPATH.
package fake