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

Side by Side Diff: tests/git_cl_test.py

Issue 2147563003: git cl try: Trigger CQ Dry Run by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Explain what happened on success. Created 4 years, 5 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 unified diff | Download patch
« git_cl.py ('K') | « git_cl.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for git_cl.py.""" 6 """Unit tests for git_cl.py."""
7 7
8 import os 8 import os
9 import StringIO 9 import StringIO
10 import stat 10 import stat
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 ((['git', 'config', '--unset', 'branch.feature.gerritpatchset'],), ''), 1653 ((['git', 'config', '--unset', 'branch.feature.gerritpatchset'],), ''),
1654 # Let this command raise exception (retcode=1) - it should be ignored. 1654 # Let this command raise exception (retcode=1) - it should be ignored.
1655 ((['git', 'config', '--unset', 'branch.feature.last-upload-hash'],), 1655 ((['git', 'config', '--unset', 'branch.feature.last-upload-hash'],),
1656 '', subprocess2.CalledProcessError(1, '', '', '', '')), 1656 '', subprocess2.CalledProcessError(1, '', '', '', '')),
1657 ((['git', 'config', '--unset', 'branch.feature.gerritserver'],), ''), 1657 ((['git', 'config', '--unset', 'branch.feature.gerritserver'],), ''),
1658 ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],), 1658 ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],),
1659 ''), 1659 ''),
1660 ] 1660 ]
1661 self.assertEqual(0, git_cl.main(['issue', '0'])) 1661 self.assertEqual(0, git_cl.main(['issue', '0']))
1662 1662
1663 def test_git_cl_try_default(self):
1664 self.mock(git_cl.Changelist, 'GetChange',
1665 lambda _, *a: (
1666 self._mocked_call(['GetChange']+list(a))))
1667 self.mock(git_cl.presubmit_support, 'DoGetTryMasters',
1668 lambda *_, **__: (
1669 self._mocked_call(['DoGetTryMasters'])))
1670 self.mock(git_cl.presubmit_support, 'DoGetTrySlaves',
1671 lambda *_, **__: (
1672 self._mocked_call(['DoGetTrySlaves'])))
1673 self.mock(git_cl._RietveldChangelistImpl, 'SetCQState',
1674 lambda _, s: self._mocked_call(['SetCQState', s]))
1675 self.calls = [
1676 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
1677 ((['git', 'config', 'branch.feature.rietveldissue'],), '123'),
1678 ((['git', 'config', 'rietveld.autoupdate'],), ''),
1679 ((['git', 'config', 'rietveld.server'],),
1680 'https://codereview.chromium.org'),
1681 ((['git', 'config', 'branch.feature.rietveldserver'],), ''),
1682 ((['git', 'config', 'branch.feature.merge'],), 'feature'),
1683 ((['git', 'config', 'branch.feature.remote'],), 'origin'),
1684 ((['get_or_create_merge_base', 'feature', 'feature'],),
1685 'fake_ancestor_sha'),
1686 ((['GetChange', 'fake_ancestor_sha', None], ),
1687 git_cl.presubmit_support.GitChange(
1688 '', '', '', '', '', '', '', '')),
1689 ((['git', 'rev-parse', '--show-cdup'],), '../'),
1690 ((['DoGetTryMasters'], ), None),
1691 ((['DoGetTrySlaves'], ), None),
1692 ((['SetCQState', git_cl._CQState.DRY_RUN], ), None),
1693 ]
1694 out = StringIO.StringIO()
1695 self.mock(git_cl.sys, 'stdout', out)
1696 self.assertEqual(0, git_cl.main(['try']))
1697 self.assertEqual(
1698 out.getvalue(),
1699 'scheduled CQ Dry Run on https://codereview.chromium.org/123\n')
1700
1663 def _common_GerritCommitMsgHookCheck(self): 1701 def _common_GerritCommitMsgHookCheck(self):
1664 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) 1702 self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
1665 self.mock(git_cl.os.path, 'abspath', 1703 self.mock(git_cl.os.path, 'abspath',
1666 lambda path: self._mocked_call(['abspath', path])) 1704 lambda path: self._mocked_call(['abspath', path]))
1667 self.mock(git_cl.os.path, 'exists', 1705 self.mock(git_cl.os.path, 'exists',
1668 lambda path: self._mocked_call(['exists', path])) 1706 lambda path: self._mocked_call(['exists', path]))
1669 self.mock(git_cl.gclient_utils, 'FileRead', 1707 self.mock(git_cl.gclient_utils, 'FileRead',
1670 lambda path: self._mocked_call(['FileRead', path])) 1708 lambda path: self._mocked_call(['FileRead', path]))
1671 self.mock(git_cl.gclient_utils, 'rm_file_or_tree', 1709 self.mock(git_cl.gclient_utils, 'rm_file_or_tree',
1672 lambda path: self._mocked_call(['rm_file_or_tree', path])) 1710 lambda path: self._mocked_call(['rm_file_or_tree', path]))
(...skipping 29 matching lines...) Expand all
1702 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), 1740 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],),
1703 ''), 1741 ''),
1704 ] 1742 ]
1705 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) 1743 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True)
1706 1744
1707 1745
1708 if __name__ == '__main__': 1746 if __name__ == '__main__':
1709 git_cl.logging.basicConfig( 1747 git_cl.logging.basicConfig(
1710 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) 1748 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
1711 unittest.main() 1749 unittest.main()
OLDNEW
« git_cl.py ('K') | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698