lstesting

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TitleDelimiter      = "### TITLE ###"
	DocumentDelimiter   = "### DOCUMENT ###"
	ChangeDelimiter     = "### CHANGE ###"
	CompletionDelimiter = "### COMPLETION"  // e.g. "### COMPLETION 0:0 ###"
	CodeActionDelimiter = "### CODE_ACTION" // e.g. "### CODE_ACTION 0:0 0:0 ###"
	StdoutDelimiter     = "### STDOUT ###"
)

Variables

View Source
var UpdateSnapshots = flag.Bool("update", false, "update snapshot expected outputs")

Functions

func Run

func Run(tc *SnapshotCase) (string, error)

Run executes a single snapshot test case against a real in-process server. It handles the full LSP lifecycle: initialization, didOpen, actions, and shutdown. Returns the normalized JSON output of all server messages after the init handshake.

func WriteSnapshotFile

func WriteSnapshotFile(path string, cases []SnapshotCase) error

WriteSnapshotFile writes test cases back to a .snap file.

Types

type Action

type Action struct {
	Type     ActionType
	Content  string     // For CHANGE: new document text
	Position *lsp.Pos   // For COMPLETION: cursor position
	Range    *lsp.Range // For CODE_ACTION: selected range
}

type ActionType

type ActionType int
const (
	ActionChange ActionType = iota
	ActionCompletion
	ActionCodeAction
)

type SnapshotCase

type SnapshotCase struct {
	Title    string
	Document string
	Actions  []Action
	Stdout   string
}

func ParseSnapshotFile

func ParseSnapshotFile(path string) ([]SnapshotCase, error)

ParseSnapshotFile reads a .snap file and extracts LSP test cases.

Format:

### TITLE ###
<test name>
### DOCUMENT ###
<rad source code>
### CHANGE ###              (optional, repeatable)
<new document text>
### COMPLETION 0:0 ###      (optional, repeatable, header-only)
### CODE_ACTION 0:0 0:0 ### (optional, repeatable, header-only)
### STDOUT ###
<expected server output as normalized JSON>

Jump to

Keyboard shortcuts

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