Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_runner.py
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | def run(self, portseed_offset): | ||||
log_stdout = tempfile.SpooledTemporaryFile(max_size=2**16) | log_stdout = tempfile.SpooledTemporaryFile(max_size=2**16) | ||||
log_stderr = tempfile.SpooledTemporaryFile(max_size=2**16) | log_stderr = tempfile.SpooledTemporaryFile(max_size=2**16) | ||||
test_argv = t.split() | test_argv = t.split() | ||||
testdir = os.path.join("{}", "{}_{}").format( | testdir = os.path.join("{}", "{}_{}").format( | ||||
self.tmpdir, re.sub(".py$", "", test_argv[0]), portseed) | self.tmpdir, re.sub(".py$", "", test_argv[0]), portseed) | ||||
tmpdir_arg = ["--tmpdir={}".format(testdir)] | tmpdir_arg = ["--tmpdir={}".format(testdir)] | ||||
name = t | name = t | ||||
time0 = time.time() | time0 = time.time() | ||||
process = subprocess.Popen([os.path.join(self.tests_dir, test_argv[0])] + test_argv[1:] + self.flags + portseed_arg + tmpdir_arg, | process = subprocess.Popen([sys.executable, os.path.join(self.tests_dir, test_argv[0])] + test_argv[1:] + self.flags + portseed_arg + tmpdir_arg, | ||||
universal_newlines=True, | universal_newlines=True, | ||||
stdout=log_stdout, | stdout=log_stdout, | ||||
stderr=log_stderr) | stderr=log_stderr) | ||||
process.wait() | process.wait() | ||||
log_stdout.seek(0), log_stderr.seek(0) | log_stdout.seek(0), log_stderr.seek(0) | ||||
[stdout, stderr] = [l.read().decode('utf-8') | [stdout, stderr] = [l.read().decode('utf-8') | ||||
for l in (log_stdout, log_stderr)] | for l in (log_stdout, log_stderr)] | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | if not test_list: | ||||
"of the test lists in test_runner.py, or run test_runner.py with no arguments to run all tests") | "of the test lists in test_runner.py, or run test_runner.py with no arguments to run all tests") | ||||
sys.exit(0) | sys.exit(0) | ||||
if args.help: | if args.help: | ||||
# Print help for test_runner.py, then print help of the first script | # Print help for test_runner.py, then print help of the first script | ||||
# and exit. | # and exit. | ||||
parser.print_help() | parser.print_help() | ||||
subprocess.check_call( | subprocess.check_call( | ||||
[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.junitouput, | ||||
tmpdir, args.jobs, args.coverage, passon_args, args.combinedlogslen, build_timings) | tmpdir, args.jobs, args.coverage, passon_args, args.combinedlogslen, build_timings) | ||||
Show All 24 Lines | if enable_coverage: | ||||
logging.debug( | logging.debug( | ||||
"Initializing coverage directory at {}".format(coverage.dir)) | "Initializing coverage directory at {}".format(coverage.dir)) | ||||
else: | else: | ||||
coverage = None | coverage = None | ||||
if len(test_list) > 1 and num_jobs > 1: | if len(test_list) > 1 and num_jobs > 1: | ||||
# Populate cache | # Populate cache | ||||
try: | try: | ||||
subprocess.check_output( | subprocess.check_output([sys.executable, os.path.join( | ||||
[os.path.join(tests_dir, 'create_cache.py')] + flags + [os.path.join("--tmpdir={}", "cache") .format(tmpdir)]) | tests_dir, 'create_cache.py')] + flags + [os.path.join("--tmpdir={}", "cache") .format(tmpdir)]) | ||||
except subprocess.CalledProcessError as e: | except subprocess.CalledProcessError as e: | ||||
sys.stdout.buffer.write(e.output) | sys.stdout.buffer.write(e.output) | ||||
raise | raise | ||||
# Run Tests | # Run Tests | ||||
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) | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | for test_result in test_results: | ||||
testdir = test_result.testdir | testdir = test_result.testdir | ||||
if combined_logs_len and os.path.isdir(testdir): | if combined_logs_len and os.path.isdir(testdir): | ||||
# Print the final `combinedlogslen` lines of the combined logs | # Print the final `combinedlogslen` lines of the combined logs | ||||
print('{}Combine the logs and print the last {} lines ...{}'.format( | print('{}Combine the logs and print the last {} lines ...{}'.format( | ||||
BOLD[1], combined_logs_len, BOLD[0])) | BOLD[1], combined_logs_len, BOLD[0])) | ||||
print('\n============') | print('\n============') | ||||
print('{}Combined log for {}:{}'.format(BOLD[1], testdir, BOLD[0])) | print('{}Combined log for {}:{}'.format(BOLD[1], testdir, BOLD[0])) | ||||
print('============\n') | print('============\n') | ||||
combined_logs, _ = subprocess.Popen([os.path.join( | combined_logs, _ = subprocess.Popen([sys.executable, os.path.join( | ||||
tests_dir, 'combine_logs.py'), '-c', testdir], universal_newlines=True, stdout=subprocess.PIPE).communicate() | tests_dir, 'combine_logs.py'), '-c', testdir], universal_newlines=True, stdout=subprocess.PIPE).communicate() | ||||
print("\n".join(deque(combined_logs.splitlines(), combined_logs_len))) | print("\n".join(deque(combined_logs.splitlines(), combined_logs_len))) | ||||
status = TICK + "Passed" if all_passed else CROSS + "Failed" | status = TICK + "Passed" if all_passed else CROSS + "Failed" | ||||
results += BOLD[1] + "\n{} | {} | {} s (accumulated) \n".format( | results += BOLD[1] + "\n{} | {} | {} s (accumulated) \n".format( | ||||
"ALL".ljust(max_len_name), status.ljust(9), time_sum) + BOLD[0] | "ALL".ljust(max_len_name), status.ljust(9), time_sum) + BOLD[0] | ||||
results += "Runtime: {} s\n".format(runtime) | results += "Runtime: {} s\n".format(runtime) | ||||
print(results) | print(results) | ||||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |