Skip to content

Commit 65e6f91

Browse files
author
Sergei Voronezhskii
committed
Add new config param 'show_reproduce_content'
By default this param is True, if the test fails then the contents of reproduce file are displayed. If the parameter is False, do not show the contents of reproduce file. For example, the 'sql-tap' tests run each case in a separate tarantool instance, so reproduce is not necessary for problem investigation. Used in 'suite.ini'. Closes #113
1 parent 822eed3 commit 65e6f91

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

lib/test_suite.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def __init__(self, suite_path, args):
9999
self.ini[i] = map(lambda x: os.path.join(suite_path, x),
100100
dict.fromkeys(self.ini[i].split()) if i in self.ini else dict())
101101

102+
self.ini.update(dict(show_reproduce_content=self.show_reproduce_content))
103+
102104
def find_tests(self):
103105
if self.ini['core'] == 'tarantool':
104106
TarantoolServer.find_tests(self, self.suite_path)
@@ -214,3 +216,11 @@ def is_parallel(self):
214216
raise ConfigurationError()
215217
pass
216218
return val
219+
220+
@property
221+
def show_reproduce_content(self):
222+
val = self.ini.get('show_reproduce_content', 'true')
223+
if not isinstance(val, bool):
224+
# It seems value from ini file, convert from string to bool
225+
val = val.lower() != 'false'
226+
return val

lib/worker.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def get_task_groups():
7777
'gen_worker': gen_worker,
7878
'task_ids': task_ids,
7979
'is_parallel': suite.is_parallel(),
80+
'show_reproduce_content': suite.show_reproduce_content
8081
}
8182
return res
8283

@@ -130,12 +131,13 @@ class WorkerTaskResult(BaseWorkerMessage):
130131
worker. The short_status (string) field intended to give short note whether
131132
the task processed successfully or not, but with little more flexibility
132133
than binary True/False. The task_id (any hashable object) field hold ID of
133-
the processed task.
134+
the processed task. The suite_ini dict with configuration.
134135
"""
135-
def __init__(self, worker_id, worker_name, task_id, short_status):
136+
def __init__(self, worker_id, worker_name, task_id, short_status, suite_ini):
136137
super(WorkerTaskResult, self).__init__(worker_id, worker_name)
137138
self.short_status = short_status
138139
self.task_id = task_id
140+
self.suite_ini = suite_ini
139141

140142

141143
class WorkerOutput(BaseWorkerMessage):
@@ -177,7 +179,7 @@ def done_marker(self):
177179
return WorkerDone(self.id, self.name)
178180

179181
def wrap_result(self, task_id, short_status):
180-
return WorkerTaskResult(self.id, self.name, task_id, short_status)
182+
return WorkerTaskResult(self.id, self.name, task_id, short_status, self.suite.ini)
181183

182184
def sigterm_handler(self, signum, frame):
183185
self.sigterm_received = True

listeners.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def process_result(self, obj):
3737
self.stats[obj.short_status] += 1
3838

3939
if obj.short_status == 'fail':
40-
self.failed_tasks.append((obj.task_id, obj.worker_name))
40+
self.failed_tasks.append((obj.task_id, obj.worker_name, obj.suite_ini))
4141

4242
def print_statistics(self):
4343
"""Returns are there failed tasks."""
@@ -50,15 +50,16 @@ def print_statistics(self):
5050
return False
5151

5252
color_stdout('Failed tasks:\n', schema='test_var')
53-
for task_id, worker_name in self.failed_tasks:
53+
for task_id, worker_name, suite_ini in self.failed_tasks:
5454
logfile = self.get_logfile(worker_name)
55-
reproduce_file_path = get_reproduce_file(worker_name)
5655
color_stdout('- %s' % yaml.safe_dump(task_id), schema='test_var')
5756
color_stdout('# logfile: %s\n' % logfile)
57+
reproduce_file_path = get_reproduce_file(worker_name)
5858
color_stdout('# reproduce file: %s\n' % reproduce_file_path)
59-
color_stdout("---\n", schema='separator')
60-
lib.utils.print_tail_n(reproduce_file_path)
61-
color_stdout("...\n", schema='separator')
59+
if suite_ini['show_reproduce_content']:
60+
color_stdout("---\n", schema='separator')
61+
lib.utils.print_tail_n(reproduce_file_path)
62+
color_stdout("...\n", schema='separator')
6263

6364
return True
6465

test-run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def main_loop_consistent(failed_test_ids):
151151
color_stdout('-' * 75, "\n", schema='separator')
152152

153153
task_ids = task_group['task_ids']
154+
show_reproduce_content = task_group['show_reproduce_content']
154155
if not task_ids:
155156
continue
156157
worker_id = 1
@@ -162,9 +163,10 @@ def main_loop_consistent(failed_test_ids):
162163
lib.worker.get_reproduce_file(worker.name)
163164
color_stdout('Reproduce file %s\n' %
164165
reproduce_file_path, schema='error')
165-
color_stdout("---\n", schema='separator')
166-
lib.utils.print_tail_n(reproduce_file_path)
167-
color_stdout("...\n", schema='separator')
166+
if show_reproduce_content:
167+
color_stdout("---\n", schema='separator')
168+
lib.utils.print_tail_n(reproduce_file_path)
169+
color_stdout("...\n", schema='separator')
168170
failed_test_ids.append(task_id)
169171
if not lib.Options().args.is_force:
170172
worker.stop_server(cleanup=False)

0 commit comments

Comments
 (0)