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
3 # found in the LICENSE file.
8 from common
import utils
11 class ChromiumDEPSTest(unittest
.TestCase
):
14 "googlecode_url": "http://%%s.googlecode.com/svn",
15 "webkit_trunk": "http://src.chromium.org/blink/trunk",
16 "webkit_revision": "%s",
17 "chromium_git": "https://chromium.googlesource.com",
22 (Var("googlecode_url") %% "google-breakpad") + "/trunk/src@%s",
24 "src/third_party/WebKit":
25 Var("webkit_trunk") + "@" + Var("webkit_revision"),
30 "src/third_party/liblouis/src":
32 "/external/liblouis.git@%s",
37 def __init__(self
, *args
, **kwargs
):
38 super(ChromiumDEPSTest
, self
).__init
__(*args
, **kwargs
)
40 def testGetChromiumComponents(self
):
41 chromium_revision
= '283296'
42 chromium_revision_git_hash
= 'b041fda2e8493dcb26aac08deb493943df240cbb'
43 webkit_revision
= '178200'
44 breakpad_revision
= '1345'
45 liblouis_commit_hashcode
= '3c2daee56250162e5a75830871601d74328d39f5'
47 def _GetContentOfDEPS(chromium_revision_tmp
):
48 self
.assertEqual(chromium_revision_tmp
, chromium_revision_git_hash
)
49 return self
.DEPS_TEMPLATE
% (webkit_revision
, breakpad_revision
,
50 liblouis_commit_hashcode
)
53 'src/breakpad/src/': {
54 'path': 'src/breakpad/src/',
55 'repository_type': 'svn',
57 'repository': 'http://google-breakpad.googlecode.com/svn/trunk/src',
58 'revision': breakpad_revision
60 'src/third_party/liblouis/src/': {
61 'path': 'src/third_party/liblouis/src/',
62 'repository_type': 'git',
65 'https://chromium.googlesource.com/external/liblouis.git',
66 'revision': liblouis_commit_hashcode
70 'repository_type': 'git',
72 'repository': 'https://chromium.googlesource.com/chromium/src/',
73 'revision': chromium_revision_git_hash
75 'src/third_party/WebKit/': {
76 'path': 'src/third_party/WebKit/',
77 'repository_type': 'svn',
79 'repository': 'http://src.chromium.org/blink/trunk',
80 'revision': webkit_revision
84 components
= chromium_deps
.GetChromiumComponents(
85 chromium_revision
, deps_file_downloader
=_GetContentOfDEPS
)
86 self
.assertEqual(expected_results
, components
)
88 def testGetChromiumComponentRange(self
):
89 chromium_revision1
= '283200'
90 chromium_revision_git_hash1
= 'c53c387f46a2ff0cf7c072222b826cff0817a80f'
91 webkit_revision1
= '178084'
92 breakpad_revision1
= '1345'
93 liblouis_commit_hashcode1
= '3c2daee56250162e5a75830871601d74328d39f5'
95 chromium_revision2
= '283296'
96 chromium_revision_git_hash2
= 'b041fda2e8493dcb26aac08deb493943df240cbb'
97 webkit_revision2
= '178200'
98 breakpad_revision2
= '1345'
99 liblouis_commit_hashcode2
= '3c2daee56250162e5a75830871601d74328d39f5'
101 def _GetContentOfDEPS(chromium_revision
):
102 chromium_revision
= str(chromium_revision
)
103 if chromium_revision
== chromium_revision_git_hash1
:
104 return self
.DEPS_TEMPLATE
% (webkit_revision1
, breakpad_revision1
,
105 liblouis_commit_hashcode1
)
107 self
.assertEqual(chromium_revision
, chromium_revision_git_hash2
)
108 return self
.DEPS_TEMPLATE
% (webkit_revision2
, breakpad_revision2
,
109 liblouis_commit_hashcode2
)
112 'src/breakpad/src/': {
113 'old_revision': breakpad_revision1
,
115 'repository': 'http://google-breakpad.googlecode.com/svn/trunk/src',
117 'new_revision': breakpad_revision2
,
118 'path': 'src/breakpad/src/',
119 'repository_type': 'svn'
121 'src/third_party/liblouis/src/': {
122 'old_revision': liblouis_commit_hashcode1
,
125 'https://chromium.googlesource.com/external/liblouis.git',
127 'new_revision': liblouis_commit_hashcode2
,
128 'path': 'src/third_party/liblouis/src/',
129 'repository_type': 'git'
132 'old_revision': chromium_revision_git_hash1
,
134 'repository': 'https://chromium.googlesource.com/chromium/src/',
136 'new_revision': chromium_revision_git_hash2
,
138 'repository_type': 'git'
140 'src/third_party/WebKit/': {
141 'old_revision': webkit_revision1
,
143 'repository': 'http://src.chromium.org/blink/trunk',
145 'new_revision': webkit_revision2
,
146 'path': 'src/third_party/WebKit/',
147 'repository_type': 'svn'
151 components
= chromium_deps
.GetChromiumComponentRange(
152 chromium_revision1
, chromium_revision2
,
153 deps_file_downloader
=_GetContentOfDEPS
)
154 self
.assertEqual(expected_results
, components
)
156 def _VerifyGitHashForAllComponents(self
, deps
):
157 self
.assertTrue(deps
)
158 self
.assertTrue(isinstance(deps
, dict))
159 for component
in deps
.values():
160 for key
in ['revision', 'old_revision', 'new_revision']:
162 self
.assertTrue(utils
.IsGitHash(component
[key
]))
164 def testComponentRangeCrossGitMigrationPoint(self
):
165 # The old revision is from svn.
166 # The new revision is from git.
167 deps
= chromium_deps
.GetChromiumComponentRange(
169 '744746cc51ef81c8f8d727fafa46b14d1c03fe44')
170 self
._VerifyGitHashForAllComponents
(deps
)
172 def testGetSvnRevision(self
):
173 # For this case, svn revision needs converting to git hash and there will be
174 # .DEPS.git and DEPS.
175 deps
= chromium_deps
.GetChromiumComponents(284750)
176 self
._VerifyGitHashForAllComponents
(deps
)
178 def testGetGitRevisionWithoutDEPS_dot_GIT(self
):
179 # For this case, there is only DEPS, not .DEPS.git.
180 deps
= chromium_deps
.GetChromiumComponents(
181 'f8b3fe9660d8dda318800f55d5e29799bbfd43f7')
182 self
._VerifyGitHashForAllComponents
(deps
)
185 def testGetGitRevisionWithDEPS_dot_GIT(self
):
186 # For this case, there will be .DEPS.git.
187 deps
= chromium_deps
.GetChromiumComponents(
188 '8ae88241aa9f224e8ce97250f32469d616e437aa')
189 self
._VerifyGitHashForAllComponents
(deps
)