Skip to content

Commit 6d7aa3d

Browse files
fanquakePastaPastaPasta
authored andcommitted
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
1 parent d0e15d5 commit 6d7aa3d

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
@@ -592,14 +592,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, attempts=1, enab
592592
max_len_name = len(max(test_list, key=len))
593593
test_count = len(test_list)
594594
all_passed = True
595-
i = 0
596-
while i < test_count:
595+
while not job_queue.done():
597596
if failfast and not all_passed:
598597
break
599598
for test_result, testdir, stdout, stderr in job_queue.get_next():
600599
test_results.append(test_result)
601-
i += 1
602-
done_str = "{}/{} - {}{}{}".format(i, test_count, BOLD[1], test_result.name, BOLD[0])
600+
done_str = f"{len(test_results)}/{test_count} - {BOLD[1]}{test_result.name}{BOLD[0]}"
603601
if test_result.status == "Passed":
604602
logging.debug("%s passed, Duration: %s s" % (done_str, test_result.time))
605603
elif test_result.status == "Skipped":
@@ -684,15 +682,16 @@ def __init__(self, *, num_tests_parallel, tests_dir, tmpdir, test_list, flags, u
684682
self.tmpdir = tmpdir
685683
self.test_list = test_list
686684
self.flags = flags
687-
self.num_running = 0
688685
self.jobs = []
689686
self.use_term_control = use_term_control
690687
self.attempts = attempts
691688

689+
def done(self):
690+
return not (self.jobs or self.test_list)
691+
692692
def get_next(self):
693-
while self.num_running < self.num_jobs and self.test_list:
693+
while len(self.jobs) < self.num_jobs and self.test_list:
694694
# Add tests
695-
self.num_running += 1
696695
test = self.test_list.pop(0)
697696
portseed = len(self.test_list)
698697
portseed_arg = ["--portseed={}".format(portseed)]
@@ -764,7 +763,6 @@ def get_next(self):
764763
continue
765764
else:
766765
status = "Failed"
767-
self.num_running -= 1
768766
self.jobs.remove(job)
769767
if self.use_term_control:
770768
clearline = '\r' + (' ' * dot_count) + '\r'

0 commit comments

Comments
 (0)