Skip to content

Commit fe1d6dc

Browse files
author
Oleg Chaplashkin
committed
Redirect luatest stderr to stdout with new option
By default, test-run captures the stderr stream and redirects its to the log file: $ cat /tmp/t/001_foo-luatest/foo_test.log: [001] Some error log [001] My warning log ... Use the new option `--show-capture` (abbr. `-c`) to redirect stderr to stdout. Use it instead of the deprecated `--verbose` option. The `--verbose` option will be ignored and output: Argument ['--verbose'] is deprecated and is ignored. Close tarantool/luatest#308
1 parent 8ebb3aa commit fe1d6dc

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

lib/luatest_server.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ def execute(self, server):
6262
project_dir = os.environ['SOURCEDIR']
6363

6464
with open(server.logfile, 'ab') as f:
65-
proc = Popen(command, cwd=project_dir, stdout=sys.stdout, stderr=f)
65+
stderr = f
66+
if Options().args.show_capture:
67+
stderr = sys.stdout
68+
proc = Popen(command, cwd=project_dir, stdout=sys.stdout, stderr=stderr)
6669
sampler.register_process(proc.pid, self.id, server.name)
6770
test_timeout = Options().args.test_timeout
6871
timer = Timer(test_timeout, timeout_handler, (proc, test_timeout))

lib/options.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ def format_help(s):
3737
return textwrap.dedent(s.lstrip('\n')) + '\n'
3838

3939

40+
class DeprecationWarning(argparse._StoreTrueAction):
41+
"""Сustom definition of the 'store_true' procedure"""
42+
43+
def __call__(self, parser, namespace, values, option_string=None):
44+
color_stdout(
45+
"Argument %s is deprecated and is ignored.\n" % self.option_strings,
46+
schema='info'
47+
)
48+
setattr(namespace, self.dest, values)
49+
50+
4051
class Options(object):
4152
"""Handle options of test-runner"""
4253

@@ -126,7 +137,7 @@ def __init__(self):
126137
parser.add_argument(
127138
"--verbose",
128139
dest='is_verbose',
129-
action="store_true",
140+
action=DeprecationWarning,
130141
default=False,
131142
help=format_help(
132143
"""
@@ -135,6 +146,18 @@ def __init__(self):
135146
Default: false.
136147
"""))
137148

149+
parser.add_argument(
150+
"-c", "--show-capture",
151+
dest='show_capture',
152+
action='store_true',
153+
default=False,
154+
help=format_help(
155+
"""
156+
Whether to show captured TAP13 output or not.
157+
158+
Default: false.
159+
"""))
160+
138161
parser.add_argument(
139162
'--debug',
140163
dest='debug',

lib/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def run(self, server):
226226
self.is_equal_result = filecmp.cmp(self.result,
227227
self.tmp_result)
228228
elif self.is_executed_ok:
229-
if Options().args.is_verbose:
229+
if Options().args.show_capture:
230230
color_stdout('\n')
231231
with open(self.tmp_result, 'r') as f:
232232
color_stdout(f.read(), schema='log')

0 commit comments

Comments
 (0)