Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: tests/git_cl_test.py

Issue 2392463009: git cl try-results for Gerrit. (Closed)
Patch Set: Better message. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/git_cl_test.py
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 987b478a0ec519d500a9c15397d76f57b4924b49..dc654f6e08a7ec520ccfb14b119107daf7f076fd 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -1970,14 +1970,18 @@ class TestGitCl(TestCase):
self.calls = [(('write_json', 'output.json', expected_output), '')]
git_cl.write_try_results_json('output.json', self.BUILDBUCKET_BUILDS_MAP)
- def _setup_fetch_try_jobs_rietveld(self, *request_results):
+ def _setup_fetch_try_jobs(self, most_recent_patchset=20001):
out = StringIO.StringIO()
self.mock(sys, 'stdout', out)
- self.mock(git_cl.Changelist, 'GetMostRecentPatchset', lambda *args: 20001)
+ self.mock(git_cl.Changelist, 'GetMostRecentPatchset',
+ lambda *args: most_recent_patchset)
self.mock(git_cl.auth, 'get_authenticator_for_host', lambda host, _cfg:
self._mocked_call(['get_authenticator_for_host', host]))
self.mock(git_cl, '_buildbucket_retry', lambda *_, **__:
self._mocked_call(['_buildbucket_retry']))
+
+ def _setup_fetch_try_jobs_rietveld(self, *request_results):
+ self._setup_fetch_try_jobs(most_recent_patchset=20001)
self.calls += [
((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
((['git', 'config', 'branch.feature.rietveldissue'],), '1'),
Sergiy Byelozyorov 2016/10/07 15:36:13 shouldn't ((['git', 'config', 'branch.feature.ge
tandrii(chromium) 2016/10/07 15:38:47 No, because it's expectation :) Well, actually if
Sergiy Byelozyorov 2016/10/07 15:39:31 Acknowledged.
@@ -1992,7 +1996,11 @@ class TestGitCl(TestCase):
def test_fetch_try_jobs_none_rietveld(self):
self._setup_fetch_try_jobs_rietveld({})
+ # Simulate that user isn't logged in.
+ self.mock(AuthenticatorMock, 'has_cached_credentials', lambda _: False)
self.assertEqual(0, git_cl.main(['try-results']))
+ self.assertRegexpMatches(sys.stdout.getvalue(),
+ 'Warning: Some results might be missing')
Sergiy Byelozyorov 2016/10/07 15:36:13 why was this logic changed? didn't it work from be
tandrii(chromium) 2016/10/07 15:38:47 I changed the test to have better coverage. Actual
Sergiy Byelozyorov 2016/10/07 15:39:31 Acknowledged.
self.assertRegexpMatches(sys.stdout.getvalue(), 'No try jobs')
def test_fetch_try_jobs_some_rietveld(self):
@@ -2000,7 +2008,44 @@ class TestGitCl(TestCase):
'builds': self.BUILDBUCKET_BUILDS_MAP.values(),
})
self.assertEqual(0, git_cl.main(['try-results']))
- self.assertRegexpMatches(sys.stdout.getvalue(), 'Failures:')
+ self.assertRegexpMatches(sys.stdout.getvalue(), '^Failures:')
+ self.assertRegexpMatches(sys.stdout.getvalue(), 'Started:')
+ self.assertRegexpMatches(sys.stdout.getvalue(), '2 try jobs')
+
+ def _setup_fetch_try_jobs_gerrit(self, *request_results):
+ self._setup_fetch_try_jobs(most_recent_patchset=13)
+ self.calls += [
+ ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
+ ((['git', 'config', 'branch.feature.rietveldissue'],), CERR1),
+ ((['git', 'config', 'branch.feature.gerritissue'],), '1'),
+ # Simulate that Gerrit has more patchsets than local.
+ ((['git', 'config', 'branch.feature.gerritpatchset'],), '12'),
+ ((['git', 'config', 'branch.feature.gerritserver'],),
+ 'https://x-review.googlesource.com'),
+ ((['get_authenticator_for_host', 'x-review.googlesource.com'],),
+ AuthenticatorMock()),
+ ] + [((['_buildbucket_retry'],), r) for r in request_results]
+
+ def test_fetch_try_jobs_none_gerrit(self):
+ self._setup_fetch_try_jobs_gerrit({})
+ self.assertEqual(0, git_cl.main(['try-results']))
+ self.assertRegexpMatches(
+ sys.stdout.getvalue(),
+ r'Warning: Codereview server has newer patchsets \(13\)')
+ self.assertRegexpMatches(sys.stdout.getvalue(), 'No try jobs')
+
+ def test_fetch_try_jobs_some_gerrit(self):
+ self._setup_fetch_try_jobs_gerrit({
+ 'builds': self.BUILDBUCKET_BUILDS_MAP.values(),
+ })
+ # Explicit --patchset means actual local patchset doesn't matter.
+ self.calls.remove(
+ ((['git', 'config', 'branch.feature.gerritpatchset'],), '12'))
+ self.assertEqual(0, git_cl.main(['try-results', '--patchset', '5']))
+
+ # ... and doesn't result in warning.
+ self.assertNotRegexpMatches(sys.stdout.getvalue(), 'Warning')
+ self.assertRegexpMatches(sys.stdout.getvalue(), '^Failures:')
self.assertRegexpMatches(sys.stdout.getvalue(), 'Started:')
self.assertRegexpMatches(sys.stdout.getvalue(), '2 try jobs')
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698