コード例 #1
0
    def get_test_lists_from_check_run(check_run: Optional[CheckRun]) -> Tuple[Optional[List[str]], Optional[List[str]]]:
        if check_run is None:
            return None, None

        all_tests_annotation: Optional[CheckRunAnnotation] = None
        skipped_tests_annotation: Optional[CheckRunAnnotation] = None

        all_tests_title_regexp = re.compile(r'^\d+ test(s)? found$')
        skipped_tests_title_regexp = re.compile(r'^\d+ skipped test(s)? found$')

        all_tests_message_regexp = re.compile(r'^(There is 1 test, see "Raw output" for the name of the test)|(There are \d+ tests, see "Raw output" for the full list of tests)\.$')
        skipped_tests_message_regexp = re.compile(r'^(There is 1 skipped test, see "Raw output" for the name of the skipped test)|(There are \d+ skipped tests, see "Raw output" for the full list of skipped tests)\.$')

        for annotation in check_run.get_annotations():
            if annotation and annotation.title and annotation.message and annotation.raw_details and \
                    all_tests_title_regexp.match(annotation.title) and \
                    all_tests_message_regexp.match(annotation.message):
                if all_tests_annotation is not None:
                    if annotation:
                        logger.error(f'Found multiple annotation with all tests in check run {check_run.id}: {annotation.raw_details}')
                    return None, None
                all_tests_annotation = annotation

            if annotation and annotation.title and annotation.message and annotation.raw_details and \
                    skipped_tests_title_regexp.match(annotation.title) and \
                    skipped_tests_message_regexp.match(annotation.message):
                if skipped_tests_annotation is not None:
                    if annotation:
                        logger.error(f'Found multiple annotation with skipped tests in check run {check_run.id}: {annotation.raw_details}')
                    return None, None
                skipped_tests_annotation = annotation

        return Publisher.get_test_list_from_annotation(all_tests_annotation), \
               Publisher.get_test_list_from_annotation(skipped_tests_annotation)
コード例 #2
0
    def error(self,
              message: str,
              file: Optional[str] = None,
              line: Optional[int] = None,
              column: Optional[int] = None) -> str:
        logger.error(message)

        params = {}
        if file is not None:
            params.update(file=file)
        if line is not None:
            params.update(line=line)
        if column is not None:
            params.update(col=column)
        return self._command(self._file, 'error', message, params)