Skip to content

Commit 93e4824

Browse files
committed
Merge bitcoin#30244: ci: parse TEST_RUNNER_EXTRA into an array
8131bf7 ci: parse TEST_RUNNER_EXTRA into an array (Max Edwards) c4762b0 test: allow excluding func test by name and arg (Max Edwards) Pull request description: While working on CI I wanted to disable some functional tests so I used the `TEST_RUNNER_EXTRA` var. The problem I had was tests that have flags such as `rpc_bind.py --ipv6` must be passed in quotes otherwise the `--ipv6` portion will be considered an argument to `test_runner.py` rather than a test name. This change allows proper parsing of quotes and complex values such as: ```shell TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6,feature_proxy.py"' ``` Update: While testing this it was noticed that `test_runner.py` when given `--exclude "rpc_bind.py --ipv6"` will exclude all `rpc_bind.py` tests so this PR has been updated to include a change to the test runner to only exclude the specific test if you pass an arg or exclude all tests of that name if you do not pass an arg. `--exclude rpc_bind.py` will exclude all three variants and `--exclude rpc_bind --ipv6` will only exclude the IPV6 variant. ACKs for top commit: maflcko: ACK 8131bf7 achow101: ACK 8131bf7 hebasto: ACK 8131bf7, tested on Ubuntu 23.10 and Windows 11. Tree-SHA512: 82b73f12d627f533d8e5be4a518d455ef4427a755bbe03ccd11d0bb70c7ff3cee76220b0264fcfb236661c4cf5deba034cbfc2372b96d5861f3436c21eae8264
2 parents f640b32 + 8131bf7 commit 93e4824

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

ci/test/03_test_script.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
146146
fi
147147

148148
if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
149-
# shellcheck disable=SC2086
150-
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/functional/test_runner.py --ci "${MAKEJOBS}" --tmpdirprefix "${BASE_SCRATCH_DIR}"/test_runner/ --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" ${TEST_RUNNER_EXTRA} --quiet --failfast
149+
# parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"'
150+
eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)"
151+
LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" test/functional/test_runner.py --ci "${MAKEJOBS}" --tmpdirprefix "${BASE_SCRATCH_DIR}"/test_runner/ --ansi --combinedlogslen=99999999 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" "${TEST_RUNNER_EXTRA[@]}" --quiet --failfast
151152
fi
152153

153154
if [ "${RUN_TIDY}" = "true" ]; then

test/functional/test_runner.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,22 @@ def main():
523523

524524
# Remove the test cases that the user has explicitly asked to exclude.
525525
if args.exclude:
526-
exclude_tests = [test.split('.py')[0] for test in args.exclude.split(',')]
526+
def print_warning_missing_test(test_name):
527+
print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], test_name))
528+
exclude_tests = [test.strip() for test in args.exclude.split(",")]
527529
for exclude_test in exclude_tests:
528-
# Remove <test_name>.py and <test_name>.py --arg from the test list
529-
exclude_list = [test for test in test_list if test.split('.py')[0] == exclude_test]
530-
for exclude_item in exclude_list:
531-
test_list.remove(exclude_item)
532-
if not exclude_list:
533-
print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], exclude_test))
530+
if exclude_test.endswith('.py'):
531+
# Remove <test_name>.py and <test_name>.py --arg from the test list
532+
exclude_list = [test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]]
533+
if not exclude_list:
534+
print_warning_missing_test(exclude_test)
535+
for exclude_item in exclude_list:
536+
test_list.remove(exclude_item)
537+
else:
538+
try:
539+
test_list.remove(exclude_test)
540+
except ValueError:
541+
print_warning_missing_test(exclude_test)
534542

535543
if args.filter:
536544
test_list = list(filter(re.compile(args.filter).search, test_list))

0 commit comments

Comments
 (0)