Skip to content

Commit 3dc36de

Browse files
DifferentialOrangeoleg-jukovec
authored andcommitted
test: configure module paths for queue init
Set up package paths so queue test instances could be run with arbitrary work_dir. Part of #215
1 parent 61ebbeb commit 3dc36de

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ clean:
2222

2323
.PHONY: deps
2424
deps: clean
25-
( cd ./queue; tarantoolctl rocks install queue 1.2.1 )
25+
( cd ./queue/testdata; tarantoolctl rocks install queue 1.2.1 )
2626

2727
.PHONY: datetime-timezones
2828
datetime-timezones:

queue/testdata/config.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
-- configure path so that you can run application
2+
-- from outside the root directory
3+
if package.setsearchroot ~= nil then
4+
package.setsearchroot()
5+
else
6+
-- Workaround for rocks loading in tarantool 1.10
7+
-- It can be removed in tarantool > 2.2
8+
-- By default, when you do require('mymodule'), tarantool looks into
9+
-- the current working directory and whatever is specified in
10+
-- package.path and package.cpath. If you run your app while in the
11+
-- root directory of that app, everything goes fine, but if you try to
12+
-- start your app with "tarantool myapp/init.lua", it will fail to load
13+
-- its modules, and modules from myapp/.rocks.
14+
local fio = require('fio')
15+
local app_dir = fio.abspath(fio.dirname(arg[0]))
16+
package.path = app_dir .. '/?.lua;' .. package.path
17+
package.path = app_dir .. '/?/init.lua;' .. package.path
18+
package.path = app_dir .. '/.rocks/share/tarantool/?.lua;' .. package.path
19+
package.path = app_dir .. '/.rocks/share/tarantool/?/init.lua;' .. package.path
20+
package.cpath = app_dir .. '/?.so;' .. package.cpath
21+
package.cpath = app_dir .. '/?.dylib;' .. package.cpath
22+
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.so;' .. package.cpath
23+
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.dylib;' .. package.cpath
24+
end
25+
126
local queue = require('queue')
227
rawset(_G, 'queue', queue)
328

queue/testdata/pool.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
-- configure path so that you can run application
2+
-- from outside the root directory
3+
if package.setsearchroot ~= nil then
4+
package.setsearchroot()
5+
else
6+
-- Workaround for rocks loading in tarantool 1.10
7+
-- It can be removed in tarantool > 2.2
8+
-- By default, when you do require('mymodule'), tarantool looks into
9+
-- the current working directory and whatever is specified in
10+
-- package.path and package.cpath. If you run your app while in the
11+
-- root directory of that app, everything goes fine, but if you try to
12+
-- start your app with "tarantool myapp/init.lua", it will fail to load
13+
-- its modules, and modules from myapp/.rocks.
14+
local fio = require('fio')
15+
local app_dir = fio.abspath(fio.dirname(arg[0]))
16+
package.path = app_dir .. '/?.lua;' .. package.path
17+
package.path = app_dir .. '/?/init.lua;' .. package.path
18+
package.path = app_dir .. '/.rocks/share/tarantool/?.lua;' .. package.path
19+
package.path = app_dir .. '/.rocks/share/tarantool/?/init.lua;' .. package.path
20+
package.cpath = app_dir .. '/?.so;' .. package.cpath
21+
package.cpath = app_dir .. '/?.dylib;' .. package.cpath
22+
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.so;' .. package.cpath
23+
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.dylib;' .. package.cpath
24+
end
25+
126
local queue = require('queue')
227
rawset(_G, 'queue', queue)
328

0 commit comments

Comments
 (0)