Skip to content

Headless Continuous Integration

Randy Hunt edited this page Jan 11, 2014 · 1 revision

If you want to automate Specter, such as on an integration server, you probably want it to run without the GUI.

This is easy to do with Xvfb virtual frame buffer for X.

From Ubuntu, make sure you have xvfb installed:

$ sudo apt-get install xvfb

Specter's exit code returns the number of failures found. Zero when all tests pass. You can check for this exit code on your integration server to determine whether the build should pass or fail.

Then there are a few options for running Specter in xvfb.

Option 1: start Xvfb as a background process

$ Xvfb :99 -screen 0 1280x768x24 &
$ DISPLAY=:99 specter --specter-args ...

If you start xvfb in this way, you will have a hidden process running that must be killed manually later.

Option 2: run Xvfb as a service

$ start-stop-daemon --start --quiet --pidfile $HOME/workspace/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1280x768x24
$ DISPLAY=:99 specter --specter-args ...
$ start-stop-daemon --stop --quiet --pidfile $HOME/xvfb.pid

This gives you more control over the processes that are left running.

Option 3: use xvfb-run to do this for you

$ xvfb-run --server-num=99 --server-args="-screen 0, 1280x768x24" specter --specter-args ...

This is perhaps the easiest and safest method, because there is only one command to run, so there is no risk of failures at any point leaving orphaned processes running on your system.

Note: When run using xvfb-run, exit codes 1-6 could possibly be indications of errors in the xvfb-run command itself, so these exit codes can not be counted on if you need to know the number of failures. However a successful exit code of zero is still trustworthy, so this method is easiest if you only care about pass/fail status.