From c4762b0aa06f2654d108bc7ca05887ffd88cf6f8 Mon Sep 17 00:00:00 2001 From: Max Edwards Date: Wed, 12 Jun 2024 16:43:05 +0100 Subject: [PATCH 1/2] 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 --- test/functional/test_runner.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 84e524558f9..2a4d929be17 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -510,14 +510,22 @@ def main(): # Remove the test cases that the user has explicitly asked to exclude. if args.exclude: - exclude_tests = [test.split('.py')[0] for test in args.exclude.split(',')] + def print_warning_missing_test(test_name): + print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], test_name)) + exclude_tests = [test.strip() for test in args.exclude.split(",")] for exclude_test in exclude_tests: - # Remove .py and .py --arg from the test list - exclude_list = [test for test in test_list if test.split('.py')[0] == exclude_test] - for exclude_item in exclude_list: - test_list.remove(exclude_item) - if not exclude_list: - print("{}WARNING!{} Test '{}' not found in current test list.".format(BOLD[1], BOLD[0], exclude_test)) + if exclude_test.endswith('.py'): + # Remove .py and .py --arg from the test list + exclude_list = [test for test in test_list if test.split('.py')[0] == exclude_test.split('.py')[0]] + if not exclude_list: + print_warning_missing_test(exclude_test) + for exclude_item in exclude_list: + test_list.remove(exclude_item) + else: + try: + test_list.remove(exclude_test) + except ValueError: + print_warning_missing_test(exclude_test) if args.filter: test_list = list(filter(re.compile(args.filter).search, test_list)) From 8131bf7483c0ea10d3573c9f2e977d19d8569b7f Mon Sep 17 00:00:00 2001 From: Max Edwards Date: Fri, 7 Jun 2024 13:11:45 +0100 Subject: [PATCH 2/2] ci: parse TEST_RUNNER_EXTRA into an array Allows for parsing quotes and multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6,feature_proxy.py"' --- ci/test/03_test_script.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index 71d9ad7f72f..74cb5173804 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -160,8 +160,9 @@ if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then fi if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then - # shellcheck disable=SC2086 - 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 + # parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"' + eval "TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA)" + 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 fi if [ "${RUN_TIDY}" = "true" ]; then