diff options
author | tdb3 <106488469+tdb3@users.noreply.github.com> | 2024-03-11 17:54:01 -0400 |
---|---|---|
committer | tdb3 <106488469+tdb3@users.noreply.github.com> | 2024-03-12 18:00:04 -0400 |
commit | 0831b54dfca1b9e728295fff500215da14589fc0 (patch) | |
tree | 3e9ba2fce1e9b8881f3891c31408d03185b503fd /test/functional/test_runner.py | |
parent | 1105aa46dd1008c556b8c435f1efcb9be09a1644 (diff) | |
download | bitcoin-0831b54dfca1b9e728295fff500215da14589fc0.tar.xz |
test: simplify test_runner.py
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).
Originally proposed by @sipa in PR #23995.
Co-authored-by: Pieter Wuille <pieter@wuille.net>
Diffstat (limited to 'test/functional/test_runner.py')
-rwxr-xr-x | test/functional/test_runner.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 59931bc208..9325b0a250 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -614,14 +614,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage= max_len_name = len(max(test_list, key=len)) test_count = len(test_list) all_passed = True - i = 0 - while i < test_count: + while not job_queue.done(): if failfast and not all_passed: break for test_result, testdir, stdout, stderr, skip_reason in job_queue.get_next(): test_results.append(test_result) - i += 1 - done_str = "{}/{} - {}{}{}".format(i, test_count, BOLD[1], test_result.name, BOLD[0]) + done_str = f"{len(test_results)}/{test_count} - {BOLD[1]}{test_result.name}{BOLD[0]}" if test_result.status == "Passed": logging.debug("%s passed, Duration: %s s" % (done_str, test_result.time)) elif test_result.status == "Skipped": @@ -706,14 +704,15 @@ class TestHandler: self.tmpdir = tmpdir self.test_list = test_list self.flags = flags - self.num_running = 0 self.jobs = [] self.use_term_control = use_term_control + def done(self): + return not (self.jobs or self.test_list) + def get_next(self): - while self.num_running < self.num_jobs and self.test_list: + while len(self.jobs) < self.num_jobs and self.test_list: # Add tests - self.num_running += 1 test = self.test_list.pop(0) portseed = len(self.test_list) portseed_arg = ["--portseed={}".format(portseed)] @@ -757,7 +756,6 @@ class TestHandler: skip_reason = re.search(r"Test Skipped: (.*)", stdout).group(1) else: status = "Failed" - self.num_running -= 1 self.jobs.remove(job) if self.use_term_control: clearline = '\r' + (' ' * dot_count) + '\r' |