Skip to content

Commit

Permalink
Fix regexes to detect chunked annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-spacil committed Feb 24, 2023
1 parent 5975303 commit 3be83a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions python/publish/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ def get_test_lists_from_check_run(check_run: Optional[CheckRun]) -> Tuple[Option
if check_run is None:
return None, None

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

all_tests_message_regexp = re.compile(
r'^(There is 1 test, see "Raw output" for the name of the test)|'
Expand Down
27 changes: 23 additions & 4 deletions python/test/test_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,22 +1123,22 @@ def test_get_test_lists_from_check_run_chunked_tests(self):
annotation1.raw_details = None

annotation2 = mock.Mock()
annotation2.title = '4 tests found (tests 1 to 2)'
annotation2.title = '4 tests found (test 1 to 2)'
annotation2.message = 'There are 4 tests, see "Raw output" for the list of tests 1 to 2.'
annotation2.raw_details = 'test one\ntest two'

annotation3 = mock.Mock()
annotation3.title = '4 tests found (tests 3 to 4)'
annotation3.title = '4 tests found (test 3 to 4)'
annotation3.message = 'There are 4 tests, see "Raw output" for the list of tests 3 to 4.'
annotation3.raw_details = 'test three\ntest four'

annotation4 = mock.Mock()
annotation4.title = '4 skipped tests found (tests 1 to 2)'
annotation4.title = '4 skipped tests found (test 1 to 2)'
annotation4.message = 'There are 4 skipped tests, see "Raw output" for the list of skipped tests 1 to 2.'
annotation4.raw_details = 'skip one\nskip two'

annotation5 = mock.Mock()
annotation5.title = '4 skipped tests found (tests 3 to 4)'
annotation5.title = '4 skipped tests found (test 3 to 4)'
annotation5.message = 'There are 4 skipped tests, see "Raw output" for the list of skipped tests 3 to 4.'
annotation5.raw_details = 'skip three\nskip four'

Expand Down Expand Up @@ -1166,6 +1166,25 @@ def test_get_test_lists_from_check_run_none_raw_details(self):
check_run.get_annotations = mock.Mock(return_value=annotations)
self.assertEqual((None, None), Publisher.get_test_lists_from_check_run(check_run))

def test_get_test_lists_from_generated_annotations(self):
cases = create_unit_test_case_results({
(None, 'class', 'test abcd'): {'success': [None]},
(None, 'class', 'test efgh'): {'skipped': [None]},
(None, 'class', 'test ijkl'): {'skipped': [None]},
})

settings = self.create_settings(check_run_annotation=[all_tests_list, skipped_tests_list])
gh = mock.MagicMock()
publisher = Publisher(settings, gh, None)
annotations = publisher.get_test_list_annotations(cases, max_chunk_size=42)

check_run = mock.Mock()
check_run.get_annotations = mock.Mock(return_value=annotations)
self.assertEqual(
(['class ‑ test abcd', 'class ‑ test efgh', 'class ‑ test ijkl'], ['class ‑ test efgh', 'class ‑ test ijkl']),
Publisher.get_test_lists_from_check_run(check_run)
)

def test_publish_check_without_annotations(self):
self.do_test_publish_check_without_base_stats([], [none_annotations])

Expand Down

0 comments on commit 3be83a7

Please sign in to comment.