Documentation
¶
Overview ¶
Package testlib contains test helpers for goreleaser tests.
Index ¶
- Variables
- func AssertSkipped(t *testing.T, err error)
- func CaptureSummary(tb testing.TB) func() []string
- func CatFileFromBareRepository(tb testing.TB, url, name string) []byte
- func CatFileFromBareRepositoryOnBranch(tb testing.TB, url, branch, name string) []byte
- func CheckDocker(tb testing.TB)
- func CheckPath(tb testing.TB, cmd string)
- func Echo(s string) string
- func EmbeddedSchemaIDs(document any) []string
- func Exit(status int) string
- func GetFileFromArchive(tb testing.TB, path, format, filename string) []byte
- func GitAdd(tb testing.TB)
- func GitAnnotatedTag(tb testing.TB, tag, message string)
- func GitBranch(tb testing.TB, branch string)
- func GitCheckoutBranch(tb testing.TB, name string)
- func GitCommit(tb testing.TB, msg string)
- func GitInit(tb testing.TB)
- func GitMakeBareRepository(tb testing.TB) string
- func GitRemoteAdd(tb testing.TB, url string)
- func GitRemoteAddWithName(tb testing.TB, remote, url string)
- func GitRemoteTrackingRef(tb testing.TB, remote, branch string)
- func GitTag(tb testing.TB, tag string)
- func InPath(cmd string) bool
- func IsCI() bool
- func IsDockerRunning(ctx context.Context) bool
- func IsWindows() bool
- func LsArchive(tb testing.TB, path, format string) []string
- func MakeNewSSHKey(tb testing.TB, pass string) string
- func MakeNewSSHKeyType(tb testing.TB, pass string, algo keygen.KeyType) string
- func Mktmp(tb testing.TB) string
- func MustDockerPool(f Fataler) *dockertest.Pool
- func MustKillContainer(f Fataler, name string)
- func OnlyOnLinux(tb testing.TB, args ...any)
- func RequireEqualArtifacts(tb testing.TB, expected, got []*artifact.Artifact)
- func RequireNoExtraField(tb testing.TB, a *artifact.Artifact, key string)
- func RequireTemplateError(tb testing.TB, err error)
- func ShC(cmd string) string
- func SharedZigCache(tb testing.TB)
- func SkipIfWindows(tb testing.TB, args ...any)
- func StartRegistry(tb testing.TB, name, port string)
- func Touch(name string) string
- type Fataler
Constants ¶
This section is empty.
Variables ¶
var GoVersion = strings.TrimPrefix(runtime.Version(), "go")
GoVersion is the current Go version, without the "go" prefix.
Functions ¶
func AssertSkipped ¶
AssertSkipped asserts that a pipe was skipped.
func CaptureSummary ¶
CaptureSummary points the GitHub Actions job summary at a temporary file, and returns a function that reads back the lines written to it.
func CheckDocker ¶
CheckDocker skips the test if docker is not running.
func CheckPath ¶
CheckPath skips the test if the binary is not in PATH, unless CI=true. In CI, the test runs without checking this prerequisite.
func EmbeddedSchemaIDs ¶ added in v0.0.2
EmbeddedSchemaIDs are the JSON pointers of every subschema below the root of a decoded JSON Schema that carries its own $id: an embedded schema resource, which a reference from outside it may not portably point into.
func GetFileFromArchive ¶
GetFileFromArchive returns the contents of filename inside the given archive path.
func GitAnnotatedTag ¶
GitAnnotatedTag creates an annotated tag.
func GitCheckoutBranch ¶
GitCheckoutBranch allows us to change the active branch that we're using.
func GitMakeBareRepository ¶
func GitRemoteAdd ¶
GitRemoteAdd adds the given url as remote.
func GitRemoteAddWithName ¶
GitRemoteAddWithName adds the given url as remote with given name.
func GitRemoteTrackingRef ¶
GitRemoteTrackingRef points refs/remotes/<remote>/<branch> at HEAD, so a test can set an upstream without fetching from a real remote.
func IsCI ¶
func IsCI() bool
IsCI returns true if we have the "CI" environment variable set to true.
func IsDockerRunning ¶
IsDockerRunning executes a `docker ps` and returns true if it succeeds.
func MakeNewSSHKeyType ¶
func Mktmp ¶
Mktmp creates a new tempdir, cd into it and automatically cd back when the test finishes.
func MustDockerPool ¶
func MustDockerPool(f Fataler) *dockertest.Pool
MustDockerPool gets a single dockertet.Pool.
func MustKillContainer ¶
MustKillContainer kills the given container by name if it exists in the current dockertest.Pool.
func OnlyOnLinux ¶
OnlyOnLinux skips the test unless the runtime OS is Linux.
func RequireEqualArtifacts ¶
func RequireNoExtraField ¶
func RequireTemplateError ¶
RequireTemplateError requires thqt an error happens and that it is a template error.
func ShC ¶
ShC returns the command line for the given cmd wrapped into a `sh -c` in linux/mac, and the cmd.exe command in windows.
func SharedZigCache ¶
SharedZigCache points zig's global cache at a single directory shared by every test in the run, while the caller keeps a local cache of its own.
The global cache is content addressed and lock protected, so sharing it is safe: 12 concurrent builds against one directory were verified to complete without error. Sharing it also lets each test reuse the libc and compiler-rt another test already compiled, which measured ~38% faster for the second and later projects.
It deliberately lives outside the workspace. setup-zig caches $GITHUB_WORKSPACE/.zig-cache between runs, and restoring a half-saved copy of that is what actually produced the "manifest hit with missing outputs" corruption in goreleaser#6754, not concurrent access. CI saves this separate cache only after the tests finish successfully.
func SkipIfWindows ¶
SkipIfWindows skips the test if runtime OS is windows.
func StartRegistry ¶
StartRegistry starts a registry with the given name in the given port, and sets up its deletion on test.Cleanup.