Help us shape the future of Go! Take the 2026 Go Developer Survey

lsptest

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package lsptest is a fake language server for tests: the test binary re-executes itself, so tests need no real language server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertGone

func AssertGone(t testing.TB, pids []int)

AssertGone fails unless every pid has exited.

func ReadPids

func ReadPids(t testing.TB, file string, n int) []int

ReadPids waits for n pids in file.

func Run

func Run()

Run acts as the fake server and exits when the test binary was started by an entry from Server. Call it first in TestMain.

func Server

func Server(t testing.TB, name string, exts []string, opts ...string) config.LSPServer

Server returns a config entry running the fake server. Each opt is key=value or a bare flag:

log=FILE            append "start" and each received method (didOpen
                    and didChange add the text, quoted) to FILE
pidfile=FILE        append the server's pid to FILE
child               also start a child process (its pid goes to pidfile)
envfile=FILE        write the server's environment to FILE
nopublish           never publish diagnostics
crash               exit right after the first response
ignore-shutdown     never answer shutdown and ignore exit
hang-init           never answer initialize
refs=FILE           answer references with FILE's locations
def=FILE            answer definition with FILE's locations

By default every didOpen and didChange publishes one diagnostic per line containing "ERR:" (an error) or "WARN:" (a warning): the message is the rest of the line and the column is where the marker starts.

func WriteLocs

func WriteLocs(t testing.TB, path string, locs []Loc)

WriteLocs writes locs as a refs or def file.

Types

type Loc

type Loc struct {
	Path      string `json:"path"`
	Line      int    `json:"line"`
	Character int    `json:"character"`
}

Loc is one location in a refs or def file: an absolute path and a zero-based line and UTF-16 character.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL