Skip to content

Commit 415ca8e

Browse files
committed
Use luatest from parent directory if available
Currently, test-run requires luatest to be installed from rocks. It is okay for most tarantool-based projects but it isn't really convenient for tarantool itself: in order to install luatest from rocks, one has to install the tt and tarantool packages because tt will refuse to install anything from rocks if tarantool binary or headers are unavailable. This means that to test a freshly built tarantool, one has to install tarantool first, which sounds strange. True, one can make tt use a freshly built tarantool's binary and headers, but it's tricky. Let's instead make test-run use luatest from the parent directory and ship luatest as a submodule in the main Tarantool repository. Note, that if there's luatest installed from rocks in the current source tree, it will still have a higher priority.
1 parent 93b2d7f commit 415ca8e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

bin/luatest

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
#!/usr/bin/env tarantool
22

3+
--
4+
-- If luatest is present in the parent directory, add it to the search path.
5+
-- This is useful for projects that are shipped with luatest as a submodule.
6+
-- Note that luatest installed from rocks still has a higher priority.
7+
--
8+
local fio = require('fio')
9+
local dir = fio.dirname(fio.abspath(arg[0]))
10+
dir = fio.dirname(dir) -- strip bin/
11+
dir = fio.dirname(dir) -- strip test-run/
12+
dir = fio.pathjoin(dir, 'luatest')
13+
if fio.path.is_dir(dir) then
14+
local luatest_path = dir .. '/?.lua;' .. dir .. '/?/init.lua;'
15+
package.path = luatest_path .. package.path
16+
-- Add luatest to LUA_PATH as well so that it can be used in processes
17+
-- spawned by tests.
18+
os.setenv('LUA_PATH', luatest_path .. (os.getenv('LUA_PATH') or ';'))
19+
end
20+
321
print(('Tarantool version is %s'):format(require('tarantool').version))
422

523
require('luatest.cli_entrypoint')()

0 commit comments

Comments
 (0)