Chapters

Docs Distribution

Testing and previews

This chapter covers how to test a BifrOSt app and the desktop shell before you publish it. It describes unit tests, host previews, the kit adoption and consistency reports, benchmarks, a test PC or virtual machine, and the logs.

Unit tests

Test an app crate with Cargo, as you would any Rust crate. Run the tests for one app from the springboard workspace:

cd springboard
cargo test --offline -p bifrost-files
cargo test --offline -p bifrost-app

Tests that draw need a font, a symbol set and a bifrost_app::Ui. Many app crates provide a test_ui() helper that loads the system font from the shared assets directory. Copy the helper from an existing app, such as springboard/apps/notes-desktop/src/lib.rs, when you need to test drawing without a device:

pub fn test_ui() -> bifrost_app::Ui {
    use bifrost_app::kit::Font;
    let dir = concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets");
    let data: &'static [u8] = Box::leak(std::fs::read(format!("{dir}/SFUI.ttf")).unwrap().into_boxed_slice());
    let mut ui = bifrost_app::Ui::new(Font::parse(data).unwrap(), 1200.0 / 768.0);
    ui.symbols = springboard::symbols::Symbols::load(dir);
    ui
}

The helper depends on the testkit feature of the springboard crate. App crates enable it on their springboard dependency, as calculator-desktop and notes-desktop do. The feature adds the helpers that the shell and app tests share. It is not part of a release build.

Note

Run the focused tests while you iterate, for example cargo test --offline --lib FILTER for one module. Run the full acceptance for the workspace once per batch of changes, before you publish.

Pinned clock and seed

An app that reads the wall clock, the time zone or a random seed draws a different frame on every run. The testing kit owns the pin, so snapshots stay the same from run to run. Call testing::pin() before the app starts, and use the kit's clock and seed in the app:

testing::pin()
Turns the pin on for this process and the app binaries it starts.
pinned()
True when the pin is on. Branch on it only to swap a live source for a fixture.
unix_secs(), system_time()
The wall clock. Use these instead of SystemTime::now(). When pinned, they return 2025-10-10 12:00:00 UTC.
seed()
A non-zero random seed. When pinned, it is a fixed value. Use it for shuffles and generators.

Monotonic time for animation is not pinned. Compliance tests call pin() first, so Books, Console, Games and Weather draw the same snapshots every run.

Host previews

A host preview runs the real app binary on your development machine and writes a PNG of its window. It needs no compositor and no device. Build the app binary into the fast profile first, because the preview reads the binary from springboard/target/fast:

cd springboard
cargo build --offline --profile fast -p bifrost-files --features springboard/desktop-wayland
cd ..
bifrost pc smoke files --sizes 1200x780 --scale 1.5625
bifrost pc smoke files --light --sizes 1200x780 --scale 1.5625
bifrost pc smoke APP...
Renders each app in the Dark scheme. APP is the app directory name under springboard/apps.
--light
Starts the app in the Light scheme. The file names end in -light.
--sizes WxH,...
A comma-separated list of window sizes in pixels. The default is 1000x720,900x600.
--scale N
Pixels per point. Use 1.0 for a standard display and 2.0 for a 2x display. The default is 1.0.
--out DIR
The output folder. The default is out/pc-app-smoke in the repository.

The preview runs the app in an isolated temporary home and data folder, and connects it over a socket pair. It sends no touches and no playback or recording commands. It does not test the installed sandbox policy, portal support or audio hardware. Check those on a test PC.

The gallery draws every Golden Gate kit widget in both schemes:

bifrost pc gallery /path/to/output

It writes gallery-light.png and gallery-dark.png to the folder. Without an argument it uses /tmp/gallery. The gallery is also an ignored test, preview_sdk_gallery in springboard/sdk/src/widgets.rs, which you can run directly with PREVIEW_DIR set. Run it after every change to a kit widget.

Kit adoption report

The adoption report shows how far each app has moved to the Golden Gate kit:

bifrost pc adoption
bifrost pc adoption --json

For each app under springboard/apps, the report counts four things:

The report counts token names in the source, comments excluded. It measures progress. It does not prove that every pixel follows the scheme. Check that with a preview in both schemes. The adoption plan is in docs/golden-gate-sdk-adoption.md.

Consistency checks

tools/check-app-consistency.py checks every app against the shared design rules. It reads the source and the manifests and needs no build. Each finding has a rule ID:

RuleLevelWhat it checks
MAN-01 to MAN-03ErrorThe manifest has its required keys, architecture is x86_64-linux, and the icon exists.
REL-01 to REL-03ErrorThe app has a CHANGELOG.md with an entry for the manifest version, and Cargo.toml has the same version.
TYP-01, TYP-02ErrorFont sizes are named tokens from render/src/ui.rs. A fit() call measures with the same token the text is drawn with.
SPC-01, SPC-02Error, warningSpacing uses the SPACE_* tokens. Off-grid values are warnings.
LAY-06, LAY-07Error, warningThe top inset comes from bifrost_app::layout::Layout. Large titles use widgets::large_title.
COL-01WarningColours are named constants, not literal pack() or rgba() values.
python3 tools/check-app-consistency.py
Prints the findings. Exits with status 1 when an error is found.
--strict
Makes warnings fail the run too.
--ratchet
Fails only when an app's count for a rule rises above the baseline in tools/app-consistency-baseline.json.
--update-baseline
Records the current counts as the baseline. Use it after you fix findings. Counts may only go down. An app that is not in the baseline must have no findings.

Benchmarks

Benchmarks are ignored tests that print a line in the form BENCH name value ms. tools/bench.py runs them, appends the results to docs/perf-history.jsonl and compares them with the previous run:

python3 tools/bench.py
python3 tools/bench.py --no-record
python3 tools/bench.py --history

The run covers three suites: the glass cost in bifrost-render, the desktop benchmarks in the springboard crate (feature desktop-wayland,testkit, names starting with bench_), and the kit benchmarks in bifrost-ui (names starting with bench_ui_). Each record stores the commit, the system version and the host. A result more than 15 per cent slower than the previous run is marked as a regression.

--no-record prints the results without writing to the history. --history prints the stored results for each benchmark.

Important

A benchmark result is useful only when the conditions match. Compare runs on the same host, with the same build profile and the same windows. Input timing on a device depends on the load on the host that sends the input, so it does not measure input latency by itself.

Test on a PC or a virtual machine

A host preview does not show what the desktop does on hardware. Check the app on a test PC before you publish. Use a physical PC with an Intel GPU, or a virtual machine. The virtual machine harness tools/arch-vm.sh starts an Arch Linux x86_64 guest under QEMU and KVM. The guest runs the shell as the only UI on tty1, through the real KMS path on a virtio GPU.

tools/arch-vm.sh install-deps      # installs qemu, OVMF and arch-install-scripts
tools/arch-vm.sh create            # builds a 6 GB image with pacstrap
tools/arch-vm.sh start --headed    # starts the guest and waits for ssh
tools/arch-vm.sh deploy            # copies the shell, the unit and the assets, then restarts the unit
tools/arch-vm.sh shot home.png     # writes a screenshot to ~/Pictures/tab/
tools/arch-vm.sh tap 640 360       # taps at guest pixels
tools/arch-vm.sh ssh 'journalctl -u springboard -n 30 --no-pager'
tools/arch-vm.sh stop

The guest's ssh is forwarded to 127.0.0.1:2250, set by ARCH_VM_SSH_PORT. The default display is 1200 by 1920 and the default memory is 1 GiB. Set ARCH_VM_MEM=3072 for heavier work. tap, swipe and key take guest coordinates. Key names are QEMU key codes, such as esc or ret.

On a physical test PC, read the screen through the compositor, not through the shell's own geometry. The compositor places windows itself, so a point taken from the shell's state can differ from the same point in a screenshot. Measure the point in the screenshot, relative to the window's top-left corner, and tap in window-local pixels.

Note

A black screenshot means the shell is not drawing. Check the service status and the journal before you assume the harness failed. After a guest kernel update, delete arch.img and run create again. The initramfs is built inside the image.

Drive a running app

Every SDK app on the PC serves JSON-RPC 2.0 on a Unix socket, so a test can read the app's state without a screenshot. Use the bifrost pc control commands:

bifrost pc control list
bifrost pc control info is.olibuijr.notes.desktop
bifrost pc control methods is.olibuijr.notes.desktop
bifrost pc control call is.olibuijr.notes.desktop notes.list '{"query":"milk"}'

The socket is $XDG_RUNTIME_DIR/bifrost/apps/<app-id>.sock. Only the owning user can connect. Every app answers app.info and app.methods. Each app adds its own methods. To add one, implement App::rpc_methods and App::rpc in the app's host crate, and add a host test next to the method. Keep writes on the main thread, through the app's own save path, so they do not race an open editor. See App lifecycle for the App trait.

Logs

Apps write to the system journal through bifrost_app::log, with a subsystem and a category. The API follows os.Logger in Apple's unified logging:

Logger::new(subsystem: &str, category: &str) -> Logger
Creates a logger for a reverse-DNS subsystem such as is.olibuijr.notes, and a category such as sync.
debug(m), info(m), notice(m), error(m), fault(m)
Writes a message at that level. Debug messages are dropped unless the subsystem's level allows them.
enabled(level) -> bool
Tells you whether a level is written, so you can skip building an expensive message.

An app declares its subsystems in manifest.toml with [[log.subsystem]] entries. The shell builds a registry from those entries at install time. Overrides are kept in /etc/bifrost/log.toml. Read the logs with bifrost-log:

bifrost-log show --subsystem is.olibuijr.notes.desktop --last 1h
bifrost-log stream --level debug
bifrost-log config --subsystem is.olibuijr.notes.desktop --level debug
bifrost-log subsystems

show and stream accept --subsystem, --category, --process, --level, --last, --limit and --contains. The Console system app shows the same log in a window, with search and streaming. Level names are debug, info, notice, error and fault.

Note

Log values that you do not want stored in clear text can be wrapped with bifrost_app::log::private(). They are redacted unless the subsystem turns on private with bifrost-log config --private on.

App compliance gate

Every app in springboard/apps must stay compliant with the SDK, the Golden Gate kit and the design rules. The gate has two halves. A static check reads each app's source and manifest. A runtime test starts the real app and checks what it draws. Acceptance runs both. Each app's findings are held to a ratchet: the count can go down, and a rise fails the run.

Static rules

Every finding has a rule ID, a file and line, and a fix. The prefixes group the rules:

PrefixChecksExample fix
GGGolden Gate chrome: full-size windows, toolbars, search fields, sidebars, path barsDraw the toolbar with widgets::toolbar_band
COLColours: named constants, scheme tokens that follow Light and DarkUse a Pair token with .now()
TYP, LAYType sizes, radii, spacing and layout that assume one screenUse a MAC_*_PT token, or derive the size from the window
APPManifest, icon, CHANGELOG and version, architecture, permissionsBump manifest.toml and Cargo.toml together
RESThreads and termination: use dispatch, sudden termination when there is no unsaved stateUse DispatchQueue::global(Qos::Utility)
CHRMenus that repeat the shell's File, Edit, View, Window or HelpGive app menus their own titles
SDK, TSTDeprecated SDK items, and the compliance test fileUse the replacement named in the item

The icon rule APP-10 needs the app icon as a square 180 by 180 PNG. The gate reads the PNG header only, so no re-encoding is needed.

A rule can be accepted in place with // compliance-allow: RULE reason on its line or the line above. Fixing is preferred, and a reviewer reads each reason. Each app gets a score from 100 less a penalty per rule. The baseline file records the count per app and rule, and the default run fails only when an app gets worse than the baseline.

python3 tools/check-app-compliance.py
The ratchet. This is the form acceptance runs.
--app DIR
One app, with its findings. A directory name is enough, such as notes-desktop.
--strict, --json
Fails on any finding, or prints the findings as JSON for tools.
--update-baseline --write-doc
Records the fixes after you have made them. Never use it to hide a regression.

Runtime test

Each app has a tests/compliance.rs, generated from a template. It starts the real app binary through the app host, with no compositor and no GPU. It runs at 1200 by 780 points, at scale 1.0 and 1.5625, in Light and Dark, and checks:

KNOWN_GAPS at the top of each test file lists the checks that fail today. They print as known gap and do not fail. Delete an id when the app is fixed, so the list only shrinks.

Note

Set COMPLIANCE_SOFT=1 to print failures without failing, for triage. Set BIFROST_BLESS=1 to accept new goldens, then look at the PNGs in both schemes before you commit them.

After an SDK, kit or render change

--changed-sdk lists every app that uses a public item changed under springboard/sdk, render, ui or proto since the base branch, with the test command for each:

python3 tools/check-app-compliance.py --changed-sdk --base main

Run those tests, and review or bless their goldens in the same change as the SDK edit.

Run it before you publish

For an app you changed:

python3 tools/check-app-compliance.py --app springboard/apps/notes-desktop
cd springboard
cargo test --offline --profile fast -p bifrost-notes --test compliance

Fix the findings, look at the host previews in both schemes, and run the ratchet with --update-baseline --write-doc so the new counts are recorded. Then run the whole gate once for the batch:

python3 tools/check-app-compliance.py
cargo test --offline --profile fast --workspace --no-fail-fast compliance

bifrost pc acceptance runs the same ratchet and the runtime tests for every app. A failure there stops the batch before it is published.

Before you publish

Run these checks in order before you publish an app or a system release. The release steps are in Publishing.

  1. Run the focused unit tests for each crate you changed, for example cargo test --offline -p bifrost-files.
  2. Build the app into the fast profile and render a host preview in both schemes: bifrost pc smoke APP and bifrost pc smoke APP --light.
  3. If you changed the kit, run bifrost pc gallery and bifrost pc adoption.
  4. Run python3 tools/check-app-compliance.py and the compliance test of each app you changed. See App compliance gate. Both must pass before you publish.
  5. Check the app on a test PC, with a screenshot in both schemes, against the rules in the Human Interface checklist.
Important

Check the build profile before you publish with --skip-build. A shell built without --features desktop-wayland does not start on a desktop. It reports a busy display card and exits. Build with cargo build --profile fast --features desktop-wayland --bin shell first.