stubcmd

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stubcmd stands in for command-line programs (gh, winget) in tests, alike on every OS: Install copies the test binary under the program's name next to a file of rules, and Main, run first by the test binary's TestMain, makes that copy answer by them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(t testing.TB, dir, name string, rules ...Rule) string

Install puts the stub program name (name.exe on Windows) answering by rules into dir and returns its path. The test binary must run Main.

func Main

func Main(m *testing.M)

Main runs tests by m, unless this process is a stub: then it answers by its rules (the first matching; none: "unexpected" and exit 1) and exits.

Types

type Rule

type Rule struct {
	// Args matches the arguments joined by spaces, as sh's case "$*" does:
	// '*' matches any run of characters, anything else itself.
	Args   string
	Stdout string
	Stderr string
	Exit   int
	// Await, when set, is a file the stub waits for before answering.
	Await string
}

Rule is one answer of a stub.

Jump to

Keyboard shortcuts

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