Skip to content

Commit cdc6a72

Browse files
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 abcafcf commit cdc6a72

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

queue/testdata/config.lua

+25
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

+25
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)