Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable luatest logging #429

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion lib/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def tap_parse_print_yaml(self, yml):
def check_tap_output(self):
""" Returns is_tap, is_ok, is_skip """
try:
with open(self.tmp_result, 'r') as f:
with open(self.tmp_result, 'r', encoding='utf-8', errors='replace') as f:
ylobankov marked this conversation as resolved.
Show resolved Hide resolved
content = f.read()
tap = pytap13.TAP13()
tap.parse(content)
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def print_tail_n(filename, num_lines=None):
""" Print N last lines of a file. If num_lines is not set,
prints the whole file.
"""
with open(filename, "r") as logfile:
with open(filename, "r", encoding="utf-8", errors="replace") as logfile:
tail_n = collections.deque(logfile, num_lines)
for line in tail_n:
color_stdout(line, schema='tail')
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
Loading