aboutsummaryrefslogtreecommitdiff
path: root/pgo_tools/monitor_pgo_profiles_unittest.py
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2022-01-06 07:57:46 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-01-06 07:57:46 +0000
commit6323407a0d9e34a73fa3cfb9925f9a16333b4e68 (patch)
treecf4cdad04e1c146844e2a790910cf9cd1b97082a /pgo_tools/monitor_pgo_profiles_unittest.py
parentf103b9f78baa21b4edf25d5dd5a1226b6c0ff159 (diff)
parent7bc245bad95c6f4c15bc3f819f61312705b59a5a (diff)
downloadtoolchain-utils-6323407a0d9e34a73fa3cfb9925f9a16333b4e68.tar.gz
Merging 32 commit(s) from Chromium's toolchain-utils am: 7bc245bad9
Original change: https://android-review.googlesource.com/c/platform/external/toolchain-utils/+/1937961 Change-Id: I0587f6c9c76cdd81d4563a5f94e5ef0e8ca5a94f
Diffstat (limited to 'pgo_tools/monitor_pgo_profiles_unittest.py')
-rwxr-xr-xpgo_tools/monitor_pgo_profiles_unittest.py74
1 files changed, 33 insertions, 41 deletions
diff --git a/pgo_tools/monitor_pgo_profiles_unittest.py b/pgo_tools/monitor_pgo_profiles_unittest.py
index b4e085ec..eef33887 100755
--- a/pgo_tools/monitor_pgo_profiles_unittest.py
+++ b/pgo_tools/monitor_pgo_profiles_unittest.py
@@ -11,41 +11,36 @@ import unittest
import unittest.mock
import monitor_pgo_profiles
-from cros_utils import tiny_render
class Test(unittest.TestCase):
"""Tests for monitor_pgo_profiles."""
+ def test_compose_complaint_with_zero_out_of_date(self):
+ self.assertIsNone(monitor_pgo_profiles.compose_complaint([]))
- def test_compose_complaint_email_with_zero_out_of_date(self):
- self.assertIsNone(monitor_pgo_profiles.compose_complaint_email([]))
-
- def test_compose_complaint_email_with_one_out_of_date(self):
+ def test_compose_complaint_with_one_out_of_date(self):
profdata_info = monitor_pgo_profiles.ProfdataInfo(
date=datetime.datetime(2020, 1, 2, 3, 4, 5),
location='gs://somewhere',
)
- result = monitor_pgo_profiles.compose_complaint_email([
+ result = monitor_pgo_profiles.compose_complaint([
('some_arch', profdata_info),
])
- self.assertEqual(result, ('1 llvm profile is out of date', [
- 'out-of-date profile:',
- tiny_render.UnorderedList([
- f'some_arch (most recent profile was from {profdata_info.date} at '
- f'{profdata_info.location!r})'
- ]),
- tiny_render.line_break,
- tiny_render.line_break,
- 'PTAL to see if the llvm-pgo-generate bots are functioning normally. '
- 'Their status can be found at ',
- tiny_render.Link(
- href=monitor_pgo_profiles.PGO_BUILDBOT_LINK,
- inner=monitor_pgo_profiles.PGO_BUILDBOT_LINK,
- ),
- '.',
- ]))
+ self.assertEqual(
+ result,
+ '\n'.join((
+ '1 profile is out of date:',
+ f'- some_arch (most recent profile was from {profdata_info.date} '
+ f'at {profdata_info.location!r})',
+ '',
+ '',
+ 'PTAL to see if the llvm-pgo-generate bots are functioning '
+ 'normally. Their status can be found at '
+ f'{monitor_pgo_profiles.PGO_BUILDBOT_LINK}.',
+ )),
+ )
- def test_compose_complaint_email_with_two_out_of_date(self):
+ def test_compose_complaint_with_two_out_of_date(self):
profdata_info_1 = monitor_pgo_profiles.ProfdataInfo(
date=datetime.datetime(2020, 1, 2, 3, 4, 5),
location='gs://somewhere',
@@ -54,28 +49,25 @@ class Test(unittest.TestCase):
date=datetime.datetime(2020, 3, 2, 1, 4, 5),
location='gs://somewhere-else',
)
- result = monitor_pgo_profiles.compose_complaint_email([
+ result = monitor_pgo_profiles.compose_complaint([
('some_arch', profdata_info_1),
('some_other_arch', profdata_info_2),
])
- self.assertEqual(result, ('2 llvm profiles are out of date', [
- 'out-of-date profiles:',
- tiny_render.UnorderedList([
- f'some_arch (most recent profile was from {profdata_info_1.date} '
+ self.assertEqual(
+ result,
+ '\n'.join((
+ '2 profiles are out of date:',
+ f'- some_arch (most recent profile was from {profdata_info_1.date} '
f'at {profdata_info_1.location!r})',
- f'some_other_arch (most recent profile was from '
- f'{profdata_info_2.date} at {profdata_info_2.location!r})'
- ]),
- tiny_render.line_break,
- tiny_render.line_break,
- 'PTAL to see if the llvm-pgo-generate bots are functioning normally. '
- 'Their status can be found at ',
- tiny_render.Link(
- href=monitor_pgo_profiles.PGO_BUILDBOT_LINK,
- inner=monitor_pgo_profiles.PGO_BUILDBOT_LINK,
- ),
- '.',
- ]))
+ f'- some_other_arch (most recent profile was from '
+ f'{profdata_info_2.date} at {profdata_info_2.location!r})',
+ '',
+ '',
+ 'PTAL to see if the llvm-pgo-generate bots are functioning '
+ 'normally. Their status can be found at '
+ f'{monitor_pgo_profiles.PGO_BUILDBOT_LINK}.',
+ )),
+ )
@unittest.mock.patch.object(subprocess, 'run')
def test_fetching_profdata_functions(self, subprocess_run_mock):