Documentation
¶
Overview ¶
Package regtest provides an environment for writing regression tests.
Index ¶
- type DiagnosticExpectation
- type Env
- func (e *Env) Await(expectations ...DiagnosticExpectation)
- func (e *Env) CloseBuffer(name string)
- func (e *Env) CloseEditor()
- func (e *Env) CreateBuffer(name string, content string)
- func (e *Env) EditBuffer(name string, edits ...fake.Edit)
- func (e *Env) FormatBuffer(name string)
- func (e *Env) GoToDefinition(name string, pos fake.Pos) (string, fake.Pos)
- func (e *Env) OpenFile(name string)
- func (e *Env) OrganizeImports(name string)
- func (e *Env) ReadWorkspaceFile(name string) string
- func (e *Env) RemoveFileFromWorkspace(name string)
- func (e *Env) SaveBuffer(name string)
- type EnvMode
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiagnosticExpectation ¶
type DiagnosticExpectation struct { IsMet func(map[string]*protocol.PublishDiagnosticsParams) bool Description string }
A DiagnosticExpectation is a condition that must be met by the current set of diagnostics.
func DiagnosticAt ¶
func DiagnosticAt(name string, line, col int) DiagnosticExpectation
DiagnosticAt asserts that there is a diagnostic entry at the position specified by line and col, for the workspace-relative path name.
func EmptyDiagnostics ¶
func EmptyDiagnostics(name string) DiagnosticExpectation
EmptyDiagnostics asserts that diagnostics are empty for the workspace-relative path name.
type Env ¶
type Env struct { // Most tests should not need to access the workspace or editor, or server, // but they are available if needed. W *fake.Workspace E *fake.Editor Server servertest.Connector // contains filtered or unexported fields }
Env holds an initialized fake Editor, Workspace, and Server, which may be used for writing tests. It also provides adapter methods that call t.Fatal on any error, so that tests for the happy path may be written without checking errors.
func (*Env) Await ¶
func (e *Env) Await(expectations ...DiagnosticExpectation)
Await waits for all diagnostic expectations to simultaneously be met.
func (*Env) CloseBuffer ¶
CloseBuffer closes an editor buffer without saving, calling t.Fatal on any error.
func (*Env) CloseEditor ¶ added in v1.0.0
func (e *Env) CloseEditor()
CloseEditor shuts down the editor, calling t.Fatal on any error.
func (*Env) CreateBuffer ¶
CreateBuffer creates a buffer in the editor, calling t.Fatal on any error.
func (*Env) EditBuffer ¶
EditBuffer applies edits to an editor buffer, calling t.Fatal on any error.
func (*Env) FormatBuffer ¶
FormatBuffer formats the editor buffer, calling t.Fatal on any error.
func (*Env) GoToDefinition ¶
GoToDefinition goes to definition in the editor, calling t.Fatal on any error.
func (*Env) OrganizeImports ¶
OrganizeImports processes the source.organizeImports codeAction, calling t.Fatal on any error.
func (*Env) ReadWorkspaceFile ¶
ReadWorkspaceFile reads a file from the workspace, calling t.Fatal on any error.
func (*Env) RemoveFileFromWorkspace ¶ added in v1.0.0
RemoveFileFromWorkspace deletes a file on disk but does nothing in the editor. It calls t.Fatal on any error.
func (*Env) SaveBuffer ¶
SaveBuffer saves an editor buffer, calling t.Fatal on any error.
type EnvMode ¶ added in v1.0.0
type EnvMode int
EnvMode is a bitmask that defines in which execution environments a test should run.
const ( // Singleton mode uses a separate cache for each test. Singleton EnvMode = 1 << iota Shared // Forwarded forwards connections to an in-process gopls instance. Forwarded // SeparateProcess runs a separate gopls process, and forwards connections to // it. SeparateProcess // NormalModes runs tests in all modes. NormalModes = Singleton | Forwarded )
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
A Runner runs tests in gopls execution environments, as specified by its modes. For modes that share state (for example, a shared cache or common remote), any tests that execute on the same Runner will share the same state.
func NewTestRunner ¶ added in v1.0.0
NewTestRunner creates a Runner with its shared state initialized, ready to run tests.
func (*Runner) Modes ¶ added in v1.0.0
Modes returns the bitmask of environment modes this runner is configured to test.