OLD | NEW |
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 import copy | 6 import copy |
7 import datetime | 7 import datetime |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import subprocess | 10 import subprocess |
(...skipping 20 matching lines...) Expand all Loading... |
31 BETA = 'beta' | 31 BETA = 'beta' |
32 DEV = 'dev' | 32 DEV = 'dev' |
33 CANARY = 'canary' | 33 CANARY = 'canary' |
34 | 34 |
35 | 35 |
36 def GetArchiveUrl(host_os, version): | 36 def GetArchiveUrl(host_os, version): |
37 basename = 'naclsdk_%s.bz2' % (host_os,) | 37 basename = 'naclsdk_%s.bz2' % (host_os,) |
38 return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename)) | 38 return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename)) |
39 | 39 |
40 | 40 |
| 41 def MakeGsUrl(rel_path): |
| 42 return update_nacl_manifest.GS_BUCKET_PATH + rel_path |
| 43 |
| 44 |
41 def GetPathFromGsUrl(url): | 45 def GetPathFromGsUrl(url): |
42 assert url.startswith(update_nacl_manifest.GS_BUCKET_PATH) | 46 assert url.startswith(update_nacl_manifest.GS_BUCKET_PATH) |
43 return url[len(update_nacl_manifest.GS_BUCKET_PATH):] | 47 return url[len(update_nacl_manifest.GS_BUCKET_PATH):] |
44 | 48 |
45 | 49 |
46 def GetPathFromHttpsUrl(url): | 50 def GetPathFromHttpsUrl(url): |
47 assert url.startswith(HTTPS_BASE_URL) | 51 assert url.startswith(HTTPS_BASE_URL) |
48 return url[len(HTTPS_BASE_URL):] | 52 return url[len(HTTPS_BASE_URL):] |
49 | 53 |
50 | 54 |
(...skipping 19 matching lines...) Expand all Loading... |
70 for host_os in OS_MLW: | 74 for host_os in OS_MLW: |
71 archive = manifest_util.Archive(host_os) | 75 archive = manifest_util.Archive(host_os) |
72 archive.url = 'http://example.com' | 76 archive.url = 'http://example.com' |
73 archive.checksum = {'sha1': 'blah'} | 77 archive.checksum = {'sha1': 'blah'} |
74 archive.size = 2 | 78 archive.size = 2 |
75 bundle.AddArchive(archive) | 79 bundle.AddArchive(archive) |
76 return bundle | 80 return bundle |
77 | 81 |
78 | 82 |
79 def MakeBundle(major_version, revision, version=None, host_oses=None): | 83 def MakeBundle(major_version, revision, version=None, host_oses=None): |
80 assert version is None or version.split('.')[0] == major_version | 84 assert version is None or version.split('.')[0] == str(major_version) |
81 bundle_name = 'pepper_' + major_version | 85 bundle_name = 'pepper_' + str(major_version) |
82 bundle = manifest_util.Bundle(bundle_name) | 86 bundle = manifest_util.Bundle(bundle_name) |
83 bundle.version = int(major_version) | 87 bundle.version = major_version |
84 bundle.revision = revision | 88 bundle.revision = revision |
85 bundle.description = 'Chrome %s bundle, revision %s' % (major_version, | 89 bundle.description = 'Chrome %s bundle, revision %s' % (major_version, |
86 revision) | 90 revision) |
87 bundle.repath = bundle_name | 91 bundle.repath = bundle_name |
88 bundle.recommended = 'no' | 92 bundle.recommended = 'no' |
89 bundle.stability = 'dev' | 93 bundle.stability = 'dev' |
90 | 94 |
91 if host_oses: | 95 if host_oses: |
92 for host_os in host_oses: | 96 for host_os in host_oses: |
93 bundle.AddArchive(MakeArchive(host_os, version)) | 97 bundle.AddArchive(MakeArchive(host_os, version)) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return self.manifest | 153 return self.manifest |
150 | 154 |
151 def GetHistory(self): | 155 def GetHistory(self): |
152 return self.history | 156 return self.history |
153 | 157 |
154 def GsUtil_ls(self, url): | 158 def GsUtil_ls(self, url): |
155 path = GetPathFromGsUrl(url) | 159 path = GetPathFromGsUrl(url) |
156 result = [] | 160 result = [] |
157 for filename, _ in self.files.iteritems(): | 161 for filename, _ in self.files.iteritems(): |
158 if filename.startswith(path): | 162 if filename.startswith(path): |
159 result.append(filename) | 163 result.append(MakeGsUrl(filename)) |
160 return result | 164 return result |
161 | 165 |
162 def GsUtil_cat(self, url): | 166 def GsUtil_cat(self, url): |
163 path = GetPathFromGsUrl(url) | 167 path = GetPathFromGsUrl(url) |
164 if path not in self.files: | 168 if path not in self.files: |
165 raise subprocess.CalledProcessError(1, 'gsutil cat %s' % (url,)) | 169 raise subprocess.CalledProcessError(1, 'gsutil cat %s' % (url,)) |
166 return self.files[path] | 170 return self.files[path] |
167 | 171 |
168 def GsUtil_cp(self, src, dest, stdin=None): | 172 def GsUtil_cp(self, src, dest, stdin=None): |
169 dest_path = GetPathFromGsUrl(dest) | 173 dest_path = GetPathFromGsUrl(dest) |
170 if src == '-': | 174 if src == '-': |
171 self.files[dest_path] = stdin | 175 self.files[dest_path] = stdin |
172 else: | 176 else: |
173 src_path = GetPathFromGsUrl(src) | 177 src_path = GetPathFromGsUrl(src) |
174 if src_path not in self.files: | 178 if src_path not in self.files: |
175 raise subprocess.CalledProcessError(1, 'gsutil cp %s %s' % (src, dest)) | 179 raise subprocess.CalledProcessError(1, 'gsutil cp %s %s' % (src, dest)) |
176 self.files[dest_path] = self.files[src_path] | 180 self.files[dest_path] = self.files[src_path] |
177 | 181 |
178 def Print(self, *args): | 182 def Print(self, *args): |
179 # eat all informational messages | 183 # eat all informational messages |
180 pass | 184 pass |
181 | 185 |
182 | 186 |
183 # Shorthand for premade bundles/versions | 187 # Shorthand for premade bundles/versions |
184 V18_0_1025_163 = '18.0.1025.163' | 188 V18_0_1025_163 = '18.0.1025.163' |
185 V18_0_1025_175 = '18.0.1025.175' | 189 V18_0_1025_175 = '18.0.1025.175' |
186 V18_0_1025_184 = '18.0.1025.184' | 190 V18_0_1025_184 = '18.0.1025.184' |
187 V19_0_1084_41 = '19.0.1084.41' | 191 V19_0_1084_41 = '19.0.1084.41' |
188 V19_0_1084_67 = '19.0.1084.67' | 192 V19_0_1084_67 = '19.0.1084.67' |
189 B18_0_1025_163_R1_MLW = MakeBundle('18', '1', V18_0_1025_163, OS_MLW) | 193 B18_0_1025_163_R1_MLW = MakeBundle(18, 1, V18_0_1025_163, OS_MLW) |
190 B18_0_1025_184_R1_MLW = MakeBundle('18', '1', V18_0_1025_184, OS_MLW) | 194 B18_0_1025_184_R1_MLW = MakeBundle(18, 1, V18_0_1025_184, OS_MLW) |
191 B18_R1_NONE = MakeBundle('18', '1') | 195 B18_R1_NONE = MakeBundle(18, '1') |
192 B19_0_1084_41_R1_MLW = MakeBundle('19', '1', V19_0_1084_41, OS_MLW) | 196 B19_0_1084_41_R1_MLW = MakeBundle(19, 1, V19_0_1084_41, OS_MLW) |
193 B19_0_1084_67_R1_MLW = MakeBundle('19', '1', V19_0_1084_67, OS_MLW) | 197 B19_0_1084_67_R1_MLW = MakeBundle(19, 1, V19_0_1084_67, OS_MLW) |
194 B19_R1_NONE = MakeBundle('19', '1') | 198 B19_R1_NONE = MakeBundle(19, '1') |
195 NON_PEPPER_BUNDLE_NOARCHIVES = MakeNonPepperBundle('foo') | 199 NON_PEPPER_BUNDLE_NOARCHIVES = MakeNonPepperBundle('foo') |
196 NON_PEPPER_BUNDLE_ARCHIVES = MakeNonPepperBundle('bar', with_archives=True) | 200 NON_PEPPER_BUNDLE_ARCHIVES = MakeNonPepperBundle('bar', with_archives=True) |
197 | 201 |
198 | 202 |
199 class TestUpdateManifest(unittest.TestCase): | 203 class TestUpdateManifest(unittest.TestCase): |
200 def setUp(self): | 204 def setUp(self): |
201 self.history = MakeHistory() | 205 self.history = MakeHistory() |
202 self.files = MakeFiles() | 206 self.files = MakeFiles() |
203 self.delegate = None | 207 self.delegate = None |
204 self.uploaded_manifest = None | 208 self.uploaded_manifest = None |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 self.history.Add(OS_CR, BETA, V18_0_1025_184) | 352 self.history.Add(OS_CR, BETA, V18_0_1025_184) |
349 self.history.Add(OS_CR, BETA, V18_0_1025_175) | 353 self.history.Add(OS_CR, BETA, V18_0_1025_175) |
350 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | 354 self.history.Add(OS_MLW, BETA, V18_0_1025_163) |
351 self.files.Add(B18_0_1025_163_R1_MLW) | 355 self.files.Add(B18_0_1025_163_R1_MLW) |
352 self._MakeDelegate() | 356 self._MakeDelegate() |
353 self._Run(OS_MLW) | 357 self._Run(OS_MLW) |
354 self._ReadUploadedManifest() | 358 self._ReadUploadedManifest() |
355 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | 359 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) |
356 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | 360 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) |
357 | 361 |
| 362 def testSnippetWithStringRevisionAndVersion(self): |
| 363 # This test exists because some manifest snippets were uploaded with |
| 364 # strings for their revisions and versions. I want to make sure the |
| 365 # resulting manifest is still consistent with the old format. |
| 366 self.manifest = MakeManifest(B18_R1_NONE) |
| 367 self.history.Add(OS_MLW, BETA, V18_0_1025_163) |
| 368 bundle_string_revision = MakeBundle('18', '1234', V18_0_1025_163, OS_MLW) |
| 369 self.files.Add(bundle_string_revision) |
| 370 self._MakeDelegate() |
| 371 self._Run(OS_MLW) |
| 372 self._ReadUploadedManifest() |
| 373 uploaded_bundle = self.uploaded_manifest.GetBundle( |
| 374 bundle_string_revision.name) |
| 375 self.assertEqual(uploaded_bundle.revision, 1234) |
| 376 self.assertEqual(uploaded_bundle.version, 18) |
| 377 |
358 | 378 |
359 def main(): | 379 def main(): |
360 suite = unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]) | 380 suite = unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]) |
361 result = unittest.TextTestRunner(verbosity=2).run(suite) | 381 result = unittest.TextTestRunner(verbosity=2).run(suite) |
362 | 382 |
363 return int(not result.wasSuccessful()) | 383 return int(not result.wasSuccessful()) |
364 | 384 |
365 if __name__ == '__main__': | 385 if __name__ == '__main__': |
366 sys.exit(main()) | 386 sys.exit(main()) |
OLD | NEW |