Skip to content

Commit 16c2ad2

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 16c2ad2

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-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

+21-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ 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("Argument %s is deprecated and is ignored.\n" % self.option_strings, schema='info')
45+
setattr(namespace, self.dest, values)
46+
47+
4048
class Options(object):
4149
"""Handle options of test-runner"""
4250

@@ -126,7 +134,7 @@ def __init__(self):
126134
parser.add_argument(
127135
"--verbose",
128136
dest='is_verbose',
129-
action="store_true",
137+
action=DeprecationWarning,
130138
default=False,
131139
help=format_help(
132140
"""
@@ -135,6 +143,18 @@ def __init__(self):
135143
Default: false.
136144
"""))
137145

146+
parser.add_argument(
147+
"-c", "--show-capture",
148+
dest='show_capture',
149+
action='store_true',
150+
default=False,
151+
help=format_help(
152+
"""
153+
Whether to show captured TAP13 output or not.
154+
155+
Default: false.
156+
"""))
157+
138158
parser.add_argument(
139159
'--debug',
140160
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)