Help us shape the future of Go! Take the 2026 Go Developer Survey

harness

package
v0.57.13 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ChromiumGPUEnv = "E2E_CHROMIUM_GPU"

ChromiumGPUEnv selects the Chromium GPU launch policy for local e2e runs.

Variables

View Source
var ErrNoAndroidDevice = errors.New("no adb device")

ErrNoAndroidDevice is returned when adb is missing or sees no device.

Functions

func ChromiumLaunchOptions added in v0.57.2

func ChromiumLaunchOptions(headless bool, gpu bool) playwright.BrowserTypeLaunchOptions

ChromiumLaunchOptions returns the Playwright launch options for one Chromium launch mode. gpu requests acceleration in full Chromium using its platform-selected backend; forcing Vulkan can select software on macOS.

func LaunchChromium added in v0.57.2

func LaunchChromium[B any](
	ctx context.Context,
	p *ChromiumLaunchPolicy,
	launch func(gpu bool) (B, error),
) (B, error)

LaunchChromium performs one Chromium launch under the sticky policy. launch receives true when the GPU options must be used. The first launch resolves the sticky GPU choice: prefer-GPU probes the GPU launch once and falls back to the legacy launch on error; legacy never attempts GPU; required never falls back. Concurrent callers serialize only while the choice is unresolved; relaunches reuse it without retrying. Cancellation aborts a launch that has not started yet.

func Resolve

func Resolve[A any](ctx context.Context, le *logrus.Entry, opts ResolveOptions, shape Shape[A]) (A, error)

Resolve returns a valid artifact, coalescing builds across processes.

Types

type AndroidChrome

type AndroidChrome struct {
	// Browser is the connected browser. Closing it only disconnects.
	Browser playwright.Browser
	// contains filtered or unexported fields
}

AndroidChrome is Chrome on the one Android device adb sees, reached over the DevTools protocol through adb port forwarding. Chrome must be open and the device unlocked; a locked device freezes its tabs.

Chrome on Android cannot create browser contexts, so tests share the profile's context and remove what they leave with ClearOrigin.

func ConnectAndroidChrome

func ConnectAndroidChrome(pw *playwright.Playwright, ports ...string) (*AndroidChrome, error)

ConnectAndroidChrome makes each of ports on the device reach the same port on this host and connects to the device's Chrome.

func (*AndroidChrome) ClearOrigin

func (a *AndroidChrome) ClearOrigin(origin string) error

ClearOrigin closes the pages of origin and clears its storage. Pages close first because Chrome cannot clear OPFS under an open sync access handle.

func (*AndroidChrome) Close

func (a *AndroidChrome) Close()

Close disconnects from Chrome and removes the port forwards.

func (*AndroidChrome) Context

Context returns the profile's browser context.

type BuildLock

type BuildLock struct {
	// contains filtered or unexported fields
}

BuildLock owns one held cross-process build lock.

func AcquireBuildLock

func AcquireBuildLock(ctx context.Context, le *logrus.Entry, lockDir, name string) (*BuildLock, error)

AcquireBuildLock acquires a named cross-process build lock. Context cancellation is checked before and after the kernel wait, but cannot promptly interrupt a caller parked in that wait.

func (*BuildLock) Release

func (l *BuildLock) Release()

Release unlocks and closes the build lock without unlinking its shared path.

type ChromiumGPUPreference added in v0.57.2

type ChromiumGPUPreference int

ChromiumGPUPreference is the three-state Chromium GPU launch policy parsed from E2E_CHROMIUM_GPU.

const (
	// ChromiumGPUPreferGPU is the unset default. Launch with hardware GPU
	// enabled; on a launch error, retry the legacy software launch once.
	ChromiumGPUPreferGPU ChromiumGPUPreference = iota
	// ChromiumGPULegacy is an explicit opt-out (false/0/no/off). Launch
	// legacy software Chromium only.
	ChromiumGPULegacy
	// ChromiumGPURequired is an explicit opt-in (true/1/yes/on). The GPU
	// launch is required and never falls back.
	ChromiumGPURequired
)

func ParseChromiumGPUPreference added in v0.57.2

func ParseChromiumGPUPreference(raw string) (ChromiumGPUPreference, error)

ParseChromiumGPUPreference parses a raw E2E_CHROMIUM_GPU value.

func ResolveChromiumGPUPreference added in v0.57.2

func ResolveChromiumGPUPreference() (ChromiumGPUPreference, error)

ResolveChromiumGPUPreference resolves the launch policy from the process environment. Harnesses call this once per boot.

func (ChromiumGPUPreference) String added in v0.57.2

func (p ChromiumGPUPreference) String() string

String returns the stable log name of the preference.

type ChromiumLaunchPolicy added in v0.57.2

type ChromiumLaunchPolicy struct {
	// contains filtered or unexported fields
}

ChromiumLaunchPolicy carries the resolved E2E_CHROMIUM_GPU preference and the sticky launch choice for one harness boot. The zero value is invalid; use NewChromiumLaunchPolicy.

func NewChromiumLaunchPolicy added in v0.57.2

func NewChromiumLaunchPolicy(le *logrus.Entry) (*ChromiumLaunchPolicy, error)

NewChromiumLaunchPolicy resolves the policy from the environment once per harness boot and logs the chosen preference.

type Generation

type Generation[A any] struct {
	Token    string
	Artifact A
}

Generation pairs a store-owned immutable publication token with its artifact.

type ResolveOptions

type ResolveOptions struct {
	LockDir      string
	LockName     string
	RequireFresh bool
}

ResolveOptions configures the shared artifact resolution policy.

type Shape

type Shape[A any] interface {
	// ContentKey returns the immutable content key to resolve.
	ContentKey(context.Context) (string, error)
	// Lookup returns every validated publication for the content key in
	// preference order. The first publication is the preferred result.
	Lookup(context.Context, string) ([]Generation[A], error)
	// Build produces and publishes one generation for the content key.
	Build(context.Context, string) (Generation[A], error)
}

Shape supplies content identity, validated publication lookup, and artifact building.

Jump to

Keyboard shortcuts

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