summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/tools/tests/create_nmf_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'native_client_sdk/src/tools/tests/create_nmf_test.py')
-rwxr-xr-xnative_client_sdk/src/tools/tests/create_nmf_test.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/native_client_sdk/src/tools/tests/create_nmf_test.py b/native_client_sdk/src/tools/tests/create_nmf_test.py
index 86a89a2..d71bee9 100755
--- a/native_client_sdk/src/tools/tests/create_nmf_test.py
+++ b/native_client_sdk/src/tools/tests/create_nmf_test.py
@@ -14,17 +14,19 @@ import unittest
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
TOOLS_DIR = os.path.dirname(SCRIPT_DIR)
DATA_DIR = os.path.join(TOOLS_DIR, 'lib', 'tests', 'data')
+BUILD_TOOLS_DIR = os.path.join(os.path.dirname(TOOLS_DIR), 'build_tools')
CHROME_SRC = os.path.dirname(os.path.dirname(os.path.dirname(TOOLS_DIR)))
MOCK_DIR = os.path.join(CHROME_SRC, 'third_party', 'pymock')
# For the mock library
sys.path.append(MOCK_DIR)
sys.path.append(TOOLS_DIR)
+sys.path.append(BUILD_TOOLS_DIR)
import build_paths
import create_nmf
import getos
-import mock
+from mock import patch, Mock
TOOLCHAIN_OUT = os.path.join(build_paths.OUT_DIR, 'sdk_tests', 'toolchain')
NACL_X86_GLIBC_TOOLCHAIN = os.path.join(TOOLCHAIN_OUT,
@@ -61,24 +63,18 @@ class TestPosixRelPath(unittest.TestCase):
class TestDefaultLibpath(unittest.TestCase):
- def testWithoutNaClSDKRoot(self):
- """GetDefaultLibPath wihtout NACL_SDK_ROOT set
-
- In the absence of NACL_SDK_ROOT GetDefaultLibPath should
- return the empty list."""
- with mock.patch.dict('os.environ', clear=True):
- paths = create_nmf.GetDefaultLibPath('Debug')
- self.assertEqual(paths, [])
-
- def testHonorNaClSDKRoot(self):
- with mock.patch.dict('os.environ', {'NACL_SDK_ROOT': '/dummy/path'}):
- paths = create_nmf.GetDefaultLibPath('Debug')
+ def setUp(self):
+ patcher = patch('create_nmf.GetSDKRoot', Mock(return_value='/dummy/path'))
+ patcher.start()
+ self.addCleanup(patcher.stop)
+
+ def testUsesSDKRoot(self):
+ paths = create_nmf.GetDefaultLibPath('Debug')
for path in paths:
self.assertTrue(path.startswith('/dummy/path'))
def testIncludesNaClPorts(self):
- with mock.patch.dict('os.environ', {'NACL_SDK_ROOT': '/dummy/path'}):
- paths = create_nmf.GetDefaultLibPath('Debug')
+ paths = create_nmf.GetDefaultLibPath('Debug')
self.assertTrue(any(os.path.join('ports', 'lib') in p for p in paths),
"naclports libpath missing: %s" % str(paths))