testenv

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package testenv checks host capabilities a test needs, so a test runs wherever the host provides them and says why it skipped where the host does not. Only test code imports this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bash

func Bash(t testing.TB) string

Bash returns the bash that runs repository scripts, and skips the test when the host has none. On Windows it is Git for Windows' bash: bash.exe on PATH is usually the WSL launcher, which runs the script inside a Linux distribution without the host's toolchains or files.

func GrantOthersRead

func GrantOthersRead(t testing.TB, path string)

GrantOthersRead lets principals other than the owner read the file at path (mode 0644), so an owner-only check must refuse it.

func InheritOthersRead

func InheritOthersRead(testing.TB, string)

InheritOthersRead is a no-op on POSIX: a new file's mode is set when it is created, so the directory cannot grant access to it beforehand.

func ReadOnlyDir

func ReadOnlyDir(t testing.TB, dir string)

ReadOnlyDir lets the current user list and traverse dir but not add or remove its entries (mode 0555) until the test ends. Root ignores permission bits, so the test is skipped there.

func ScriptCommand

func ScriptCommand(t testing.TB, path string, args ...string) *exec.Cmd

ScriptCommand returns a command that runs the repository script at path with args. A POSIX host runs the script directly. Windows cannot run a script by its #! line, so there the command names the interpreter that line selects: bash or sh through Bash or Sh, and python3 as found on PATH. A script with any other interpreter skips the test on Windows.

func Sh

func Sh(t testing.TB) string

Sh returns the POSIX sh that runs repository scripts, found as Bash is.

func Symlink(t testing.TB, oldname, newname string)

Symlink creates newname as a symbolic link to oldname. When the host does not let this process create symbolic links (Windows without Developer Mode or elevation), the test is skipped; any other error fails it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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