0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-01 09:35:52 -05:00

test: fix exclude parsing for functional runner

This restores previous behaviour of being able to exclude a test by name without having to specify .py extension.
This commit is contained in:
Max Edwards 2024-09-11 18:27:49 +01:00
parent 0725a37494
commit 72b46f28bf

View file

@ -522,23 +522,24 @@ def main():
test_list += BASE_SCRIPTS test_list += BASE_SCRIPTS
# Remove the test cases that the user has explicitly asked to exclude. # Remove the test cases that the user has explicitly asked to exclude.
# The user can specify a test case with or without the .py extension.
if args.exclude: if args.exclude:
def print_warning_missing_test(test_name): def print_warning_missing_test(test_name):
print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], test_name)) print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], test_name))
def remove_tests(exclude_list):
if not exclude_list:
print_warning_missing_test(exclude_test)
for exclude_item in exclude_list:
test_list.remove(exclude_item)
exclude_tests = [test.strip() for test in args.exclude.split(",")] exclude_tests = [test.strip() for test in args.exclude.split(",")]
for exclude_test in exclude_tests: for exclude_test in exclude_tests:
if exclude_test.endswith('.py'): # A space in the name indicates it has arguments such as "wallet_basic.py --descriptors"
# Remove <test_name>.py and <test_name>.py --arg from the test list if ' ' in exclude_test:
exclude_list = [test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]] remove_tests([test for test in test_list if test.replace('.py', '') == exclude_test.replace('.py', '')])
if not exclude_list:
print_warning_missing_test(exclude_test)
for exclude_item in exclude_list:
test_list.remove(exclude_item)
else: else:
try: # Exclude all variants of a test
test_list.remove(exclude_test) remove_tests([test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]])
except ValueError:
print_warning_missing_test(exclude_test)
if args.filter: if args.filter:
test_list = list(filter(re.compile(args.filter).search, test_list)) test_list = list(filter(re.compile(args.filter).search, test_list))