Skip to content

Commit c4762b0

Browse files
committed
test: allow excluding func test by name and arg
Can now specify test_runner.py --exclude "rpc_bind.py --ipv6" and have only that test variant excluded
1 parent aa6b876 commit c4762b0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

test/functional/test_runner.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,22 @@ def main():
510510

511511
# Remove the test cases that the user has explicitly asked to exclude.
512512
if args.exclude:
513-
exclude_tests = [test.split('.py')[0] for test in args.exclude.split(',')]
513+
def print_warning_missing_test(test_name):
514+
print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], test_name))
515+
exclude_tests = [test.strip() for test in args.exclude.split(",")]
514516
for exclude_test in exclude_tests:
515-
# Remove <test_name>.py and <test_name>.py --arg from the test list
516-
exclude_list = [test for test in test_list if test.split('.py')[0] == exclude_test]
517-
for exclude_item in exclude_list:
518-
test_list.remove(exclude_item)
519-
if not exclude_list:
520-
print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], exclude_test))
517+
if exclude_test.endswith('.py'):
518+
# Remove <test_name>.py and <test_name>.py --arg from the test list
519+
exclude_list = [test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]]
520+
if not exclude_list:
521+
print_warning_missing_test(exclude_test)
522+
for exclude_item in exclude_list:
523+
test_list.remove(exclude_item)
524+
else:
525+
try:
526+
test_list.remove(exclude_test)
527+
except ValueError:
528+
print_warning_missing_test(exclude_test)
521529

522530
if args.filter:
523531
test_list = list(filter(re.compile(args.filter).search, test_list))

0 commit comments

Comments
 (0)