Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_runner.py
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | TEST_PARAMS = { | ||||
# This: | # This: | ||||
# example "testName" : [["--param1", "--param2"] , ["--param3"]] | # example "testName" : [["--param1", "--param2"] , ["--param3"]] | ||||
# will run the test 3 times: | # will run the test 3 times: | ||||
# testName | # testName | ||||
# testName --param1 --param2 | # testName --param1 --param2 | ||||
# testname --param3 | # testname --param3 | ||||
"wallet_txn_doublespend.py": [["--mineblock"]], | "wallet_txn_doublespend.py": [["--mineblock"]], | ||||
"wallet_txn_clone.py": [["--mineblock"]], | "wallet_txn_clone.py": [["--mineblock"]], | ||||
"wallet_createwallet.py": [["--usecli"]], | |||||
"wallet_multiwallet.py": [["--usecli"]], | "wallet_multiwallet.py": [["--usecli"]], | ||||
"wallet_disableprivatekeys.py": [["--usecli"]], | |||||
} | } | ||||
# Used to limit the number of tests, when list of tests is not provided on command line | # Used to limit the number of tests, when list of tests is not provided on command line | ||||
# When --extended is specified, we run all tests, otherwise | # When --extended is specified, we run all tests, otherwise | ||||
# we only run a test if its execution time in seconds does not exceed EXTENDED_CUTOFF | # we only run a test if its execution time in seconds does not exceed EXTENDED_CUTOFF | ||||
DEFAULT_EXTENDED_CUTOFF = 40 | DEFAULT_EXTENDED_CUTOFF = 40 | ||||
DEFAULT_JOBS = (multiprocessing.cpu_count() // 3) + 1 | DEFAULT_JOBS = (multiprocessing.cpu_count() // 3) + 1 | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | else: | ||||
# Run all tests that do not exceed | # Run all tests that do not exceed | ||||
test_list = all_scripts | test_list = all_scripts | ||||
cutoff = args.cutoff | cutoff = args.cutoff | ||||
if args.extended: | if args.extended: | ||||
cutoff = sys.maxsize | cutoff = sys.maxsize | ||||
# Remove the test cases that the user has explicitly asked to exclude. | # Remove the test cases that the user has explicitly asked to exclude. | ||||
if args.exclude: | if args.exclude: | ||||
tests_excl = [re.sub(r"\.py$", "", t) + | tests_excl = [re.sub(r"\.py$", "", t) | ||||
".py" for t in args.exclude.split(',')] | + ".py" for t in args.exclude.split(',')] | ||||
for exclude_test in tests_excl: | for exclude_test in tests_excl: | ||||
if exclude_test in test_list: | if exclude_test in test_list: | ||||
test_list.remove(exclude_test) | test_list.remove(exclude_test) | ||||
else: | else: | ||||
print("{}WARNING!{} Test '{}' not found in current test list.".format( | print("{}WARNING!{} Test '{}' not found in current test list.".format( | ||||
BOLD[1], BOLD[0], exclude_test)) | BOLD[1], BOLD[0], exclude_test)) | ||||
# Update timings from build_dir only if separate build directory is used. | # Update timings from build_dir only if separate build directory is used. | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | def handle_update_messages(): | ||||
if printed_status: | if printed_status: | ||||
print() | print() | ||||
printed_status = False | printed_status = False | ||||
handle_message(message, running_jobs) | handle_message(message, running_jobs) | ||||
update_queue.task_done() | update_queue.task_done() | ||||
except Empty: | except Empty: | ||||
if not on_ci(): | if not on_ci(): | ||||
print("Running jobs: {}".format(", ".join([j[1] for j in running_jobs])), end="\r") | print("Running jobs: {}".format( | ||||
", ".join([j[1] for j in running_jobs])), end="\r") | |||||
sys.stdout.flush() | sys.stdout.flush() | ||||
printed_status = True | printed_status = True | ||||
def handle_test_cases(): | def handle_test_cases(): | ||||
""" | """ | ||||
job_runner represents a single thread that is part of a worker pool. | job_runner represents a single thread that is part of a worker pool. | ||||
It waits for a test, then executes that test. | It waits for a test, then executes that test. | ||||
It also reports start and result messages to handle_update_messages | It also reports start and result messages to handle_update_messages | ||||
▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines |