core

package
v0.0.0-...-7a30fe1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

func (*Checker) CheckTranscript

func (ckr *Checker) CheckTranscript(ctx context.Context, r io.Reader) error

func (*Checker) HandleEnd

func (ckr *Checker) HandleEnd(ctx context.Context) error

type CommandCheckError

type CommandCheckError struct {
	Command string
	Lineno  int
	Errs    []error
}

func (CommandCheckError) Error

func (err CommandCheckError) Error() string

type CommandResult

type CommandResult struct {
	Output   []byte
	ExitCode int
}

type DiffError

type DiffError struct {
	Expected string
	Actual   string
}

func (DiffError) Color

func (err DiffError) Color() string

func (DiffError) Error

func (err DiffError) Error() string

func (DiffError) Plain

func (err DiffError) Plain() string

type Handler

type Handler interface {
	// HandleComment processes comment lines and blank lines.
	// Corresponds to cmdt syntax: "# comment text" or blank lines.
	HandleComment(ctx context.Context, text string) error

	// HandleRun executes a shell command.
	// Corresponds to cmdt syntax: "$ command args".
	HandleRun(ctx context.Context, command string) error

	// HandleOutput processes expected output from a command.
	// The fd parameter indicates the file descriptor: 1 for stdout, 2 for stderr.
	// Corresponds to cmdt syntax: "1 stdout line" or "2 stderr line".
	HandleOutput(ctx context.Context, fd int, line string) error

	// HandleFileOutput processes expected output that references an external file.
	// The fd parameter indicates the file descriptor: 1 for stdout, 2 for stderr.
	// The filepath parameter specifies the file containing the expected output.
	// Corresponds to cmdt syntax: "1< filename" or "2< filename".
	HandleFileOutput(ctx context.Context, fd int, filepath string) error

	// HandleNoNewline indicates that the last output line did not end with a newline.
	// The fd parameter indicates which stream (stdout=1, stderr=2) lacks the newline.
	// Corresponds to cmdt syntax: "% no-newline".
	HandleNoNewline(ctx context.Context, fd int) error

	// HandleExitCode processes the expected exit code of a command.
	// If omitted in the transcript, the exit code defaults to 0.
	// Corresponds to cmdt syntax: "? exitcode".
	HandleExitCode(ctx context.Context, exitCode int) error

	// HandleEnd is called after a command and all its assertions have been processed.
	// This method has no direct cmdt syntax equivalent but signals command completion.
	HandleEnd(ctx context.Context) error
}

Handler provides callbacks for processing transcript operations. Each method corresponds to a specific cmdt opcode or interpreter event.

type Interpreter

type Interpreter struct {
	// Input parameters.
	Handler Handler

	// Exposed state.
	Lineno        int    // Line currently executing.
	Command       string // Text of the most recently executed command.
	CommandLineno int    // Line of the most recently executed command.
	// contains filtered or unexported fields
}

Interprets a transcript file.

func (*Interpreter) ExecLine

func (t *Interpreter) ExecLine(ctx context.Context, text string) error

func (*Interpreter) ExecTranscript

func (t *Interpreter) ExecTranscript(ctx context.Context, r io.Reader) error

type Recorder

type Recorder struct {
	// If provided, tees Stdout to this writer in addition to the buffer.
	Stdout io.Writer
	// If provided, tees Stderr to this writer in addition to the buffer.
	Stderr io.Writer
	// Transcript captures the recorded output in cmdt format.
	Transcript bytes.Buffer
	// contains filtered or unexported fields
}

Recorder is a shell Interpreter that captures a command transcript into the Transcript byte buffer.

func (*Recorder) Exited

func (rec *Recorder) Exited() bool

func (*Recorder) Init

func (rec *Recorder) Init() error

func (*Recorder) RecordComment

func (rec *Recorder) RecordComment(text string)

func (*Recorder) RunCommand

func (rec *Recorder) RunCommand(ctx context.Context, command string) (*CommandResult, error)

func (*Recorder) SetPreferredFiles

func (rec *Recorder) SetPreferredFiles(files []string)

SetPreferredFiles sets the list of preferred filenames in order. Files should be provided in deterministic order (stderr first, then stdout).

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

func (*Updater) HandleComment

func (upr *Updater) HandleComment(ctx context.Context, text string) error

func (*Updater) HandleEnd

func (upr *Updater) HandleEnd(ctx context.Context) error

func (*Updater) HandleExitCode

func (upr *Updater) HandleExitCode(ctx context.Context, exitCode int) error

func (*Updater) HandleFileOutput

func (upr *Updater) HandleFileOutput(ctx context.Context, fd int, filepath string) error

func (*Updater) HandleNoNewline

func (upr *Updater) HandleNoNewline(ctx context.Context, fd int) error

func (*Updater) HandleOutput

func (upr *Updater) HandleOutput(ctx context.Context, fd int, line string) error

func (*Updater) HandleRun

func (upr *Updater) HandleRun(ctx context.Context, command string) error

func (*Updater) UpdateTranscript

func (upr *Updater) UpdateTranscript(ctx context.Context, r io.Reader) (transcript *bytes.Buffer, err error)

Jump to

Keyboard shortcuts

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