def _run_suites(test_driver_list, args, prepare_only=False): """Runs the indicated suites.""" setup_output_directory(args.output_dir) suite_results.initialize(test_driver_list, args, prepare_only) if not test_driver_list: return False timeout = (args.total_timeout if args.total_timeout and not prepare_only else None) try: with concurrent.ThreadPoolExecutor(args.jobs, daemon=True) as executor: futures = [ executor.submit(_run_driver, driver, args, prepare_only) for driver in test_driver_list ] done, not_done = concurrent.wait(futures, timeout, concurrent.FIRST_EXCEPTION) try: # Iterate over the results to propagate an exception if any of the tasks # aborted by an error in the test drivers. Since such an error is due to # broken script rather than normal failure in tests, we prefer just to # die similarly as when Python errors occurred in the main thread. for future in done: future.result() # No exception was raised but some timed-out tasks are remaining. if not_done: print '@@@STEP_TEXT@Integration test timed out@@@' debug.write_frames(sys.stdout) if args.warn_on_failure: print '@@@STEP_WARNINGS@@@' else: print '@@@STEP_FAILURE@@@' return False # All tests passed (or failed) in time. return True finally: if not_done: _shutdown_unfinished_drivers_gracefully( not_done, test_driver_list) finally: for driver in test_driver_list: driver.finalize(args)
def _run_suites(test_driver_list, args, prepare_only=False): """Runs the indicated suites.""" setup_output_directory(args.output_dir) suite_results.initialize(test_driver_list, args, prepare_only) if not test_driver_list: return False timeout = ( args.total_timeout if args.total_timeout and not prepare_only else None) try: with concurrent.ThreadPoolExecutor(args.jobs, daemon=True) as executor: futures = [executor.submit(_run_driver, driver, args, prepare_only) for driver in test_driver_list] done, not_done = concurrent.wait(futures, timeout, concurrent.FIRST_EXCEPTION) try: # Iterate over the results to propagate an exception if any of the tasks # aborted by an error in the test drivers. Since such an error is due to # broken script rather than normal failure in tests, we prefer just to # die similarly as when Python errors occurred in the main thread. for future in done: future.result() # No exception was raised but some timed-out tasks are remaining. if not_done: print '@@@STEP_TEXT@Integration test timed out@@@' debug.write_frames(sys.stdout) if args.warn_on_failure: print '@@@STEP_WARNINGS@@@' else: print '@@@STEP_FAILURE@@@' return False # All tests passed (or failed) in time. return True finally: if not_done: _shutdown_unfinished_drivers_gracefully(not_done, test_driver_list) finally: for driver in test_driver_list: driver.finalize(args)
def main(raw_args): args = _process_args(raw_args) if args.run_ninja: build_common.run_ninja() test_driver_list = [] for n in xrange(args.repeat_runs): test_driver_list.extend(_get_test_driver_list(args)) if args.plan_report: suite_results.initialize(test_driver_list, args, False) suite_results.report_expected_results( driver.scoreboard for driver in sorted(test_driver_list, key=lambda driver: driver.name)) return 0 elif args.list: pretty_print_tests(args) return 0 elif args.remote: return _run_suites_and_output_results_remote(args, raw_args) else: return _run_suites_and_output_results_local(test_driver_list, args)