Skip to content

Commit

Permalink
Enable luatest logging
Browse files Browse the repository at this point in the history
If the test fails and there is a luatest log file (`run.log` by default)
you'll see the following output:

 - [box-luatest/varbinary_test.lua, null]
  # logfile:         /tmp/t/log/031_box-luatest.log
  # luatest logfile: /tmp/t/031_box-luatest/run.log
  # reproduce file:  /tmp/t/reproduce/031_box-luatest.list.yaml

Closes #427
  • Loading branch information
Oleg Chaplashkin committed Jun 11, 2024
1 parent 8ea4e71 commit 9727b6c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/luatest_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def __init__(self, *args, **kwargs):
def execute(self, server):
"""Execute test by luatest command
Execute `luatest -c --no-clean --verbose <name>_test.lua --output tap`
command. Disable capture mode and deletion of the var directory.
Provide a verbose output in the tap format. Extend the command by
`--pattern <pattern>` if the corresponding option is provided.
Execute `luatest -c --no-clean --verbose <name>_test.lua --output tap --log <path>`
command. Disable capture mode and deletion of the var directory. Provide a verbose
output in the tap format. Extend the command by `--pattern <pattern>` if the
corresponding option is provided.
"""
server.current_test = self
script = os.path.join(os.path.basename(server.testdir), self.name)
Expand All @@ -51,6 +51,8 @@ def execute(self, server):
command.extend([server.luatest])
# Add luatest command-line options.
command.extend(['-c', '--no-clean', '--verbose', script, '--output', 'tap'])
# Add luatest logging option.
command.extend(['--log', os.path.join(server.vardir, 'run.log')])
if Options().args.pattern:
for p in Options().args.pattern:
command.extend(['--pattern', p])
Expand Down
10 changes: 10 additions & 0 deletions lib/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ def get_reproduce_file(worker_name):
return os.path.join(reproduce_dir, '%s.list.yaml' % worker_name)


def get_luatest_logfile(worker_name):
# Luatest logging is only for LuatestServer workers.
# It doesn't always guarantee a log file.
# If it doesn't exist, it will return None.
if 'luatest' in worker_name:
path = os.path.join(main_vardir(), worker_name, 'run.log')
if os.path.isfile(path):
return path


def print_greetings():
# print information about tarantool
color_stdout('\n')
Expand Down
4 changes: 4 additions & 0 deletions listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from lib.worker import WorkerOutput
from lib.worker import WorkerTaskResult
from lib.worker import get_reproduce_file
from lib.worker import get_luatest_logfile
from lib.utils import prefix_each_line
from lib.utils import safe_makedirs
from lib.utils import print_tail_n
Expand Down Expand Up @@ -161,6 +162,9 @@ def print_tasks_info(self, tasks):
task_id_str = yaml.safe_dump(task_id, default_flow_style=True)
final_report('- %s' % task_id_str, schema='test_var')
color_stdout('# logfile: %s\n' % logfile)
luatest_logfile = get_luatest_logfile(worker_name)
if luatest_logfile:
color_stdout('# luatest logfile: %s\n' % luatest_logfile)
reproduce_file_path = get_reproduce_file(worker_name)
color_stdout('# reproduce file: %s\n' % reproduce_file_path)
if show_reproduce_content:
Expand Down

0 comments on commit 9727b6c

Please sign in to comment.