#!/usr/bin/env python3 import os from testlib import clean_binary_tests, build_tests, test_binaries, run_test from concurrent.futures import as_completed, ThreadPoolExecutor TIMES = 10 if __name__ == "__main__": clean_binary_tests() build_tests() binaries = test_binaries(exclude=[r'test_regression-.*']) print(f'========= collected {len(binaries)} test binaries:') print('\n'.join(binaries)) print(f"Run all tests sequentially for {TIMES} times: ") test_with_fails = {} for binary in binaries: fails = [] for i in range(TIMES): exitcode, stdout, stderr = run_test(binary, isolate=False) print(f'Run {binary} {i+1} of {TIMES}, exit code {exitcode}') if exitcode != 0: fails.append(exitcode) if fails: test_with_fails[binary] = fails if test_with_fails: print("Some tests failed: ") for t, f in test_with_fails.items(): print(f'{t} failed {len(f)} times')
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() return (p.returncode, stdout, stderr) if __name__ == "__main__": clean_coverage() clean_binary_tests() build_tests() binaries = test_binaries(exclude=[ r'test_regression-.*', r'near-.*', r'test_cases_runtime-.*', r'test_cases_testnet_rpc-.*', r'test_catchup-.*', r'test_errors-.*', r'test_rejoin-.*', r'test_simple-.*', r'test_tps_regression-.*', ]) errors = False # Run coverage with ThreadPoolExecutor(max_workers=cpu_count()) as executor: future_to_binary = { executor.submit(coverage, binary): binary for binary in binaries } for future in as_completed(future_to_binary): binary = future_to_binary[future]
RERUN_THRESHOLD = 5 def show_test_result(binary, result): print(f'========= test binary {binary}') print(f'========= stdout of {binary}:') print(result[1]) print(f'========= stderr of {binary}:') print(result[2]) if __name__ == "__main__": clean_binary_tests() run_doc_tests() build_tests() binaries = test_binaries( exclude=[r'test_regression-.*', r'near_rpc_error_macro-.*']) print(f'========= collected {len(binaries)} test binaries:') print('\n'.join(binaries)) completed = 0 fails = [] with ThreadPoolExecutor(max_workers=workers()) as executor: future_to_binary = { executor.submit(run_test, binary): binary for binary in binaries } for future in as_completed(future_to_binary): completed += 1 binary_full_name = future_to_binary[future] binary = os.path.basename(binary_full_name) result = future.result()