Skip to content

Commit

Permalink
Add printing flaked tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ylobankov committed Mar 21, 2023
1 parent d03af63 commit 3695267
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/worker.py
Expand Up @@ -373,7 +373,7 @@ def run_loop(self, task_queue, result_queue):
short_status, duration = self.run_task(task_id)
retries_left = retries_left - 1

if fails_count > 0 and short_status != 'fail':
if fails_count > 0 and short_status == 'pass':
result_queue.put(self.wrap_result(task_id, 'flaky', duration))
else:
result_queue.put(
Expand Down
29 changes: 18 additions & 11 deletions listeners.py
Expand Up @@ -155,6 +155,19 @@ def print_duration(self, stats_dir):
self.duration_stats[task_id]))
fd.close()

def print_tasks_info(self, tasks):
for task_id, worker_name, show_reproduce_content in tasks:
logfile = self.get_logfile(worker_name)
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)
reproduce_file_path = get_reproduce_file(worker_name)
color_stdout('# reproduce file: %s\n' % reproduce_file_path)
if show_reproduce_content:
color_stdout("---\n", schema='separator')
print_tail_n(reproduce_file_path)
color_stdout("...\n", schema='separator')

def print_statistics(self):
"""Print statistics and results of testing."""
# Prepare standalone subpath '<vardir>/statistics' for statistics files.
Expand All @@ -169,21 +182,15 @@ def print_statistics(self):
for short_status, cnt in self.stats.items():
final_report('* %s: %d\n' % (short_status, cnt), schema='test_var')

if self.flaked_tasks:
final_report('Flaked tasks:\n', schema='test_var')
self.print_tasks_info(self.flaked_tasks)

if not self.failed_tasks:
return False, bool(self.flaked_tasks)

final_report('Failed tasks:\n', schema='test_var')
for task_id, worker_name, show_reproduce_content in self.failed_tasks:
logfile = self.get_logfile(worker_name)
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)
reproduce_file_path = get_reproduce_file(worker_name)
color_stdout('# reproduce file: %s\n' % reproduce_file_path)
if show_reproduce_content:
color_stdout("---\n", schema='separator')
print_tail_n(reproduce_file_path)
color_stdout("...\n", schema='separator')
self.print_tasks_info(self.failed_tasks)

return True, bool(self.flaked_tasks)

Expand Down

0 comments on commit 3695267

Please sign in to comment.