bootstrap

package module
v0.0.0-...-73dd228 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PackageDir     = "bootstrap"
	CargoWorkspace = "byte-rs"
)
View Source
const RegexpIgnoreCase = "(?i)"

Variables

This section is empty.

Functions

func Boot

func Boot(mainSourceFile string)

Performs the boot routine for the bootstrap process. This will check if the bootstrapper needs to be update and rebuild itself, restarting the process if that is the case.

func Caller

func Caller(skip int) string

func CargoDir

func CargoDir() string

Returns the root path where to run cargo.

func ExeName

func ExeName(name string) string

func Exec

func Exec(name string, args []string, callback func(output string, isError bool)) (int, error)

Exec a process using a callback to process output.

func ExecInDir

func ExecInDir(prefix, dir string, callback func() bool) bool

func FileName

func FileName() string

Returns the Go filename of the caller function.

func Glob

func Glob(root, pattern string) (out []string)

func GlobRegex

func GlobRegex(pattern string) string

func Lines

func Lines(input string) []string

func MatchesPattern

func MatchesPattern(input, pattern string) bool

func NoError

func NoError(err error, msg string)

func ProjectDir

func ProjectDir() string

Returns the absolute root directory for the project.

func ReadJson

func ReadJson(filename string, output any) any

func ReadText

func ReadText(filename string) string

func Relative

func Relative(base, path string) string

func Run

func Run(prefix, name string, args ...string) bool

Run a new process handling errors and stderr output.

func Spawn

func Spawn(name string, args ...string) error

Spawn a new process "replaces" the current process by the given one.

The new process shares the same environment and standard output streams as the current process.

After the spawned process exits, the current process will exit with the same exit code.

func TrimLines

func TrimLines(lines []string) []string

func WithExtension

func WithExtension(filename string, ext string) string

Types

type CommonSequence

type CommonSequence struct {
	PosA int
	PosB int
	Len  int
}

func LCS

func LCS[T comparable](a []T, b []T) (out []CommonSequence)

Compute the Longest Common Subsequence (LCS) of A and B.

type Diff

type Diff[T comparable] struct {
	// contains filtered or unexported fields
}

func Compare

func Compare[T comparable](input, output []T) Diff[T]

func (Diff[T]) Blocks

func (diff Diff[T]) Blocks() (out []DiffBlock)

func (Diff[T]) String

func (diff Diff[T]) String() string

func (Diff[T]) Text

func (diff Diff[T]) Text() (out []string)

type DiffBlock

type DiffBlock struct {
	Kind int
	Src  int
	Dst  int
	Len  int
}

Represents a block of removed, inserted, or equal elements.

`Kind` represents the type of block:

- If 0 -> this is a run of equal elements between `Src` and `Dst`; - If -1 -> this is a block of elements from `Src` removed from `Dst`; - If +1 -> this is a block of elements from `Dst` inserted into `Src`.

func (DiffBlock) String

func (blk DiffBlock) String() string

type Runner

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

func NewRunner

func NewRunner(release bool) Runner

func (Runner) ExecScript

func (runner Runner) ExecScript(
	filename string,
	callback func(output string, isError bool),
) (int, error)

func (Runner) Spawn

func (runner Runner) Spawn(args ...string)

type ScriptTest

type ScriptTest struct {
	Name    string
	File    string
	Error   error
	Success bool
	Skipped bool

	Directory string

	Expected any
	StdOut   string
	StdErr   string
	ExitCode int

	ExpectOutput []string
	ActualOutput []string
}

func RunScriptTest

func RunScriptTest(scriptFileName string) (out ScriptTest)

func (*ScriptTest) CheckResult

func (test *ScriptTest) CheckResult()

func (ScriptTest) OutputDetails

func (test ScriptTest) OutputDetails()

Jump to

Keyboard shortcuts

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