예제 #1
0
    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):
        do_coverage = True
        base_path = cast(str, env.destination_directory)
        rc_path = os.path.join(base_path, 'continuous-integration',
                               '.coveragerc')
        target_path = base_path
        result = shell_tools.run_cmd(env.bin('pytest'),
                                     target_path,
                                     None if verbose else '--quiet',
                                     *([
                                         '--cov', '--cov-report=annotate',
                                         '--cov-config={}'.format(rc_path)
                                     ] if do_coverage else []),
                                     out=shell_tools.TeeCapture(sys.stdout),
                                     raise_on_fail=False,
                                     log_run_to_stderr=verbose)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'Tests passed!'

        last_line = [e for e in output.split('\n') if e.strip()][-1]
        fail_match = re.match('.+=== (\d+) failed', last_line)
        if fail_match is None:
            return False, 'Tests failed.'
        return False, '{} tests failed.'.format(fail_match.group(1))
예제 #2
0
    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):
        base_path = cast(str, env.destination_directory)
        rc_path = os.path.join(base_path,
                               'continuous-integration',
                               '.pylintrc')
        files = list(
            env_tools.get_unhidden_ungenerated_python_files(base_path))

        result = shell_tools.run_cmd(
            env.bin('pylint'),
            '--rcfile={}'.format(rc_path),
            *files,
            out=shell_tools.TeeCapture(sys.stdout),
            raise_on_fail=False,
            log_run_to_stderr=verbose,
            abbreviate_non_option_arguments=True)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'No lint here!'
        file_line_count = len(re.findall(r'\*' * 10, output))
        total_line_count = len([e for e in output.split('\n') if e.strip()])
        issue_count = total_line_count - file_line_count

        return False, '{} issues'.format(issue_count)
예제 #3
0
    def _common_run_helper(env: env_tools.PreparedEnv, coverage: bool,
                           verbose: bool) -> Tuple[bool, str]:
        base_path = cast(str, env.destination_directory)
        target_path = base_path
        result = shell_tools.run_cmd(
            env.bin('pytest'),
            target_path,
            None if verbose else '--quiet',
            '--cov' if coverage else '',
            '--cov-report=annotate' if coverage else '',
            out=shell_tools.TeeCapture(sys.stdout),
            raise_on_fail=False,
            log_run_to_stderr=verbose,
            abbreviate_non_option_arguments=True)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'Converted tests passed!'

        last_line = [e for e in output.split('\n') if e.strip()][-1]
        fail_match = re.match('.+=== (\d+) failed', last_line)
        if fail_match is None:
            return False, 'Tests failed.'
        return False, '{} tests failed.'.format(fail_match.group(1))
예제 #4
0
    def _common_run_helper(env: env_tools.PreparedEnv,
                           coverage: bool,
                           verbose: bool) -> Tuple[bool, str]:
        base_path = cast(str, env.destination_directory)
        target_path = base_path
        result = shell_tools.run_cmd(
            env.bin('pytest'),
            target_path,
            None if verbose else '--quiet',
            '--cov' if coverage else '',
            '--cov-report=annotate' if coverage else '',
            out=shell_tools.TeeCapture(sys.stdout),
            raise_on_fail=False,
            log_run_to_stderr=verbose,
            abbreviate_non_option_arguments=True)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'Converted tests passed!'

        last_line = [e for e in output.split('\n') if e.strip()][-1]
        fail_match = re.match('.+=== (\d+) failed', last_line)
        if fail_match is None:
            return False, 'Tests failed.'
        return False, '{} tests failed.'.format(fail_match.group(1))
예제 #5
0
파일: check_pylint.py 프로젝트: yinxx/Cirq
    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):
        base_path = cast(str, env.destination_directory)
        rc_path = os.path.join(base_path, 'continuous-integration',
                               '.pylintrc')
        files = list(
            env_tools.get_unhidden_ungenerated_python_files(base_path))

        result = shell_tools.run_cmd(env.bin('pylint'),
                                     '--reports=no',
                                     '--score=no',
                                     '--output-format=colorized',
                                     '--rcfile={}'.format(rc_path),
                                     *files,
                                     out=shell_tools.TeeCapture(sys.stdout),
                                     raise_on_fail=False,
                                     log_run_to_stderr=verbose,
                                     abbreviate_non_option_arguments=True)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'No lint here!'
        file_line_count = len(re.findall(r'\*' * 10, output))
        total_line_count = len([e for e in output.split('\n') if e.strip()])
        issue_count = total_line_count - file_line_count

        return False, '{} issues'.format(issue_count)
예제 #6
0
    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):
        do_coverage = True
        base_path = cast(str, env.destination_directory)
        rc_path = os.path.join(base_path,
                               'continuous-integration',
                               '.coveragerc')
        target_path = base_path
        result = shell_tools.run_cmd(
            env.bin('pytest'),
            target_path,
            None if verbose else '--quiet',
            *([
                  '--cov',
                  '--cov-report=annotate',
                  '--cov-config={}'.format(rc_path)
              ] if do_coverage else []),
            out=shell_tools.TeeCapture(sys.stdout),
            raise_on_fail=False,
            log_run_to_stderr=verbose)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'Tests passed!'

        last_line = [e for e in output.split('\n') if e.strip()][-1]
        fail_match = re.match('.+=== (\d+) failed', last_line)
        if fail_match is None:
            return False, 'Tests failed.'
        return False, '{} tests failed.'.format(fail_match.group(1))
예제 #7
0
    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):
        base_path = cast(str, env.destination_directory)
        config_path = os.path.join(base_path, 'dev_tools', 'conf', 'mypy.ini')
        files = list(
            env_tools.get_unhidden_ungenerated_python_files(base_path))

        result = shell_tools.run_cmd(env.bin('mypy'),
                                     '--config-file={}'.format(config_path),
                                     *files,
                                     out=shell_tools.TeeCapture(sys.stdout),
                                     raise_on_fail=False,
                                     log_run_to_stderr=verbose,
                                     abbreviate_non_option_arguments=True)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'Types look good!'
        issue_count = len([e for e in output.split('\n') if e.strip()])

        return False, '{} issues'.format(issue_count)
예제 #8
0
    def perform_check(self, env: env_tools.PreparedEnv, verbose: bool):
        base_path = cast(str, env.destination_directory)
        config_path = os.path.join(base_path,
                                   'continuous-integration',
                                   'mypy.ini')
        files = list(env_tools.get_unhidden_ungenerated_python_files(
            base_path))

        result = shell_tools.run_cmd(
            env.bin('mypy'),
            '--config-file={}'.format(config_path),
            *files,
            out=shell_tools.TeeCapture(sys.stdout),
            raise_on_fail=False,
            log_run_to_stderr=verbose,
            abbreviate_non_option_arguments=True)

        output = cast(str, result[0])
        passed = result[2] == 0
        if passed:
            return True, 'Types look good!'
        issue_count = len([e for e in output.split('\n') if e.strip()])

        return False, '{} issues'.format(issue_count)