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

Unified Diff: bin/cbuildbot_unittest.py

Issue 5689003: Add ability to store the manifest in the manifest directory. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Issues while testing 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 side-by-side diff with in-line comments
Download patch
« bin/cbuildbot.py ('K') | « bin/cbuildbot.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/cbuildbot_unittest.py
diff --git a/bin/cbuildbot_unittest.py b/bin/cbuildbot_unittest.py
index b3a4009a90a96feb899f53765cbaa57ffd63c2d9..8b60c11cb0b5e6dc4a89c1a699c4f8bd6bd70520 100755
--- a/bin/cbuildbot_unittest.py
+++ b/bin/cbuildbot_unittest.py
@@ -11,6 +11,7 @@ import mox
import os
import posix
import shutil
+import tempfile
import unittest
# Fixes circular dependency error.
@@ -18,6 +19,7 @@ import cbuildbot_comm
import cbuildbot
from cros_build_lib import ReinterpretPathForChroot
+
class CBuildBotTest(mox.MoxTestBase):
def setUp(self):
@@ -117,7 +119,7 @@ class CBuildBotTest(mox.MoxTestBase):
buildroot = '/fake_dir'
board = 'fake-board'
test_results_dir = 'fake_results_dir'
- gsutil_path='/fake/gsutil/path'
+ gsutil_path = '/fake/gsutil/path'
archive_dir = 1234
acl = 'fake_acl'
num_retries = 5
@@ -230,6 +232,68 @@ class CBuildBotTest(mox.MoxTestBase):
binhosts)
self.mox.VerifyAll()
+ def testGetChromeOSVersion(self):
+ """Tests that we can parse the correct chromeos version using method."""
+ fake_data = '\n'.join(['ChromeOS version information:',
+ ' SOME_OTHER_DATA=blah',
+ ' CHROMEOS_VERSION_STRING=9.0.232.1',
+ ' CHROMEOS_VERSION_CODENAME=test-bot',
+ ])
+ cbuildbot.RunCommand('./chromeos_version.sh',
+ cwd='src/scripts',
+ redirect_stderr=True,
+ redirect_stdout=True).AndReturn(fake_data)
+ self.mox.ReplayAll()
+ return_tuple = cbuildbot._GetChromeOSVersion('')
+ self.assertEquals('.'.join(return_tuple), '9.0.232.1')
+ self.mox.VerifyAll()
+
+ def testGetManifestPath(self):
+ """Tests whether our logic to get the manifest path is correct."""
+ self.mox.StubOutWithMock(cbuildbot, '_GetChromeOSVersion')
+ return_tuple = cbuildbot._GetChromeOSVersion('').AndReturn(
+ ('9', '0', '232', '1'))
+ self.mox.ReplayAll()
+ relative_path = cbuildbot._GetManifestPath('')
+ self.assertEquals(relative_path, '9.0/9.0.232.1.xml')
+ self.mox.VerifyAll()
+
+ def _CommonManifestTest(self, url, overlay_no_buildroot):
+ """Common method for dump manifest tests."""
+ self.mox.StubOutWithMock(cbuildbot, '_GetManifestPath')
+ self.mox.StubOutWithMock(shutil, 'copy')
+ self.mox.StubOutWithMock(os, 'symlink')
+ temp_root = tempfile.mkdtemp('_unittest')
+
+ overlay = overlay_no_buildroot % { 'buildroot': temp_root }
scottz 2010/12/11 00:01:53 {'
sosa 2010/12/13 18:46:39 Done.
+ relative_path = 'fake/manifest/path.xml'
+ full_path = os.path.join(overlay, 'manifests', relative_path)
+
+ cbuildbot._GetManifestPath(temp_root).AndReturn(relative_path)
+ cbuildbot.RunCommand(['repo', 'manifest', '-r', '-o', full_path],
+ cwd=temp_root)
+ os.symlink(relative_path, os.path.join(overlay, 'manifests', 'LATEST'))
+ cbuildbot.RunCommand(['git', 'add', 'manifests/' + relative_path],
+ cwd=overlay)
+ cbuildbot.RunCommand(['git', 'add', 'manifests/LATEST'], cwd=overlay)
+ shutil.copy(full_path, '/dev/stderr')
+
+ self.mox.ReplayAll()
+ cbuildbot._DumpManifest(temp_root, url)
+ self.mox.VerifyAll()
+
+ shutil.rmtree(temp_root)
+
+ def testDumpManifestPublic(self):
+ """Tests whether we push the manifest to the public overlay correctly."""
+ self._CommonManifestTest('http://some_url/manifest',
+ cbuildbot.PUBLIC_OVERLAY)
+
+ def testDumpManifestPrivate(self):
+ """Tests whether we push the manifest to the private overlay correctly."""
+ self._CommonManifestTest('http://some_url/manifest-internal',
+ cbuildbot.PRIVATE_OVERLAY)
+
if __name__ == '__main__':
unittest.main()
« bin/cbuildbot.py ('K') | « bin/cbuildbot.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698