Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import unittest | 5 import unittest |
| 6 | 6 |
| 7 import chromium_deps | 7 import chromium_deps |
| 8 from common import utils | |
| 8 | 9 |
| 9 | 10 |
| 10 class ChromiumDEPSTest(unittest.TestCase): | 11 class ChromiumDEPSTest(unittest.TestCase): |
| 11 DEPS_TEMPLATE = """ | 12 DEPS_TEMPLATE = """ |
| 12 vars = { | 13 vars = { |
| 13 "googlecode_url": "http://%%s.googlecode.com/svn", | 14 "googlecode_url": "http://%%s.googlecode.com/svn", |
| 14 "webkit_trunk": "http://src.chromium.org/blink/trunk", | 15 "webkit_trunk": "http://src.chromium.org/blink/trunk", |
| 15 "webkit_revision": "%s", | 16 "webkit_revision": "%s", |
| 16 "chromium_git": "https://chromium.googlesource.com", | 17 "chromium_git": "https://chromium.googlesource.com", |
| 17 } | 18 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 29 "src/third_party/liblouis/src": | 30 "src/third_party/liblouis/src": |
| 30 Var("chromium_git") + | 31 Var("chromium_git") + |
| 31 "/external/liblouis.git@%s", | 32 "/external/liblouis.git@%s", |
| 32 } | 33 } |
| 33 } | 34 } |
| 34 """ | 35 """ |
| 35 | 36 |
| 36 def __init__(self, *args, **kwargs): | 37 def __init__(self, *args, **kwargs): |
| 37 super(ChromiumDEPSTest, self).__init__(*args, **kwargs) | 38 super(ChromiumDEPSTest, self).__init__(*args, **kwargs) |
| 38 | 39 |
| 39 def testGetChromiumComponents(self): | 40 def testGetChromiumComponents(self): |
|
aarya
2014/08/26 02:13:53
Can you do the testing on these. these test an int
stgao
2014/08/26 18:35:24
Good suggestion.
I added a new test testComponentR
| |
| 40 chromium_revision = '283296' | 41 chromium_revision = '283296' |
| 42 chromium_revision_git_hash = 'b041fda2e8493dcb26aac08deb493943df240cbb' | |
| 41 webkit_revision = '178200' | 43 webkit_revision = '178200' |
| 42 breakpad_revision = '1345' | 44 breakpad_revision = '1345' |
| 43 liblouis_commit_hashcode = '3c2daee56250162e5a75830871601d74328d39f5' | 45 liblouis_commit_hashcode = '3c2daee56250162e5a75830871601d74328d39f5' |
| 44 | 46 |
| 45 def _GetContentOfDEPS(chromium_revision_tmp): | 47 def _GetContentOfDEPS(chromium_revision_tmp): |
| 46 self.assertEqual(chromium_revision_tmp, chromium_revision) | 48 self.assertEqual(chromium_revision_tmp, chromium_revision_git_hash) |
| 47 return self.DEPS_TEMPLATE % (webkit_revision, breakpad_revision, | 49 return self.DEPS_TEMPLATE % (webkit_revision, breakpad_revision, |
| 48 liblouis_commit_hashcode) | 50 liblouis_commit_hashcode) |
| 49 | 51 |
| 50 expected_results = { | 52 expected_results = { |
| 51 'src/breakpad/src/': { | 53 'src/breakpad/src/': { |
| 52 'path': 'src/breakpad/src/', | 54 'path': 'src/breakpad/src/', |
| 53 'repository_type': 'svn', | 55 'repository_type': 'svn', |
| 54 'name': 'breakpad', | 56 'name': 'breakpad', |
| 55 'repository': 'http://google-breakpad.googlecode.com/svn/trunk/src', | 57 'repository': 'http://google-breakpad.googlecode.com/svn/trunk/src', |
| 56 'revision': breakpad_revision | 58 'revision': breakpad_revision |
| 57 }, | 59 }, |
| 58 'src/third_party/liblouis/src/': { | 60 'src/third_party/liblouis/src/': { |
| 59 'path': 'src/third_party/liblouis/src/', | 61 'path': 'src/third_party/liblouis/src/', |
| 60 'repository_type': 'git', | 62 'repository_type': 'git', |
| 61 'name': 'liblouis', | 63 'name': 'liblouis', |
| 62 'repository': | 64 'repository': |
| 63 'https://chromium.googlesource.com/external/liblouis.git', | 65 'https://chromium.googlesource.com/external/liblouis.git', |
| 64 'revision': liblouis_commit_hashcode | 66 'revision': liblouis_commit_hashcode |
| 65 }, | 67 }, |
| 66 'src/': { | 68 'src/': { |
| 67 'path': 'src/', | 69 'path': 'src/', |
| 68 'repository_type': 'svn', | 70 'repository_type': 'git', |
| 69 'name': 'chromium', | 71 'name': 'chromium', |
| 70 'repository': 'https://src.chromium.org/chrome/trunk', | 72 'repository': 'https://chromium.googlesource.com/chromium/src/', |
| 71 'revision': chromium_revision | 73 'revision': chromium_revision_git_hash |
| 72 }, | 74 }, |
| 73 'src/third_party/WebKit/': { | 75 'src/third_party/WebKit/': { |
| 74 'path': 'src/third_party/WebKit/', | 76 'path': 'src/third_party/WebKit/', |
| 75 'repository_type': 'svn', | 77 'repository_type': 'svn', |
| 76 'name': 'blink', | 78 'name': 'blink', |
| 77 'repository': 'http://src.chromium.org/blink/trunk', | 79 'repository': 'http://src.chromium.org/blink/trunk', |
| 78 'revision': webkit_revision | 80 'revision': webkit_revision |
| 79 } | 81 } |
| 80 } | 82 } |
| 81 | 83 |
| 82 components = chromium_deps.GetChromiumComponents( | 84 components = chromium_deps.GetChromiumComponents( |
| 83 chromium_revision, deps_file_downloader=_GetContentOfDEPS) | 85 chromium_revision, deps_file_downloader=_GetContentOfDEPS) |
| 84 self.assertEqual(expected_results, components) | 86 self.assertEqual(expected_results, components) |
| 85 | 87 |
| 86 def testGetChromiumComponentRange(self): | 88 def testGetChromiumComponentRange(self): |
| 87 chromium_revision1 = '283200' | 89 chromium_revision1 = '283200' |
| 90 chromium_revision_git_hash1 = 'c53c387f46a2ff0cf7c072222b826cff0817a80f' | |
| 88 webkit_revision1 = '178084' | 91 webkit_revision1 = '178084' |
| 89 breakpad_revision1 = '1345' | 92 breakpad_revision1 = '1345' |
| 90 liblouis_commit_hashcode1 = '3c2daee56250162e5a75830871601d74328d39f5' | 93 liblouis_commit_hashcode1 = '3c2daee56250162e5a75830871601d74328d39f5' |
| 91 | 94 |
| 92 chromium_revision2 = '283296' | 95 chromium_revision2 = '283296' |
| 96 chromium_revision_git_hash2 = 'b041fda2e8493dcb26aac08deb493943df240cbb' | |
| 93 webkit_revision2 = '178200' | 97 webkit_revision2 = '178200' |
| 94 breakpad_revision2 = '1345' | 98 breakpad_revision2 = '1345' |
| 95 liblouis_commit_hashcode2 = '3c2daee56250162e5a75830871601d74328d39f5' | 99 liblouis_commit_hashcode2 = '3c2daee56250162e5a75830871601d74328d39f5' |
| 96 | 100 |
| 97 def _GetContentOfDEPS(chromium_revision): | 101 def _GetContentOfDEPS(chromium_revision): |
| 98 chromium_revision = str(chromium_revision) | 102 chromium_revision = str(chromium_revision) |
| 99 if chromium_revision == chromium_revision1: | 103 if chromium_revision == chromium_revision_git_hash1: |
| 100 return self.DEPS_TEMPLATE % (webkit_revision1, breakpad_revision1, | 104 return self.DEPS_TEMPLATE % (webkit_revision1, breakpad_revision1, |
| 101 liblouis_commit_hashcode1) | 105 liblouis_commit_hashcode1) |
| 102 else: | 106 else: |
| 103 self.assertEqual(chromium_revision2, chromium_revision) | 107 self.assertEqual(chromium_revision, chromium_revision_git_hash2) |
| 104 return self.DEPS_TEMPLATE % (webkit_revision2, breakpad_revision2, | 108 return self.DEPS_TEMPLATE % (webkit_revision2, breakpad_revision2, |
| 105 liblouis_commit_hashcode2) | 109 liblouis_commit_hashcode2) |
| 106 | 110 |
| 107 expected_results = { | 111 expected_results = { |
| 108 'src/breakpad/src/': { | 112 'src/breakpad/src/': { |
| 109 'old_revision': breakpad_revision1, | 113 'old_revision': breakpad_revision1, |
| 110 'name': 'breakpad', | 114 'name': 'breakpad', |
| 111 'repository': 'http://google-breakpad.googlecode.com/svn/trunk/src', | 115 'repository': 'http://google-breakpad.googlecode.com/svn/trunk/src', |
| 112 'rolled': False, | 116 'rolled': False, |
| 113 'new_revision': breakpad_revision2, | 117 'new_revision': breakpad_revision2, |
| 114 'path': 'src/breakpad/src/', | 118 'path': 'src/breakpad/src/', |
| 115 'repository_type': 'svn' | 119 'repository_type': 'svn' |
| 116 }, | 120 }, |
| 117 'src/third_party/liblouis/src/': { | 121 'src/third_party/liblouis/src/': { |
| 118 'old_revision': liblouis_commit_hashcode1, | 122 'old_revision': liblouis_commit_hashcode1, |
| 119 'name': 'liblouis', | 123 'name': 'liblouis', |
| 120 'repository': | 124 'repository': |
| 121 'https://chromium.googlesource.com/external/liblouis.git', | 125 'https://chromium.googlesource.com/external/liblouis.git', |
| 122 'rolled': False, | 126 'rolled': False, |
| 123 'new_revision': liblouis_commit_hashcode2, | 127 'new_revision': liblouis_commit_hashcode2, |
| 124 'path': 'src/third_party/liblouis/src/', | 128 'path': 'src/third_party/liblouis/src/', |
| 125 'repository_type': 'git' | 129 'repository_type': 'git' |
| 126 }, | 130 }, |
| 127 'src/': { | 131 'src/': { |
| 128 'old_revision': chromium_revision1, | 132 'old_revision': chromium_revision_git_hash1, |
| 129 'name': 'chromium', | 133 'name': 'chromium', |
| 130 'repository': 'https://src.chromium.org/chrome/trunk', | 134 'repository': 'https://chromium.googlesource.com/chromium/src/', |
| 131 'rolled': True, | 135 'rolled': True, |
| 132 'new_revision': chromium_revision2, | 136 'new_revision': chromium_revision_git_hash2, |
| 133 'path': 'src/', | 137 'path': 'src/', |
| 134 'repository_type': 'svn' | 138 'repository_type': 'git' |
| 135 }, | 139 }, |
| 136 'src/third_party/WebKit/': { | 140 'src/third_party/WebKit/': { |
| 137 'old_revision': webkit_revision1, | 141 'old_revision': webkit_revision1, |
| 138 'name': 'blink', | 142 'name': 'blink', |
| 139 'repository': 'http://src.chromium.org/blink/trunk', | 143 'repository': 'http://src.chromium.org/blink/trunk', |
| 140 'rolled': True, | 144 'rolled': True, |
| 141 'new_revision': webkit_revision2, | 145 'new_revision': webkit_revision2, |
| 142 'path': 'src/third_party/WebKit/', | 146 'path': 'src/third_party/WebKit/', |
| 143 'repository_type': 'svn' | 147 'repository_type': 'svn' |
| 144 } | 148 } |
| 145 } | 149 } |
| 146 | 150 |
| 147 components = chromium_deps.GetChromiumComponentRange( | 151 components = chromium_deps.GetChromiumComponentRange( |
| 148 chromium_revision1, chromium_revision2, | 152 chromium_revision1, chromium_revision2, |
| 149 deps_file_downloader=_GetContentOfDEPS) | 153 deps_file_downloader=_GetContentOfDEPS) |
| 150 self.assertEqual(expected_results, components) | 154 self.assertEqual(expected_results, components) |
| 151 | 155 |
| 156 def _VerifyGitHashForAllComponents(self, deps): | |
| 157 self.assertTrue(isinstance(deps, dict)) | |
| 158 for component in deps.values(): | |
| 159 self.assertTrue(utils.IsGitHash(component['revision'])) | |
| 160 | |
| 152 def testGetSvnRevision(self): | 161 def testGetSvnRevision(self): |
| 162 # For this case, svn revision needs converting to git hash and there will be | |
| 163 # .DEPS.git and DEPS. | |
| 153 deps = chromium_deps.GetChromiumComponents(284750) | 164 deps = chromium_deps.GetChromiumComponents(284750) |
| 154 self.assertTrue(isinstance(deps, dict)) | 165 self._VerifyGitHashForAllComponents(deps) |
| 166 | |
| 167 def testGetGitRevision(self): | |
| 168 # For this case, there is only DEPS, not .DEPS.git. | |
| 169 deps = chromium_deps.GetChromiumComponents( | |
| 170 'f8b3fe9660d8dda318800f55d5e29799bbfd43f7') | |
| 171 self._VerifyGitHashForAllComponents(deps) | |
| 172 | |
| 173 # For this case, there will be .DEPS.git. | |
| 174 deps = chromium_deps.GetChromiumComponents( | |
| 175 '8ae88241aa9f224e8ce97250f32469d616e437aa') | |
| 176 self._VerifyGitHashForAllComponents(deps) | |
| OLD | NEW |