Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis CI - Run LWJGL Tests in Non-Headless Environment?

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?

like image 507
EngineerBetter_DJ Avatar asked Mar 03 '15 16:03

EngineerBetter_DJ


2 Answers

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).

like image 176
GlobalVariable Avatar answered Oct 06 '22 11:10

GlobalVariable


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

like image 32
mwohlf Avatar answered Oct 06 '22 12:10

mwohlf