Skip to content

Commit

Permalink
Add the ability to set the path to the exe file
Browse files Browse the repository at this point in the history
You can set an additional argument `--executable` (string) for the
test-run. This parameter sets a fixed path to the executable file.

Example usage:

$ ./test-run.py --executable /foo/bar/tarantool - a new behavior. The
path to the executable file will be "/foo/bar/tarantool".

Closes #400
  • Loading branch information
ochaplashkin committed Jul 24, 2023
1 parent 6a5192f commit d85fcca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/__init__.py
Expand Up @@ -83,7 +83,7 @@ def module_init():

prepend_path(os.path.join(os.environ['TEST_RUN_DIR'], 'lib/luatest/bin'))

TarantoolServer.find_exe(args.builddir)
TarantoolServer.find_exe(args.builddir, executable=args.executable)
UnittestServer.find_exe(args.builddir)
AppServer.find_exe(args.builddir)
LuatestServer.find_exe(args.builddir)
Expand Down
12 changes: 12 additions & 0 deletions lib/options.py
Expand Up @@ -493,6 +493,18 @@ def __init__(self):
$ . <(./test/test-run.py --env)
"""))

parser.add_argument(
'--executable',
dest='executable',
default=None,
help=format_help(
"""
Set the custom path to the Tarantool executable.
It is useful if you need to test a custom build
with a different directory structure.
"""))

# XXX: We can use parser.parse_intermixed_args() on
# Python 3.7 to understand commands like
# ./test-run.py foo --exclude bar baz
Expand Down
4 changes: 2 additions & 2 deletions lib/tarantool_server.py
Expand Up @@ -694,14 +694,14 @@ def __init__(self, _ini=None, test_suite=None):
self.current_test = caller_globals['test_run_current_test']

@classmethod
def find_exe(cls, builddir, silent=True):
def find_exe(cls, builddir, silent=True, executable=None):
cls.builddir = os.path.abspath(builddir)
builddir = os.path.join(builddir, "src")
path = builddir + os.pathsep + os.environ["PATH"]
color_log("Looking for server binary in ", schema='serv_text')
color_log(path + ' ...\n', schema='path')
for _dir in path.split(os.pathsep):
exe = os.path.join(_dir, cls.default_tarantool["bin"])
exe = executable if executable else os.path.join(_dir, cls.default_tarantool["bin"])
ctl_dir = cls.TEST_RUN_DIR
ctl = os.path.join(ctl_dir, cls.default_tarantool['ctl'])
need_lua_path = False
Expand Down

0 comments on commit d85fcca

Please sign in to comment.