Skip to content

Commit 975097f

Browse files
committed
Let test_runner.py start multiple jobs per timeslot
1 parent 8c0bd87 commit 975097f

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

test/functional/test_runner.py

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -529,33 +529,35 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
529529

530530
max_len_name = len(max(test_list, key=len))
531531
test_count = len(test_list)
532-
for i in range(test_count):
533-
test_result, testdir, stdout, stderr = job_queue.get_next()
534-
test_results.append(test_result)
535-
done_str = "{}/{} - {}{}{}".format(i + 1, test_count, BOLD[1], test_result.name, BOLD[0])
536-
if test_result.status == "Passed":
537-
logging.debug("%s passed, Duration: %s s" % (done_str, test_result.time))
538-
elif test_result.status == "Skipped":
539-
logging.debug("%s skipped" % (done_str))
540-
else:
541-
print("%s failed, Duration: %s s\n" % (done_str, test_result.time))
542-
print(BOLD[1] + 'stdout:\n' + BOLD[0] + stdout + '\n')
543-
print(BOLD[1] + 'stderr:\n' + BOLD[0] + stderr + '\n')
544-
if combined_logs_len and os.path.isdir(testdir):
545-
# Print the final `combinedlogslen` lines of the combined logs
546-
print('{}Combine the logs and print the last {} lines ...{}'.format(BOLD[1], combined_logs_len, BOLD[0]))
547-
print('\n============')
548-
print('{}Combined log for {}:{}'.format(BOLD[1], testdir, BOLD[0]))
549-
print('============\n')
550-
combined_logs_args = [sys.executable, os.path.join(tests_dir, 'combine_logs.py'), testdir]
551-
if BOLD[0]:
552-
combined_logs_args += ['--color']
553-
combined_logs, _ = subprocess.Popen(combined_logs_args, universal_newlines=True, stdout=subprocess.PIPE).communicate()
554-
print("\n".join(deque(combined_logs.splitlines(), combined_logs_len)))
555-
556-
if failfast:
557-
logging.debug("Early exiting after test failure")
558-
break
532+
i = 0
533+
while i < test_count:
534+
for test_result, testdir, stdout, stderr in job_queue.get_next():
535+
test_results.append(test_result)
536+
i += 1
537+
done_str = "{}/{} - {}{}{}".format(i, test_count, BOLD[1], test_result.name, BOLD[0])
538+
if test_result.status == "Passed":
539+
logging.debug("%s passed, Duration: %s s" % (done_str, test_result.time))
540+
elif test_result.status == "Skipped":
541+
logging.debug("%s skipped" % (done_str))
542+
else:
543+
print("%s failed, Duration: %s s\n" % (done_str, test_result.time))
544+
print(BOLD[1] + 'stdout:\n' + BOLD[0] + stdout + '\n')
545+
print(BOLD[1] + 'stderr:\n' + BOLD[0] + stderr + '\n')
546+
if combined_logs_len and os.path.isdir(testdir):
547+
# Print the final `combinedlogslen` lines of the combined logs
548+
print('{}Combine the logs and print the last {} lines ...{}'.format(BOLD[1], combined_logs_len, BOLD[0]))
549+
print('\n============')
550+
print('{}Combined log for {}:{}'.format(BOLD[1], testdir, BOLD[0]))
551+
print('============\n')
552+
combined_logs_args = [sys.executable, os.path.join(tests_dir, 'combine_logs.py'), testdir]
553+
if BOLD[0]:
554+
combined_logs_args += ['--color']
555+
combined_logs, _ = subprocess.Popen(combined_logs_args, universal_newlines=True, stdout=subprocess.PIPE).communicate()
556+
print("\n".join(deque(combined_logs.splitlines(), combined_logs_len)))
557+
558+
if failfast:
559+
logging.debug("Early exiting after test failure")
560+
break
559561

560562
print_results(test_results, max_len_name, (int(time.time() - start_time)))
561563

@@ -649,8 +651,9 @@ def get_next(self):
649651

650652
dot_count = 0
651653
while True:
652-
# Return first proc that finishes
654+
# Return all procs that have finished, if any. Otherwise sleep until there is one.
653655
time.sleep(.5)
656+
ret = []
654657
for job in self.jobs:
655658
(name, start_time, proc, testdir, log_out, log_err) = job
656659
if proc.poll() is not None:
@@ -669,7 +672,9 @@ def get_next(self):
669672
clearline = '\r' + (' ' * dot_count) + '\r'
670673
print(clearline, end='', flush=True)
671674
dot_count = 0
672-
return TestResult(name, status, int(time.time() - start_time)), testdir, stdout, stderr
675+
ret.append((TestResult(name, status, int(time.time() - start_time)), testdir, stdout, stderr))
676+
if ret:
677+
return ret
673678
if self.use_term_control:
674679
print('.', end='', flush=True)
675680
dot_count += 1

0 commit comments

Comments
 (0)