scripttest

package
v0.16.397 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 12 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 scripttest replays the scripted cases the previous runtime's modules ran (the golden files of the checkpoint store and of the routes over git): the same file and git actions in a temporary folder, and the same dumps of a working folder and a shadow repository, so a Go test compares like with like.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitEnv

func GitEnv(extra ...string) []string

GitEnv is the environment without GIT_ variables, plus extra.

Types

type Action

type Action struct {
	Path    string  `json:"path"`
	PathB64 string  `json:"pathB64"`
	Write   *string `json:"write"`
	B64     *string `json:"b64"`
	Repeat  *string `json:"repeat"`
	Count   int     `json:"count"`
	Mode    *int    `json:"mode"`
	Link    *string `json:"link"`
	Rm      bool    `json:"rm"`
	Mkdir   bool    `json:"mkdir"`
	Chmod   *int    `json:"chmod"`
	Mtime   *int64  `json:"mtime"`
	Git     []string
	Date    string
}

Action is one step on the files: write (text, base64 or a repeated string), link, rm, mkdir, chmod, mtime, or a git command run in the folder (with a fixed author and, given a date, fixed dates).

type World

type World struct {
	Root string
	// contains filtered or unexported fields
}

World is a script's temporary folder; HOME and XDG_CONFIG_HOME point into it, so git reads no person's config.

func New

func New(t testing.TB, roots []string) *World

New is a fresh world; roots are the working folders a script names (their hashes are scrubbed too).

func (*World) Apply

func (w *World) Apply(actions []Action)

Apply runs file and git actions; a file action that fails is skipped from where it failed, as gen.mjs skipped it.

func (*World) DumpRepo

func (w *World) DumpRepo(dir, ns string) any

DumpRepo is a shadow repository: its refs (the namespace written as NS; commits by tree and subject, other objects by id), its own files and leftover temporary files.

func (*World) DumpTree

func (w *World) DumpTree(dir string) []any

DumpTree is every entry of a working folder but .git folders, by raw name: folders, files by mode and content hash, links by target.

func (*World) Git

func (w *World) Git(dir string, input []byte, args []string, extra ...string) string

Git runs git in dir and fails the test when it fails.

func (*World) NoteRoot

func (w *World) NoteRoot(cwd string)

NoteRoot creates a working folder and has the hash of its real path scrubbed as #<cwd>#.

func (*World) Scrub

func (w *World) Scrub(s string) string

Scrub writes the temporary folder as $ROOT and the noted hashes by name.

Jump to

Keyboard shortcuts

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