(args)
| 373 | |
| 374 | |
| 375 | def run_in_subprocess(args): |
| 376 | # only case args.isolated_cases run in subprocess, all other run in a subprocess |
| 377 | if not args.no_diff: # run based on git diff |
| 378 | try: |
| 379 | test_suite_files = get_selected_cases() |
| 380 | logger.info('Tests suite to run: ') |
| 381 | for f in test_suite_files: |
| 382 | logger.info(f) |
| 383 | except Exception: |
| 384 | logger.error('Get test suite based diff exception!, will run all cases.') |
| 385 | test_suite_files = gather_test_suites_files(os.path.abspath(args.test_dir), args.pattern) |
| 386 | if len(test_suite_files) == 0: |
| 387 | logger.error('Get no test suite based on diff, run all the cases.') |
| 388 | test_suite_files = gather_test_suites_files(os.path.abspath(args.test_dir), args.pattern) |
| 389 | else: |
| 390 | test_suite_files = gather_test_suites_files(os.path.abspath(args.test_dir), args.pattern) |
| 391 | test_suite_files = deduplicate_preserve_order(test_suite_files) |
| 392 | |
| 393 | non_parallelizable_suites = [] |
| 394 | test_suite_files = [x for x in test_suite_files if x not in non_parallelizable_suites] |
| 395 | |
| 396 | run_config = None |
| 397 | isolated_cases = [] |
| 398 | test_suite_env_map = {} |
| 399 | # put all the case in default env. |
| 400 | for test_suite_file in test_suite_files: |
| 401 | test_suite_env_map[test_suite_file] = 'default' |
| 402 | |
| 403 | if args.run_config is not None and Path(args.run_config).exists(): |
| 404 | with open(args.run_config, encoding='utf-8') as f: |
| 405 | run_config = yaml.safe_load(f) |
| 406 | if 'isolated' in run_config: |
| 407 | isolated_cases = run_config['isolated'] |
| 408 | |
| 409 | if 'envs' in run_config: |
| 410 | for env in run_config['envs']: |
| 411 | if env != 'default': |
| 412 | for test_suite in run_config['envs'][env]['tests']: |
| 413 | if test_suite in test_suite_env_map: |
| 414 | test_suite_env_map[test_suite] = env |
| 415 | |
| 416 | if args.subprocess: # run all case in subprocess |
| 417 | isolated_cases = test_suite_files |
| 418 | |
| 419 | with tempfile.TemporaryDirectory() as temp_result_dir: |
| 420 | # first run cases that nonparallelizable |
| 421 | run_non_parallelizable_test_suites(non_parallelizable_suites, temp_result_dir) |
| 422 | |
| 423 | # run case parallel in envs |
| 424 | for env in set(test_suite_env_map.values()): |
| 425 | parallel_run_case_in_env(env, run_config['envs'][env], test_suite_env_map, isolated_cases, temp_result_dir, |
| 426 | args.parallel) |
| 427 | |
| 428 | result_dfs = [] |
| 429 | result_path = Path(temp_result_dir) |
| 430 | for result in result_path.iterdir(): |
| 431 | if Path.is_file(result): |
| 432 | df = pandas.read_pickle(result) |
no test coverage detected