Documentation
¶
Overview ¶
Package devlock gives one tb process at a time a device: an Android device or emulator, or an iOS simulator. Two runners on one device replace each other's on-device agent and drive the same screen: both fail in confusing ways. So every tb process that drives a device (`tb test` for the devices its run uses, the daemon for a `tb open` / `tb do` session) holds the device's lock, and a second one is told who has it instead of going ahead.
A lock is an flock(2) (LockFileEx on Windows) on a file per device in a machine-wide folder (~/.testbuddy/locks, or TB_LOCK_DIR): the system drops it when the holding process exits, however it exits, so a crashed or killed run never leaves a device locked. The file also holds who locked it (the command, pid, folder, start time), shown to whoever finds the device taken. Browsers need no lock: each run starts its own.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Lock ¶
type Lock struct {
Serial string
// contains filtered or unexported fields
}
Lock is a held device lock.
func Acquire ¶
Acquire takes the device's lock, waiting up to wait for its holder to let go (0: not at all). It checks again every poll: a lock held by another process sends no event when it goes. A cancelled ctx ends the wait at once with ctx's error, holding no lock (issue #115). tb itself does not call it: `tb test --wait-for-device` waits in orchestrate's Pool.
func TryAcquire ¶
TryAcquire takes the device's lock at once, or returns a *Busy naming who holds it.
type Owner ¶
type Owner struct {
PID int `json:"pid"`
What string `json:"what"` // e.g. "tb test flows/login.yaml", "tb session alice"
Dir string `json:"dir,omitempty"`
Since time.Time `json:"since"`
Command string `json:"command,omitempty"` // the holder's full command line
}
Owner says who holds a device.