Skip to content

Development ​

Gates ​

nix develop .#lib enters the dev shell; just lists recipes. Repository-wide recipes, the Nix layout, CI and releases are in Developing lys. just gates runs the gates:

RecipeRuns
just fmt-checkFormatting check (gofumpt, gci)
just checkvet, lint, no-fused, test, build
just raceTests under the race detector
just gpuGPU tests on lavapipe
just headlessCapture and virtual input tests against a private headless sway

Other recipes:

RecipeRuns
just fmtFormat Go sources
just gpu-hostEvery GPU path on the host's GPU under the validation layer, including the encoder and dmabuf capture
just docker [recipe] [memory]A recipe (default gates, memory 10g) in a container with the dev shell's store paths, the checkout, GPU render nodes and host drivers, but no display, session bus or runtime dir
just generateRebuild shaders, Wayland bindings and keysym tables
just goldensRewrite render goldens (UPDATE_GOLDEN=1)
just svg-refsRasterize SVG references with rsvg-convert
just benchBenchmarks
just test-env, just test-env-stopStart or stop the headless sway test session

On Intel GPUs Mesa's ANV driver exposes Vulkan Video decoding only with ANV_DEBUG=video-decode (Mesa 26.2.5): run ANV_DEBUG=video-decode just gpu-host there, or the decode tests skip for want of a decoding device.

nix fmt formats Nix files with alejandra.

Determinism ​

Rendering, typesetting, animation and styling produce identical bits on every architecture, so one golden serves all. Two rules enforce this:

  • Go may fuse x*y + z into an FMA (arm64 does, amd64 does not). Write float64(x*y) + z wherever a product, or a division by a constant power of two, feeds an addition or subtraction, including across statements. just no-fused compiles for arm64 and fails on any FMA instruction.
  • Use gomath for trigonometry, exponentials, logarithms, Pow, Cbrt, Hypot, Erf and Erfc. The linter rejects math's versions outside tests.

No work at import ​

Importing a package runs no code: a program pays for what it uses, not for what it links. A package that lys-ui links, vendored copies included, carries

go
func TestImportingCostsNothing(t *testing.T) { testbuild.RequireNoInit(t) }

which fails when the package, or a test file in it, has an init function or a package-level variable the compiler cannot lay out statically: a map, a call (regexp.MustCompile, fmt.Errorf, reflect.TypeFor, maphash.MakeSeed), a computed table, a slice of another variable. Write a switch or a static array in place of a small map, a constant in place of a computed one (with a test holding it to its formula), and build the rest on first use behind a sync.Once in a struct beside its value.

Test support ​

Importable by the tests of every lys component.

PackagePurpose
goldenCompares pixels against committed PNG goldens, exact by default. A missing golden fails. Reference compares against another renderer's output within a Tolerance. UPDATE_GOLDEN=1 rewrites goldens
gputestSelects the GPU tests' Vulkan driver from LYS_TEST_GPU: lavapipe for Mesa's CPU driver, host for the host's GPU (failing, with the devices it found, when the loader offers only CPU devices); any other value is an error; unset runs where a device exists and skips elsewhere
wltestPrivate runtime dir, loopback display for wire-level tests, fake linux-dmabuf feedback, and a client that shows solid-colour surfaces on the headless compositor (LYS_TEST_HEADLESS)
pipewire/pwtestPrivate PipeWire daemon and libpipewire reference consumers
eis/eistestlibei reference client for EIS servers
dbustestPrivate dbus-daemons configured from a generated file; needs only dbus-daemon on PATH. NewPipe is a descriptor to send whose RequireEveryCopyClosed fails the test while any copy the bus handed out is still open
pulse/pulsetestA fake PulseAudio server speaking the native protocol, with scriptable devices, streams and failures; a client's own streams go with its connection
logind/logindtestA fake systemd-logind on a dbustest bus that records every call and emits logind's signals; its helpers report with t.Errorf, so hooks on other goroutines may call them
polkit/polkittestA fake polkitd Authority on a dbustest bus: scripted or held authorization checks, agent registrations, actions and temporary authorizations, every check and cancel recorded
peercred/peercredtestA socket peer that is another process, with its own pid and lifetime: the test binary run again through Run in the package's TestMain, or Main inside testhome.Main
wallclock/wallclocktestSetZone replaces a zone file the way timedated does, with a fixed zone of a given name and offset, for a wallclock.SystemClock watching it
sockdirA directory short enough for Unix socket paths (sun_path is 108 bytes)
testhomeRuns a test binary against a scratch home and no session but its own: Run (or Main) in TestMain moves HOME and the XDG per-user directories, unsets the variables that advertise a compositor, display or media server, and pins the session bus, the system bus and the sound server to sockets only a test's own fake serves, keeping the go command's caches and a recipe's headless session (LYS_TEST_HEADLESS). RequireNoHostSession, called from one test per package, fails where a host endpoint is still within reach

A package whose tests build applications, dial a bus or connect to a display isolates itself with both halves:

go
func TestMain(m *testing.M) { testhome.Run(m) }

func TestTheTestsReachNoHostSession(t *testing.T) { testhome.RequireNoHostSession(t) }

A test that needs a bus starts its own (dbustest) and points the process at it (UseAsSessionBus, UseAsSystemBus). A test binary an isolated test starts again, as a helper or as the program under test, keeps the environment its parent gave it.

A recipe that boots a session for the tests, a headless compositor or a VM's login, exports LYS_TEST_SESSION with that session's runtime directory. Main then leaves the session in place, and the guard holds the runtime directory, the buses, the sound server and the display to exactly that directory or the test home, wherever it lies; a session bus the recipe did not name is pinned to an absent socket. Without the variable a session in /run/user/<uid> is the host's and fails the guard.

Released under the MIT License.