Ejemplo n.º 1
0
            # Find tests.
            test_cases = get_test_cases_to_run(tests_dir, tests_root_dir,
                                               excluded_dirs, config, args)
            if not test_cases:
                relative_excluded_dirs = ', '.join(
                    os.path.relpath(dir.path, tests_root_dir.path)
                    for dir in excluded_dirs)
                print_error(
                    'no {}tests found in {} (excluded directories: {})'.format(
                        'critical ' if args.only_critical else '',
                        tests_dir.path, relative_excluded_dirs))
                sys.exit(1)

            # Run them.
            print_prologue(tests_dir.path, test_cases, tested_commit,
                           args.resume)
            tests_results = run_test_cases(
                test_cases,
                tested_commit,
                procs=get_num_of_procs_for_tests(config),
                resume=args.resume,
                lock=lock)
            print_summary(tests_results)

            # Send notifications (if needed).
            if not stop_testing:
                send_email_for_commit_if_needed(config, db, tested_commit)

        sys.exit(0 if tests_results.succeeded else 1)
except Exception:
    logging.exception('unhandled exception')
        test_cases = get_test_cases_to_run(
            tests_dir,
            tests_root_dir,
            excluded_dirs,
            config,
            args
        )
        if not test_cases:
            relative_excluded_dirs = ', '.join(
                os.path.relpath(dir.path, tests_root_dir.path) for dir in excluded_dirs
            )
            print_error('no tests found in {} (excluded directories: {})'.format(
                tests_dir.path,
                relative_excluded_dirs,
            ))
            sys.exit(1)

        # Run them.
        print_prologue(tests_dir.path, test_cases)
        tests_results = run_test_cases(
            test_cases,
            procs=get_num_of_procs_for_tests(config),
            lock=lock
        )
        print_summary(tests_results)

        sys.exit(0 if tests_results.succeeded else 1)
except Exception:
    logging.exception('unhandled exception')
    raise