This wrapper script can be used instead of executing "blender"
to launch blender in it's own display server which is closed
when Blender quits.
The BLENDER_BIN environment variable is used to run Blender,
forwarding arguments & passing the exit-code back to the script.
This can be used to run automated graphical-tests while still being
in background (from a user perspective).
This has the advantage that windows don't popup in the foreground,
or on servers/VM's that aren't running a graphical session.
Running many Blender instances, each in their own display server
is also supported, allowing for tests to make use of multiple jobs.
Tested with graphical undo tests which have not yet been made part of
CTests (needs further investigation).
Currently this only supports WAYLAND however it can run on X11
since it launches it's own WAYLAND compositor instance for each
Blender session. The wrapper has been written with the intention of
adding support for other back-ends in the future (if practical).
Use the WESTON compositor since it's widely available and has a
headless server, any other WAYLAND-server could likely be used without
much trouble.
These programs don't run as part of automated tests but can be useful
utilities for developers to expose issues or bisecting
(in the case of event simulation).