Skip to content

Commit 0515406

Browse files
committed
Merge #16374: test: Enable passing wildcard test names to test runner from root
e142ee0 doc: describe how to pass wildcard names to test runner (Jon Atack) 6a7a70b test: enable passing wildcards with path to test runner (Jon Atack) Pull request description: Currently, passing wildcard testname args to the test runner from outside the test/functional/ directory does not work, even though developers expect it to. See these recent IRC discussions for more background: http://www.erisian.com.au/bitcoin-core-dev/log-2019-07-10.html#l-262 (lines 262 to 323) and http://www.erisian.com.au/bitcoin-core-dev/log-2019-07-11.html#l-134. 1. [BUGFIX] Enable passing wildcards with paths. 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 this PR does not change: 9 test files with arguments in their filename are not picked up by wildcard search. 2. [Docs] Describe how to pass wildcard names (multiple and with paths) to the test runner in test/README.md. ACKs for top commit: jnewbery: tested ACK e142ee0 jachiang: Tested ACK bitcoin/bitcoin@e142ee0. Thanks a lot for this fix! MarcoFalke: ACK e142ee0, fine with me Tree-SHA512: cb3d994880cdc9b8918546b573a25faa5b4c7339826ac7cfe20f076aac6e731a34271609c0cf5a7ee5e4a2d5ae205298319d24bf36ef5b5d569a1a0c57883e54
2 parents 459baa1 + e142ee0 commit 0515406

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

test/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,29 @@ You can run any combination (incl. duplicates) of tests by calling:
4949
test/functional/test_runner.py <testname1> <testname2> <testname3> ...
5050
```
5151

52+
Wildcard test names can be passed, if the paths are coherent and the test runner
53+
is called from a `bash` shell or similar that does the globbing. For example,
54+
to run all the wallet tests:
55+
56+
```
57+
test/functional/test_runner.py test/functional/wallet*
58+
functional/test_runner.py functional/wallet* (called from the test/ directory)
59+
test_runner.py wallet* (called from the test/functional/ directory)
60+
```
61+
62+
but not
63+
64+
```
65+
test/functional/test_runner.py wallet*
66+
```
67+
68+
Combinations of wildcards can be passed:
69+
70+
```
71+
test/functional/test_runner.py ./test/functional/tool* test/functional/mempool*
72+
test_runner.py tool* mempool*
73+
```
74+
5275
Run the regression test suite with:
5376

5477
```

test/functional/test_runner.py

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

0 commit comments

Comments
 (0)