Skip to content

Commit 89da427

Browse files
committed
Not require own test helper when running tests
> Fow what test/helper.lua is needed? Luatest automatically requires `test/helper.lua` file if it's present. Usually, it is used to configure luatest or run any bootstrap code. > What's the problem? To run tarantool functional tests we use the test-run framework [1]. test-run has an integration with luatest (uses luatest as a submodule) and allows us to run tarantool functional tests written in the luatest approach. Most of the such tests can be run via luatest directly, but test-run is used to run all types of tarantool tests at the same time (diff, python, app, luatest). When test-run works, it tunes some environment variables for own needs and sets LUA_PATH to something like this: LUA_PATH='<...>/tarantool/?/init.lua;<...>/tarantool/?.lua;\ <...>/tarantool/test-run/lib/luatest/?/init.lua;\ <...>/tarantool/test-run/lib/luatest/?.lua;;' The tarantool tests don't have own `test/helper.lua` file and this file is required from the luatest submodule of test-run in accordance with the configured LUA_PATH variable, which is obviously wrong. > What's the solution? The simplest way to resolve this issue is to move `test/helper.lua` to `test/helpers/general.lua` to not auto-require it while running tests. Actually, there is no reason to have `test/helper.lua` in luatest. I can assume it was added to run unit tests with `shuffle = 'group'`. But we can run unit tests with the `--shuffle group` option and have the same effect. [1] https://github.com/tarantool/test-run Closes #306
1 parent e6a2093 commit 89da427

20 files changed

+19
-21
lines changed

.github/workflows/test_on_push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
run: make lint
3434

3535
- name: Run tests
36-
run: bin/luatest -v
36+
run: bin/luatest -v --shuffle group

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ add_custom_target(doc
6060
)
6161

6262
add_custom_target(lint DEPENDS bootstrap COMMAND .rocks/bin/luacheck .)
63-
add_custom_target(selftest DEPENDS bootstrap COMMAND bin/luatest)
63+
add_custom_target(selftest DEPENDS bootstrap COMMAND bin/luatest --shuffle group)
6464

6565
add_custom_target(test_with_coverage_report
6666
DEPENDS bootstrap

test/assertions_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local t = require('luatest')
22
local g = t.group()
33

4-
local helper = require('test.helper')
4+
local helper = require('test.helpers.general')
55

66
g.test_custom_errors = function()
77
local function assert_no_exception(fn)

test/autorequire_luatest_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local t = require('luatest')
44
local g = t.group()
55
local Server = t.Server
66

7-
local root = fio.dirname(fio.dirname(fio.abspath(package.search('test.helper'))))
7+
local root = fio.dirname(fio.abspath('test.helpers'))
88
local datadir = fio.pathjoin(root, 'tmp', 'luatest_module')
99
local command = fio.pathjoin(root, 'test', 'server_instance.lua')
1010

test/boxcfg_interaction_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local t = require('luatest')
44
local g = t.group()
55
local Server = t.Server
66

7-
local root = fio.dirname(fio.dirname(fio.abspath(package.search('test.helper'))))
7+
local root = fio.dirname(fio.abspath('test.helpers'))
88
local datadir = fio.pathjoin(root, 'tmp', 'boxcfg_interaction')
99
local command = fio.pathjoin(root, 'test', 'server_instance.lua')
1010

test/capturing_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local t = require('luatest')
22
local g = t.group()
33

4-
local helper = require('test.helper')
4+
local helper = require('test.helpers.general')
55
local Capture = require('luatest.capture')
66
local capture = Capture:new()
77

test/helper.lua renamed to test/helpers/general.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ local t = require('luatest')
22
local Runner = require('luatest.runner')
33
local utils = require('luatest.utils')
44

5-
t.configure({shuffle = 'group'})
6-
75
local helper = {}
86

97
function helper.run_suite(load_tests, args)

test/hooks_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local t = require('luatest')
22
local g = t.group()
33

44
local Capture = require('luatest.capture')
5-
local helper = require('test.helper')
5+
local helper = require('test.helpers.general')
66

77
g.test_hooks = function()
88
local hooks = {}

test/luatest_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local t = require('luatest')
22
local g = t.group()
33

4-
local helper = require('test.helper')
4+
local helper = require('test.helpers.general')
55

66
g.test_assert_returns_velue = function()
77
t.assert_equals(t.assert(1), 1)

test/luaunit/assertions_error_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local t = require('luatest')
22
local g = t.group()
33

4-
local helper = require('test.helper')
4+
local helper = require('test.helpers.general')
55
local assert_failure = helper.assert_failure
66
local assert_failure_equals = helper.assert_failure_equals
77

0 commit comments

Comments
 (0)