Running a Local Build
The main way of testing niri during development is running it as a nested window. The second step is usually switching to a different TTY and running niri there. The easiest way to run a local build as your main compositor is to:Logging Levels
Niri usestracing for logging. Here’s how logging levels are used:
error! - Programming errors and bugs
error! - Programming errors and bugs
Programming errors and bugs that are recoverable. Things you’d normally use
unwrap() for. However, when a Wayland compositor crashes, it brings down the entire session, so it’s better to recover and log an error! whenever reasonable.warn! - Something bad but possible
warn! - Something bad but possible
Something bad but still possible happened. Informing the user that they did something wrong, or that their hardware did something weird, falls into this category. For example, config parsing errors should be indicated with a
warn!.info! - Important normal operation messages
info! - Important normal operation messages
The most important messages related to normal operation. Running niri with
RUST_LOG=niri=info should not make the user want to disable logging altogether.debug! - Less important normal operation
debug! - Less important normal operation
Less important messages related to normal operation. Running niri with
debug! messages hidden should not negatively impact the UX.trace! - Debugging details (compiled out in release)
trace! - Debugging details (compiled out in release)
Everything that can be useful for debugging but is otherwise too spammy or performance intensive.
trace! messages are compiled out of release builds.Tests
We have some unit tests, most prominently for the layout code and for config parsing.- When adding new operations to the layout, add them to the
Openum at the bottom ofsrc/layout/mod.rs(this will automatically include it in the randomized tests) - When adding new config options, include them in the config parsing test
Running Tests
Make sure to runcargo test --all to run tests from sub-crates too.
RUN_SLOW_TESTS variable to run them:
Visual Tests
Theniri-visual-tests sub-crate is a GTK application that runs hard-coded test cases so that you can visually check that they look right. It uses mock windows with the real layout and rendering code.
Visual tests are especially helpful when working on animations.