Skip to content

Commit 90db2d5

Browse files
test: workaround LUA_PATH only for repo tests
luatest implicitly requires `test.helper` package in the beginning of a test run, if there is a package. We use the assumption that `test.helper` package exist and required to find the module root in `cfg_test` in tarantool/metrics. These tests are also included in tarantool/tarantool repo as a submodule. Paths are workarounded before the run [1] so we can reuse existing tests and not rewrite them. But `test.helper` path is not workarounded since we do not need this file. Moreover, we shouldn't use it in tarantool/tarantool since it asserts that non-built-in package is used, while we test built-in one there. But tarantool/tarantool tests actually use `test.helper` to find the root in `cfg_test`. It had worked for tarantool/tarantool tests before because, in fact, we had used luatest `test.helper` package to find the root (and, for some reason, it was fine). After [2], there is no luatest `test.helper` anymore and root search fails [3]. This patch makes `cfg_test` to set LUA_PATH to `nil` if we're testing built-in package in tarantool/tarantool since we don't need any rock files. 1. https://github.com/tarantool/tarantool/blob/13159230cfd9ec46b93ad7e6185a3204e27b5b50/test/metrics-luatest/helper.lua#L111-L112 2. tarantool/luatest#307 3. tarantool/tarantool#8683 (comment) Closes #456
1 parent 8292468 commit 90db2d5

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

test/cfg_test.lua

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
local t = require('luatest')
22
local group = t.group('cfg')
33

4-
local fio = require('fio')
5-
64
local metrics = require('metrics')
75
local utils = require('test.utils')
86

9-
local root = fio.dirname(fio.dirname(fio.abspath(package.search('test.helper'))))
10-
117
local function create_server(g)
128
g.server = t.Server:new({
139
alias = 'myserver',
1410
env = {
15-
LUA_PATH = root .. '/?.lua;' ..
16-
root .. '/?/init.lua;' ..
17-
root .. '/.rocks/share/tarantool/?.lua'
11+
LUA_PATH = utils.LUA_PATH
1812
}
1913
})
2014
g.server:start{wait_until_ready = true}

test/helper.lua

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ require('test.rock_utils').assert_nonbuiltin('metrics')
66

77
local fio = require('fio')
88
local utils = require('test.utils')
9+
10+
local root = fio.dirname(fio.dirname(fio.abspath(package.search('test.utils'))))
11+
12+
package.loaded['test.utils'].LUA_PATH = root .. '/?.lua;' ..
13+
root .. '/?/init.lua;' ..
14+
root .. '/.rocks/share/tarantool/?.lua'
15+
916
local t = require('luatest')
1017
local ok, cartridge_helpers = pcall(require, 'cartridge.test-helpers')
1118
if not ok then

test/utils.lua

+5
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,9 @@ function utils.fflush_main_server_output(server, capture)
137137
return captured
138138
end
139139

140+
141+
-- Empty by default. Empty LUA_PATH satisfies built-in package tests.
142+
-- For tarantool/metrics, LUA_PATH is set up through test.helper
143+
utils.LUA_PATH = nil
144+
140145
return utils

0 commit comments

Comments
 (0)