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 by navigating from this source file (test/harness/shared/exec.go -> repo root is three levels up). 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 captured separately and surfaced only inside the returned error on failure. Use when stderr carries diagnostics that must not contaminate parsed stdout (e.g. gcloud prints a benign WARNING to stderr when a --filter matches an empty list).
func RunCmdTee ¶
func RunCmdTee(ctx context.Context, extraEnv []string, logPath, name string, args ...string) (string, error)
RunCmdTee executes name with args like RunCmd but additionally streams the combined output to logPath as it runs. Long-running deploy commands tee here so multi-megabyte output lands in a file under .test-output/ rather than the test's inline log. The returned string is still the full captured output so callers can fold it into error messages.
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.