Skip to content

Commit 3f13533

Browse files
DifferentialOrangeylobankov
authored andcommitted
coverage: support tarantool binary with a suffix
Fix collecting coverage if tarantool binary has a suffix. For example, binaries installed with `tt install` always have a suffix and non-suffix symlink for an active binary (luatest resolves symlinks while working with a command). Closes #311
1 parent 4aecd8e commit 3f13533

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
when a server fails to start due to bad configuration.
5252
- Save server artifacts (logs, snapshots, etc.) if the test fails.
5353
- Group working directories of servers inside a replica set into one directory.
54+
- Fix collecting coverage if tarantool binary has a suffix.
5455

5556
## 0.5.7
5657

luatest/server.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function Server:initialize()
169169
table.insert(self.args, 3, self.command)
170170
self.command = arg[-1]
171171
-- If command is tarantool, add `-l luatest.coverage`
172-
elseif self.command:endswith('/tarantool') then
172+
elseif utils.is_tarantool_binary(self.command) then
173173
if not fun.index('luatest.coverage', self.args) then
174174
table.insert(self.args, 1, '-l')
175175
table.insert(self.args, 2, 'luatest.coverage')
@@ -248,7 +248,7 @@ function Server:start(opts)
248248
local args = table.copy(self.args)
249249
local env = table.copy(os.environ())
250250

251-
if not command:endswith('/tarantool') then
251+
if not utils.is_tarantool_binary(self.command) then
252252
-- When luatest is installed as a rock, the internal server_instance.lua
253253
-- script won't have execution permissions even though it has them in the
254254
-- source tree, and won't be able to be run while a server start. To bypass

luatest/utils.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,8 @@ function utils.version_ge(version1, version2)
182182
end
183183
end
184184

185+
function utils.is_tarantool_binary(path)
186+
return path:find('^.*/tarantool[^/]*$') ~= nil
187+
end
188+
185189
return utils

test/utils_test.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
local t = require('luatest')
2+
local g = t.group()
3+
4+
local utils = require('luatest.utils')
5+
6+
g.test_is_tarantool_binary = function()
7+
local cases = {
8+
{'/usr/bin/tarantool', true},
9+
{'/usr/local/bin/tarantool', true},
10+
{'/usr/local/bin/tt', false},
11+
{'/usr/bin/ls', false},
12+
{'/home/myname/app/bin/tarantool', true},
13+
{'/home/tarantool/app/bin/go-server', false},
14+
{'/usr/bin/tarantool-ee_gc64-2.11.0-0-r577', true},
15+
{'/home/tarantool/app/bin/tarantool', true},
16+
{'/home/tarantool/app/bin/tarantool-ee_gc64-2.11.0-0-r577', true},
17+
}
18+
19+
for _, case in ipairs(cases) do
20+
local path, result = unpack(case)
21+
t.assert_equals(utils.is_tarantool_binary(path), result,
22+
("Unexpected result for %q"):format(path))
23+
end
24+
end

0 commit comments

Comments
 (0)