Skip to content

Commit 6850d72

Browse files
committed
Merge bitcoin#29497: test: simplify test_runner.py
0831b54 test: simplify test_runner.py (tdb3) Pull request description: Implements the simplifications to test_runner.py proposed by sipa in PR bitcoin#23995. Remove the num_running variable as it can be implied by the length of the jobs list. Remove the i variable as it can be implied by the length of the test_results list. Instead of counting results to determine if finished, make the queue object itself responsible (by looking at running jobs and jobs left). ACKs for top commit: mzumsande: re-ACK 0831b54 davidgumberg: reACK bitcoin@0831b54 marcofleon: re-ACK 0831b54 Tree-SHA512: e5473e68d49cd779b29d97635329283ae7195412cb1e92461675715ca7eedb6519a1a93ba28d40ca6f015d270f7bcd3e77cef279d9cd655155ab7805b49638f1
2 parents 55c6323 + 0831b54 commit 6850d72

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/functional/test_runner.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
614614
max_len_name = len(max(test_list, key=len))
615615
test_count = len(test_list)
616616
all_passed = True
617-
i = 0
618-
while i < test_count:
617+
while not job_queue.done():
619618
if failfast and not all_passed:
620619
break
621620
for test_result, testdir, stdout, stderr, skip_reason in job_queue.get_next():
622621
test_results.append(test_result)
623-
i += 1
624-
done_str = "{}/{} - {}{}{}".format(i, test_count, BOLD[1], test_result.name, BOLD[0])
622+
done_str = f"{len(test_results)}/{test_count} - {BOLD[1]}{test_result.name}{BOLD[0]}"
625623
if test_result.status == "Passed":
626624
logging.debug("%s passed, Duration: %s s" % (done_str, test_result.time))
627625
elif test_result.status == "Skipped":
@@ -706,14 +704,15 @@ def __init__(self, *, num_tests_parallel, tests_dir, tmpdir, test_list, flags, u
706704
self.tmpdir = tmpdir
707705
self.test_list = test_list
708706
self.flags = flags
709-
self.num_running = 0
710707
self.jobs = []
711708
self.use_term_control = use_term_control
712709

710+
def done(self):
711+
return not (self.jobs or self.test_list)
712+
713713
def get_next(self):
714-
while self.num_running < self.num_jobs and self.test_list:
714+
while len(self.jobs) < self.num_jobs and self.test_list:
715715
# Add tests
716-
self.num_running += 1
717716
test = self.test_list.pop(0)
718717
portseed = len(self.test_list)
719718
portseed_arg = ["--portseed={}".format(portseed)]
@@ -757,7 +756,6 @@ def get_next(self):
757756
skip_reason = re.search(r"Test Skipped: (.*)", stdout).group(1)
758757
else:
759758
status = "Failed"
760-
self.num_running -= 1
761759
self.jobs.remove(job)
762760
if self.use_term_control:
763761
clearline = '\r' + (' ' * dot_count) + '\r'

0 commit comments

Comments
 (0)