Skip to content

Commit 0a504ff

Browse files
author
Oleg Chaplashkin
committed
test: ban direct calling of box.cfg()
Direct call and configuration of the runner instance is prohibited. Now if you need to test something with specific configuration use a server instance please (see luatest.Server module). In-scope-of tarantool/luatest#245 NO_DOC=ban calling box.cfg NO_TEST=ban calling box.cfg NO_CHANGELOG=ban calling box.cfg
1 parent 0ef5e3b commit 0a504ff

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

test/helper.lua

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- There are situations when the Tarantool instance is configured
2+
-- for testing. For example:
3+
--
4+
-- g.test_foo = function()
5+
-- box.cfg{params}
6+
-- ...
7+
-- t.assert_equals(foo, bar)
8+
--
9+
-- g.test_bar = function()
10+
-- t.assert_equals(foo, bar)
11+
--
12+
-- We expect that the test environment will not be configured
13+
-- in the `test_bar`, but this will not always be the case
14+
-- (depends on the order of execution of tests).
15+
-- We prohibit a direct call to `box.cfg` by overriding the
16+
-- `__call` meta method.
17+
box.cfg = setmetatable({}, {__call = function()
18+
error('A direct call to `box.cfg` is not recommended' ..
19+
' (you are changing the test runner instance)', 0) end})

test/metrics-luatest/helper.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,10 @@ local function workaround_requires(path)
109109
end
110110

111111
workaround_requires('test.utils')
112-
workaround_requires('test.psutils_linux_test_payload')
112+
113+
require('test.utils')
114+
local test_root = fio.dirname(fio.dirname(fio.abspath(package.search('third_party.metrics.test.utils'))))
115+
116+
package.loaded['test.utils'].LUA_PATH = os.getenv('LUA_PATH') ..
117+
test_root .. '/?.lua;' ..
118+
test_root .. '/?/init.lua;'

0 commit comments

Comments
 (0)