Documentation
¶
Overview ¶
Package shared provides cross-cutting test-harness utilities: repo-root resolution, command execution, and tee-to-file output capture used by the e2e harness.
Index ¶
- func RepoRoot() string
- func RunCmd(ctx context.Context, extraEnv []string, name string, args ...string) (string, error)
- func RunCmdStdout(ctx context.Context, extraEnv []string, name string, args ...string) (string, error)
- func RunCmdTee(ctx context.Context, extraEnv []string, logPath, name string, args ...string) (string, error)
- func ShortID() string
- func Slug(s string) string
- func TestOutputDir() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RepoRoot ¶
func RepoRoot() string
RepoRoot returns the absolute path of the repository root, resolved from this source file so callers need not hard-code paths.
func RunCmd ¶
RunCmd executes name with args, inheriting os.Environ() and appending extraEnv. It returns the combined stdout+stderr output and any error. The command is bound to ctx, so a cancelled context kills the process.
func RunCmdStdout ¶
func RunCmdStdout(ctx context.Context, extraEnv []string, name string, args ...string) (string, error)
RunCmdStdout runs name with args like RunCmd but returns only stdout; stderr is surfaced only inside the error on failure. Use when stderr carries diagnostics that must not contaminate parsed stdout (e.g. gcloud's benign empty-filter WARNING).
func RunCmdTee ¶
func RunCmdTee(ctx context.Context, extraEnv []string, logPath, name string, args ...string) (string, error)
RunCmdTee runs name with args like RunCmd but also streams the combined output to logPath, so a long-running command's multi-megabyte output lands in a file rather than the inline log. The returned string is still the full captured output.
func ShortID ¶
func ShortID() string
ShortID returns a short, lowercase, DNS-label-safe random identifier (8 hex chars). Used to make per-run resource names unique so concurrent or leftover runs do not collide.
func Slug ¶
Slug normalizes s into a DNS-1123-label-safe token: lowercased, with disallowed characters collapsed to single hyphens and the result trimmed of leading/trailing hyphens. Used to derive resource names from test names.
func TestOutputDir ¶
func TestOutputDir() string
TestOutputDir returns the repo's .test-output directory, the standard destination for tee'd long-running command logs.
Types ¶
This section is empty.