Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_runner.py
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | def main(): | ||||
parser.add_argument('--jobs', '-j', type=int, default=DEFAULT_JOBS, | parser.add_argument('--jobs', '-j', type=int, default=DEFAULT_JOBS, | ||||
help='how many test scripts to run in parallel. Default=4.') | help='how many test scripts to run in parallel. Default=4.') | ||||
parser.add_argument('--keepcache', '-k', action='store_true', | parser.add_argument('--keepcache', '-k', action='store_true', | ||||
help='the default behavior is to flush the cache directory on startup. --keepcache retains the cache from the previous testrun.') | help='the default behavior is to flush the cache directory on startup. --keepcache retains the cache from the previous testrun.') | ||||
parser.add_argument('--quiet', '-q', action='store_true', | parser.add_argument('--quiet', '-q', action='store_true', | ||||
help='only print results summary and failure logs') | help='only print results summary and failure logs') | ||||
parser.add_argument('--tmpdirprefix', '-t', | parser.add_argument('--tmpdirprefix', '-t', | ||||
default=tempfile.gettempdir(), help="Root directory for datadirs") | default=tempfile.gettempdir(), help="Root directory for datadirs") | ||||
parser.add_argument('--junitouput', '-ju', | parser.add_argument('--junitoutput', '-ju', | ||||
deadalnix: `-ju` is absolutely non standard. unidashed parameter are uni letters, contrary to double… | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsYa this threw me off as well. Fixed in D3692 jasonbcox: Ya this threw me off as well. Fixed in D3692 | |||||
default=os.path.join(build_dir, 'junit_results.xml'), help="file that will store JUnit formatted test results.") | default=os.path.join(build_dir, 'junit_results.xml'), help="file that will store JUnit formatted test results.") | ||||
args, unknown_args = parser.parse_known_args() | args, unknown_args = parser.parse_known_args() | ||||
# args to be passed on always start with two dashes; tests are the | # args to be passed on always start with two dashes; tests are the | ||||
# remaining unknown args | # remaining unknown args | ||||
tests = [arg for arg in unknown_args if arg[:2] != "--"] | tests = [arg for arg in unknown_args if arg[:2] != "--"] | ||||
passon_args = [arg for arg in unknown_args if arg[:2] == "--"] | passon_args = [arg for arg in unknown_args if arg[:2] == "--"] | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | if args.help: | ||||
subprocess.check_call( | subprocess.check_call( | ||||
[sys.executable, os.path.join(tests_dir, test_list[0]), '-h']) | [sys.executable, os.path.join(tests_dir, test_list[0]), '-h']) | ||||
sys.exit(0) | sys.exit(0) | ||||
if not args.keepcache: | if not args.keepcache: | ||||
shutil.rmtree(os.path.join(build_dir, "test", | shutil.rmtree(os.path.join(build_dir, "test", | ||||
"cache"), ignore_errors=True) | "cache"), ignore_errors=True) | ||||
run_tests(test_list, build_dir, tests_dir, args.junitouput, | run_tests(test_list, build_dir, tests_dir, args.junitoutput, | ||||
tmpdir, args.jobs, args.coverage, passon_args, args.combinedlogslen, build_timings) | tmpdir, args.jobs, args.coverage, passon_args, args.combinedlogslen, build_timings) | ||||
def run_tests(test_list, build_dir, tests_dir, junitouput, tmpdir, num_jobs, enable_coverage=False, args=[], combined_logs_len=0, build_timings=None): | def run_tests(test_list, build_dir, tests_dir, junitoutput, tmpdir, num_jobs, enable_coverage=False, args=[], combined_logs_len=0, build_timings=None): | ||||
# Warn if bitcoind is already running (unix only) | # Warn if bitcoind is already running (unix only) | ||||
try: | try: | ||||
pidofOutput = subprocess.check_output(["pidof", "bitcoind"]) | pidofOutput = subprocess.check_output(["pidof", "bitcoind"]) | ||||
if pidofOutput is not None and pidofOutput != b'': | if pidofOutput is not None and pidofOutput != b'': | ||||
print("{}WARNING!{} There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!".format( | print("{}WARNING!{} There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!".format( | ||||
BOLD[1], BOLD[0])) | BOLD[1], BOLD[0])) | ||||
except (OSError, subprocess.SubprocessError): | except (OSError, subprocess.SubprocessError): | ||||
pass | pass | ||||
Show All 28 Lines | def run_tests(test_list, build_dir, tests_dir, junitoutput, tmpdir, num_jobs, enable_coverage=False, args=[], combined_logs_len=0, build_timings=None): | ||||
time0 = time.time() | time0 = time.time() | ||||
test_results = execute_test_processes( | test_results = execute_test_processes( | ||||
num_jobs, test_list, tests_dir, tmpdir, flags) | num_jobs, test_list, tests_dir, tmpdir, flags) | ||||
runtime = int(time.time() - time0) | runtime = int(time.time() - time0) | ||||
max_len_name = len(max(test_list, key=len)) | max_len_name = len(max(test_list, key=len)) | ||||
print_results(test_results, tests_dir, max_len_name, | print_results(test_results, tests_dir, max_len_name, | ||||
runtime, combined_logs_len) | runtime, combined_logs_len) | ||||
save_results_as_junit(test_results, junitouput, runtime) | save_results_as_junit(test_results, junitoutput, runtime) | ||||
if (build_timings is not None): | if (build_timings is not None): | ||||
build_timings.save_timings(test_results) | build_timings.save_timings(test_results) | ||||
if coverage: | if coverage: | ||||
coverage.report_rpc_coverage() | coverage.report_rpc_coverage() | ||||
logging.debug("Cleaning up coverage data") | logging.debug("Cleaning up coverage data") | ||||
▲ Show 20 Lines • Show All 393 Lines • Show Last 20 Lines |
-ju is absolutely non standard. unidashed parameter are uni letters, contrary to double dashed ones.