src.elv.shsrc.elv.sh/pkg/prog/progtest Index | Files

package progtest

import "src.elv.sh/pkg/prog/progtest"

Package progtest contains utilities for wrapping prog.Program instances into Elvish functions, so that they can be tested using the src.elv.sh/pkg/eval/evaltest framework.

Index

Functions

func ElvishInGlobal

func ElvishInGlobal(p prog.Program) func(ev *eval.Evaler)

ElvishInGlobal returns a setup function suitable for the evaltest framework, which creates a function called "elvish" in the global scope that invokes the given program.

func ProgramAsGoFn

func ProgramAsGoFn(p prog.Program) any

ProgramAsGoFn converts a prog.Program to a Go-implemented Elvish function.

Stdin of the program is connected to the stdin of the function.

Stdout of the program is usually written unchanged to the stdout of the function, except when:

Stderr of the program is written to the stderr of the function with a [stderr] prefix, with similar treatment for missing trailing EOL and &check-stderr-contains.

If the program exits with a non-zero return value, a line "[exit] $i" is written to stderr.

Source Files

progtest.go

Version
v0.21.0 (latest)
Published
Aug 13, 2024
Platform
linux/amd64
Imports
7 packages
Last checked
1 day ago

Tools for package owners.