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

Unified Diff: lib/cros_build_lib_unittest.py

Issue 6765001: Add better support for getting the path to crosutils. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 years, 9 months 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
« lib/cros_build_lib.py ('K') | « lib/cros_build_lib.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cros_build_lib_unittest.py
diff --git a/lib/cros_build_lib_unittest.py b/lib/cros_build_lib_unittest.py
index 293bff15ab004515c9ddac04f5c5bbbd2b4e105a..8a576cd4534ea044ab9f976664b21af71e362327 100755
--- a/lib/cros_build_lib_unittest.py
+++ b/lib/cros_build_lib_unittest.py
@@ -6,13 +6,14 @@
"""Unit tests for cros_build_lib."""
+import mox
import os
import tempfile
import unittest
import cros_build_lib
-class CrosBuildLibTest(unittest.TestCase):
+class CrosBuildLibTest(mox.MoxTestBase):
"""Test class for cros_build_lib."""
def testRunCommandSimple(self):
@@ -103,6 +104,31 @@ class CrosBuildLibTest(unittest.TestCase):
log_fh.close()
os.remove(log_file)
+ def testGetCrosUtilsPathInChroot(self):
+ """Tests whether we can get crosutils from chroot."""
+ self.mox.StubOutWithMock(cros_build_lib, 'IsInsideChroot')
+ crosutils_path_src = '/home/' + os.getenv('USER') + 'trunk/src/scripts'
+ crosutils_path_installed = '/usr/lib/crosutils'
+
+ cros_build_lib.IsInsideChroot().MultipleTimes().AndReturn(True)
+
+ self.mox.ReplayAll()
+ self.assertTrue(cros_build_lib.GetCrosUtilsPath(from_source=True),
+ crosutils_path_src)
+ self.assertTrue(cros_build_lib.GetCrosUtilsPath(from_source=False),
+ crosutils_path_installed)
+ self.mox.VerifyAll()
+
+ def testGetCrosUtilsPathInChroot(self):
+ """Tests whether we can get crosutils from outside chroot."""
+ self.mox.StubOutWithMock(cros_build_lib, 'IsInsideChroot')
+ path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
+ cros_build_lib.IsInsideChroot().MultipleTimes().AndReturn(False)
+
+ self.mox.ReplayAll()
+ self.assertTrue(cros_build_lib.GetCrosUtilsPath(), path)
+ self.mox.VerifyAll()
+
if __name__ == '__main__':
unittest.main()
« lib/cros_build_lib.py ('K') | « lib/cros_build_lib.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698