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

Side by Side Diff: bin/cbuildbot_unittest.py

Issue 5888003: Undo all the manifest logic from cbuildbot. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: to stderr Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « bin/cbuildbot.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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Unittests for cbuildbot. Needs to be run inside of chroot for mox.""" 7 """Unittests for cbuildbot. Needs to be run inside of chroot for mox."""
8 8
9 import __builtin__ 9 import __builtin__
10 import mox 10 import mox
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 binhost = 'http://www.example.com' 225 binhost = 'http://www.example.com'
226 binhosts = [binhost, None] 226 binhosts = [binhost, None]
227 check = mox.And(mox.IsA(list), mox.In(binhost), mox.Not(mox.In(None)), 227 check = mox.And(mox.IsA(list), mox.In(binhost), mox.Not(mox.In(None)),
228 mox.In('chromeos-images:/var/www/prebuilt/')) 228 mox.In('chromeos-images:/var/www/prebuilt/'))
229 cbuildbot.RunCommand(check, cwd='%s/src/scripts' % self._buildroot) 229 cbuildbot.RunCommand(check, cwd='%s/src/scripts' % self._buildroot)
230 self.mox.ReplayAll() 230 self.mox.ReplayAll()
231 cbuildbot._UploadPrebuilts(self._buildroot, self._test_board, 'private', 231 cbuildbot._UploadPrebuilts(self._buildroot, self._test_board, 'private',
232 binhosts) 232 binhosts)
233 self.mox.VerifyAll() 233 self.mox.VerifyAll()
234 234
235 def testGetChromeOSVersion(self):
236 """Tests that we can parse the correct chromeos version using method."""
237 fake_data = '\n'.join(['ChromeOS version information:',
238 ' SOME_OTHER_DATA=blah',
239 ' CHROMEOS_VERSION_STRING=9.0.232.1',
240 ' CHROMEOS_VERSION_CODENAME=test-bot',
241 ])
242 cbuildbot.RunCommand('./chromeos_version.sh',
243 cwd='src/scripts',
244 redirect_stderr=True,
245 redirect_stdout=True).AndReturn(fake_data)
246 self.mox.ReplayAll()
247 return_tuple = cbuildbot._GetChromeOSVersion('')
248 self.assertEquals('.'.join(return_tuple), '9.0.232.1')
249 self.mox.VerifyAll()
250
251 def testGetManifestPath(self):
252 """Tests whether our logic to get the manifest path is correct."""
253 self.mox.StubOutWithMock(cbuildbot, '_GetChromeOSVersion')
254 return_tuple = cbuildbot._GetChromeOSVersion('').AndReturn(
255 ('9', '0', '232', '1'))
256 self.mox.ReplayAll()
257 relative_path = cbuildbot._GetManifestPath('')
258 self.assertEquals(relative_path, '9.0/9.0.232.1.xml')
259 self.mox.VerifyAll()
260
261 def _CommonManifestTest(self, url, overlay_no_buildroot):
262 """Common method for dump manifest tests."""
263 self.mox.StubOutWithMock(cbuildbot, '_GetManifestPath')
264 self.mox.StubOutWithMock(shutil, 'copy')
265 self.mox.StubOutWithMock(os, 'symlink')
266 temp_root = tempfile.mkdtemp('_unittest')
267
268 overlay = overlay_no_buildroot % {'buildroot': temp_root}
269 relative_path = 'fake/manifest/path.xml'
270 full_path = os.path.join(overlay, 'manifests', relative_path)
271
272 cbuildbot._GetManifestPath(temp_root).AndReturn(relative_path)
273 cbuildbot.RunCommand(['repo', 'manifest', '-r', '-o', full_path],
274 cwd=temp_root)
275 os.symlink(relative_path, os.path.join(overlay, 'manifests', 'LATEST'))
276 cbuildbot.RunCommand(['git', 'add', 'manifests/' + relative_path],
277 cwd=overlay)
278 cbuildbot.RunCommand(['git', 'add', 'manifests/LATEST'], cwd=overlay)
279 shutil.copy(full_path, '/dev/stderr')
280
281 self.mox.ReplayAll()
282 cbuildbot._DumpManifest(temp_root, url)
283 self.mox.VerifyAll()
284
285 shutil.rmtree(temp_root)
286
287 def testDumpManifestPublic(self):
288 """Tests whether we push the manifest to the public overlay correctly."""
289 self._CommonManifestTest('http://some_url/manifest',
290 cbuildbot.PUBLIC_OVERLAY)
291
292 def testDumpManifestPrivate(self):
293 """Tests whether we push the manifest to the private overlay correctly."""
294 self._CommonManifestTest('http://some_url/manifest-internal',
295 cbuildbot.PRIVATE_OVERLAY)
296
297 235
298 if __name__ == '__main__': 236 if __name__ == '__main__':
299 unittest.main() 237 unittest.main()
OLDNEW
« no previous file with comments | « bin/cbuildbot.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698