Skip to content

Commit 6a7a70b

Browse files
committed
test: enable passing wildcards with path to test runner
Currently, passing wildcard testname args to the test runner from outside the `test/functional/` directory does not work. See this recent IRC discussion for more background: http://www.erisian.com.au/bitcoin-core-dev/log-2019-07-10.html#l-262 (lines 262 to 323). This small change enables passing multiple wildcards with paths, as long as the paths are coherent. Examples: - test/functional/test_runner.py test/functional/wallet* - functional/test_runner.py functional/wallet* - test/functional/test_runner.py ./test/functional/tool* test/functional/mempool* A current limitation that this PR does not change: 9 test files with arguments in their name are not picked up by wildcard search. - Squashed commit: non-mutating version - Squashed commit: minor code optimisation
1 parent 4fcccda commit 6a7a70b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/functional/test_runner.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,22 @@ def main():
269269
test_list = []
270270
if tests:
271271
# Individual tests have been specified. Run specified tests that exist
272-
# in the ALL_SCRIPTS list. Accept the name with or without .py extension.
273-
tests = [test + ".py" if ".py" not in test else test for test in tests]
272+
# in the ALL_SCRIPTS list. Accept names with or without a .py extension.
273+
# Specified tests can contain wildcards, but in that case the supplied
274+
# paths should be coherent, e.g. the same path as that provided to call
275+
# test_runner.py. Examples:
276+
# `test/functional/test_runner.py test/functional/wallet*`
277+
# `test/functional/test_runner.py ./test/functional/wallet*`
278+
# `test_runner.py wallet*`
279+
# but not:
280+
# `test/functional/test_runner.py wallet*`
281+
# Multiple wildcards can be passed:
282+
# `test_runner.py tool* mempool*`
274283
for test in tests:
275-
if test in ALL_SCRIPTS:
276-
test_list.append(test)
284+
script = test.split("/")[-1]
285+
script = script + ".py" if ".py" not in script else script
286+
if script in ALL_SCRIPTS:
287+
test_list.append(script)
277288
else:
278289
print("{}WARNING!{} Test '{}' not found in full test list.".format(BOLD[1], BOLD[0], test))
279290
elif args.extended:

0 commit comments

Comments
 (0)