Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regexes to detect chunked annotations #407

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, this round-trip test would have discovered that titles in test_get_test_lists_from_check_run_chunked_tests were wrong in the first place.

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