I'm trying to run some tests on Travis CI that require a server that's, err... Not headless. As you can tell, I know so little about the area I don't even know the right terminology to use.
The tests use LibGDX and LWJGL. They work fine on my desktop (Windows 8 and Ubuntu), but unsurprisingly fail in Travis CI:
Could not initialize class org.lwjgl.Sys
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setVSync(LwjglGraphics.java:446)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:118)
Can I do anything with Travis CI to make it think it has a proper display? Even if this is not possible with Travis CI, is there a generic approach that I could perhaps take with another VM I have more control over?
This can be done with xvfb. In your travis.yml, add this:
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
You will have to install xvfb if you don't already have it. You may also have to install the other libs/packages needed by your tests on the VM (for e.g. for web app tests, you would need a browser).
Starting a virtual framebuffer (xvfb) on Travis CI is not enough. If you need OpenGL > 1.4 you also need to install libgl1-mesa-swx11, libgl1-mesa-swx11-dev.
In my travis.yml I setup OpenGL and start xvfb with:
- sudo apt-get install -qq --force-yes mesa-utils libgl1-mesa-swx11 libgl1-mesa-swx11-dev xvfb
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render
the whole file is at: https://github.com/mwohlf/pluto/blob/master/.travis.yml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With