Skip to content

Commit 2be37ae

Browse files
committed
test: print excluded tests
1 parent 72b46f2 commit 2be37ae

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

test/functional/test_runner.py

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -523,23 +523,29 @@ def main():
523523

524524
# Remove the test cases that the user has explicitly asked to exclude.
525525
# The user can specify a test case with or without the .py extension.
526+
excluded_tests = []
526527
if args.exclude:
527528
def print_warning_missing_test(test_name):
528529
print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], test_name))
529530
def remove_tests(exclude_list):
531+
removed = []
530532
if not exclude_list:
531533
print_warning_missing_test(exclude_test)
532534
for exclude_item in exclude_list:
533-
test_list.remove(exclude_item)
535+
if exclude_item in test_list:
536+
test_list.remove(exclude_item)
537+
removed.append(exclude_item)
538+
return removed
534539

535540
exclude_tests = [test.strip() for test in args.exclude.split(",")]
536541
for exclude_test in exclude_tests:
537542
# A space in the name indicates it has arguments such as "wallet_basic.py --descriptors"
538543
if ' ' in exclude_test:
539-
remove_tests([test for test in test_list if test.replace('.py', '') == exclude_test.replace('.py', '')])
544+
excluded = remove_tests([test for test in test_list if test.replace('.py', '') == exclude_test.replace('.py', '')])
540545
else:
541546
# Exclude all variants of a test
542-
remove_tests([test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]])
547+
excluded = remove_tests([test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]])
548+
excluded_tests.extend(excluded)
543549

544550
if args.filter:
545551
test_list = list(filter(re.compile(args.filter).search, test_list))
@@ -570,6 +576,7 @@ def remove_tests(exclude_list):
570576

571577
run_tests(
572578
test_list=test_list,
579+
excluded_tests=excluded_tests,
573580
src_dir=config["environment"]["SRCDIR"],
574581
build_dir=config["environment"]["BUILDDIR"],
575582
tmpdir=tmpdir,
@@ -582,7 +589,7 @@ def remove_tests(exclude_list):
582589
results_filepath=results_filepath,
583590
)
584591

585-
def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False, use_term_control, results_filepath=None):
592+
def run_tests(*, test_list, excluded_tests, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False, use_term_control, results_filepath=None):
586593
args = args or []
587594

588595
# Warn if bitcoind is already running
@@ -639,6 +646,9 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
639646
start_time = time.time()
640647
test_results = []
641648

649+
for excluded_test in excluded_tests:
650+
test_results.append(TestResult(excluded_test, "Excluded", 0))
651+
642652
max_len_name = len(max(test_list, key=len))
643653
test_count = len(test_list)
644654
all_passed = True
@@ -817,32 +827,33 @@ def get_next(self):
817827

818828

819829
class TestResult():
830+
831+
STATUS_INFO = { # sort key, colour, glyph
832+
"Passed": (0, GREEN, TICK),
833+
"Skipped": (1, DEFAULT, CIRCLE),
834+
"Excluded": (2, DEFAULT, CIRCLE),
835+
"Failed": (3, RED, CROSS),
836+
}
837+
820838
def __init__(self, name, status, time):
821839
self.name = name
822840
self.status = status
823841
self.time = time
824842
self.padding = 0
825843

826844
def sort_key(self):
827-
if self.status == "Passed":
828-
return 0, self.name.lower()
829-
elif self.status == "Failed":
830-
return 2, self.name.lower()
831-
elif self.status == "Skipped":
832-
return 1, self.name.lower()
845+
try:
846+
priority, _, _ = self.STATUS_INFO[self.status]
847+
return priority, self.name.lower()
848+
except KeyError:
849+
raise KeyError(f"Test status unknown: {self.status}")
833850

834851
def __repr__(self):
835-
if self.status == "Passed":
836-
color = GREEN
837-
glyph = TICK
838-
elif self.status == "Failed":
839-
color = RED
840-
glyph = CROSS
841-
elif self.status == "Skipped":
842-
color = DEFAULT
843-
glyph = CIRCLE
844-
845-
return color[1] + "%s | %s%s | %s s\n" % (self.name.ljust(self.padding), glyph, self.status.ljust(7), self.time) + color[0]
852+
try:
853+
_, color, glyph = self.STATUS_INFO[self.status]
854+
return f"{color[1]}{self.name:<{self.padding}} | {glyph}{self.status:<7} | {self.time} s\n{color[0]}"
855+
except KeyError:
856+
raise KeyError(f"Test status unknown: {self.status}")
846857

847858
@property
848859
def was_successful(self):

0 commit comments

Comments
 (0)