Skip to content

Commit fa77b0e

Browse files
committed
If running inside Travis, assume we have Xfvb running, change DISPLAY to :99
Based on https://www.electronjs.org/docs/tutorial/testing-on-headless-ci#travis-ci
1 parent aef2c2e commit fa77b0e

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ language: c
22
compiler:
33
- gcc
44
- clang
5+
addons:
6+
apt:
7+
packages:
8+
- xvfb
9+
install:
10+
- export DISPLAY=':99.0'
11+
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
512
env:
613
-
714
- USE_XFT=0

test/integration/runtests.lua

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
--# on Debian in lua-posix
2-
local basedir = "../../"
32

43
print("[TESTING] Integration")
54

5+
local running_on_travis = os.getenv('TRAVIS')
6+
local notion_binary = "../../notion/notion"
7+
local notionflux_binary = "../../mod_notionflux/notionflux/notionflux"
8+
if running_on_travis then
9+
print('TRAVIS detected')
10+
-- notion_binary = "/usr/local/bin/notion"
11+
-- notionflux_binary = "/usr/local/bin/notionflux"
12+
end
13+
614
local success, posix = pcall(require, "posix")
715
if not success then
816
print("[ERROR] posix module not found")
@@ -34,16 +42,20 @@ local function find_in_path(file)
3442
return false
3543
end
3644

37-
print('Running tests against ' .. basedir .. 'notion/notion')
45+
print('Running tests against ' .. notion_binary)
3846

3947
local xpid = posix.fork()
4048
if (xpid == 0) then
49+
if running_on_travis then
50+
print('TRAVIS should have Xfvb running')
51+
os.exit(1)
52+
end
4153
local xorg_binary = find_in_path("Xorg")
4254
if xorg_binary == false then
4355
print('Error launching Xorg dummy, Xorg binary not found')
4456
end
4557
print('Starting Xorg dummy: ' .. xorg_binary)
46-
local result,errstr,errno = posix.exec(xorg_binary, "-noreset", "+extension", "GLX", "+extension", "RANDR", "+extension", "RENDER", "-logfile", "./10.log", "-config", "./xorg.conf", ":7")
58+
local result,errstr,errno = posix.exec(xorg_binary, "-noreset", "+extension", "GLX", "+extension", "RANDR", "+extension", "RENDER", "-logfile", "./99.log", "-config", "./xorg.conf", ":99")
4759
print('Error replacing current process with Xorg dummy: ' .. errstr)
4860
os.exit(1)
4961
end
@@ -56,13 +68,13 @@ local errors = 0
5668
for i,testset in ipairs(testsets) do
5769
posix.setenv('HOME', testset);
5870

59-
os.execute("rm -rf " .. testset .. "/.notion/default-session--7")
71+
os.execute("rm -rf " .. testset .. "/.notion/default-session--99")
6072

6173
print('Starting notion in ./' .. testset .. '...')
6274

6375
local notionpid = posix.fork()
6476
if (notionpid == 0) then
65-
local result,errstr,errno = posix.exec(basedir .. "notion/notion", "-noerrorlog", "-display", ":7")
77+
local result,errstr,errno = posix.exec(notion_binary, "-noerrorlog", "-display", ":99")
6678
print('Error replacing current process with notion: ' .. errstr)
6779
os.exit(1)
6880
end
@@ -71,7 +83,7 @@ for i,testset in ipairs(testsets) do
7183

7284
for test in getTests(testset) do
7385
print('[TEST] ' .. test)
74-
local testoutputpipe = io.popen("cat " .. test .. " | DISPLAY=:7 " .. basedir .. "mod_notionflux/notionflux/notionflux")
86+
local testoutputpipe = io.popen("cat " .. test .. " | DISPLAY=:99 " .. notionflux_binary)
7587
local testoutput = testoutputpipe:read("*a")
7688
local okend = "\"ok\"\n"
7789
if(testoutput == "" or testoutput:sub(-#okend) ~= okend) then

0 commit comments

Comments
 (0)