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

Unified Diff: tests/git_cl_test.py

Issue 1191473002: [depot_tools] New "git cl upload" flag to traverse dependent branches and re-upload them (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix lint Created 5 years, 6 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 b19e45c90d5b81a5998604771ea4e22c73e2eb1e..293523daa095e7e08de0fb747430d9b88b89a5c3 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -696,6 +696,54 @@ class TestGitCl(TestCase):
squash=True,
expected_upstream_ref='origin/master')
+ def test_upload_branch_deps(self):
+ def mock_run_git(*args, **_kwargs):
+ if args[0] == ['for-each-ref',
+ '--format=%(refname:short) %(upstream:short)',
+ 'refs/heads']:
+ # Create a local branch dependency tree that looks like this:
+ # test1 -> test2 -> test3 -> test4 -> test5
+ # -> test3.1
+ # test6 -> test0
+ branch_deps = [
+ 'test2 test1', # test1 -> test2
+ 'test3 test2', # test2 -> test3
+ 'test3.1 test2', # test2 -> test3.1
+ 'test4 test3', # test3 -> test4
+ 'test5 test4', # test4 -> test5
+ 'test6 test0', # test0 -> test6
+ 'test7', # test7
+ ]
+ return '\n'.join(branch_deps)
+ self.mock(git_cl, 'RunGit', mock_run_git)
+
+ class RecordCalls:
+ times_called = 0
+ record_calls = RecordCalls()
+ def mock_CMDupload(*args, **_kwargs):
+ record_calls.times_called += 1
+ return 0
+ self.mock(git_cl, 'CMDupload', mock_CMDupload)
+
+ self.calls = [
+ (('[Press enter to continue or ctrl-C to quit]',), ''),
+ ]
+
+ class MockChangelist():
+ def __init__(self):
+ pass
+ def GetBranch(self):
+ return 'test1'
+ def GetIssue(self):
+ return '123'
+ def GetPatchset(self):
+ return '1001'
+
+ ret = git_cl.upload_branch_deps(MockChangelist(), [])
+ # CMDupload should have been called 5 times because of 5 dependent branches.
+ self.assertEquals(5, record_calls.times_called)
+ self.assertEquals(0, ret)
+
def test_config_gerrit_download_hook(self):
self.mock(git_cl, 'FindCodereviewSettingsFile', CodereviewSettingsFileMock)
def ParseCodereviewSettingsContent(content):
« 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