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

Side by Side Diff: native_client_sdk/src/tools/tests/getos_test.py

Issue 86053005: [NaCl SDK] Fix "make debug" and "make run" on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 7 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 | « native_client_sdk/src/tools/run.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/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 os 6 import os
7 import shutil 7 import shutil
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 import unittest 10 import unittest
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 def testGetSystemArch(self): 65 def testGetSystemArch(self):
66 """returns a valid architecture.""" 66 """returns a valid architecture."""
67 arch = getos.GetSystemArch(getos.GetPlatform()) 67 arch = getos.GetSystemArch(getos.GetPlatform())
68 self.assertIn(arch, ('x86_64', 'x86_32', 'arm')) 68 self.assertIn(arch, ('x86_64', 'x86_32', 'arm'))
69 69
70 def testGetChromePathEnv(self): 70 def testGetChromePathEnv(self):
71 """honors CHROME_PATH environment.""" 71 """honors CHROME_PATH environment."""
72 with mock.patch.dict('os.environ', {'CHROME_PATH': '/dummy/file'}): 72 with mock.patch.dict('os.environ', {'CHROME_PATH': '/dummy/file'}):
73 expect = "Invalid CHROME_PATH.*/dummy/file" 73 expect = "Invalid CHROME_PATH.*/dummy/file"
74 platform = getos.GetPlatform()
74 if hasattr(self, 'assertRaisesRegexp'): 75 if hasattr(self, 'assertRaisesRegexp'):
75 with self.assertRaisesRegexp(getos.Error, expect): 76 with self.assertRaisesRegexp(getos.Error, expect):
76 getos.GetChromePath() 77 getos.GetChromePath(platform)
77 else: 78 else:
78 # TODO(sbc): remove this path once we switch to python2.7 everywhere 79 # TODO(sbc): remove this path once we switch to python2.7 everywhere
79 self.assertRaises(getos.Error, getos.GetChromePath) 80 self.assertRaises(getos.Error, getos.GetChromePath, platform)
80 81
81 def testGetChromePathCheckExists(self): 82 def testGetChromePathCheckExists(self):
82 """checks that existence of explicitly CHROME_PATH is checked.""" 83 """checks that existence of explicitly CHROME_PATH is checked."""
83 mock_location = '/bin/ls' 84 mock_location = '/bin/ls'
84 if getos.GetPlatform() == 'win': 85 platform = getos.GetPlatform()
86 if platform == 'win':
85 mock_location = 'c:\\nowhere' 87 mock_location = 'c:\\nowhere'
86 with mock.patch.dict('os.environ', {'CHROME_PATH': mock_location}): 88 with mock.patch.dict('os.environ', {'CHROME_PATH': mock_location}):
87 with mock.patch('os.path.exists') as mock_exists: 89 with mock.patch('os.path.exists') as mock_exists:
88 chrome = getos.GetChromePath() 90 chrome = getos.GetChromePath(platform)
89 self.assertEqual(chrome, mock_location) 91 self.assertEqual(chrome, mock_location)
90 mock_exists.assert_called_with(chrome) 92 mock_exists.assert_called_with(chrome)
91 93
92 def testGetHelperPath(self): 94 def testGetHelperPath(self):
93 """GetHelperPath checks that helper exists.""" 95 """GetHelperPath checks that helper exists."""
94 platform = getos.GetPlatform() 96 platform = getos.GetPlatform()
95 # The helper is only needed on linux. On other platforms 97 # The helper is only needed on linux. On other platforms
96 # GetHelperPath() simply return empty string. 98 # GetHelperPath() simply return empty string.
97 if platform == 'linux': 99 if platform == 'linux':
98 with mock.patch('os.path.exists') as mock_exists: 100 with mock.patch('os.path.exists') as mock_exists:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 with open(os.path.join(self.tempdir, 'README'), 'w') as out: 148 with open(os.path.join(self.tempdir, 'README'), 'w') as out:
147 out.write('Version: %s\n' % expected_version[0]) 149 out.write('Version: %s\n' % expected_version[0])
148 out.write('Chrome Revision: %s\n' % expected_version[1]) 150 out.write('Chrome Revision: %s\n' % expected_version[1])
149 151
150 version = getos.GetSDKVersion() 152 version = getos.GetSDKVersion()
151 self.assertEqual(version, expected_version) 153 self.assertEqual(version, expected_version)
152 154
153 155
154 if __name__ == '__main__': 156 if __name__ == '__main__':
155 unittest.main() 157 unittest.main()
OLDNEW
« no previous file with comments | « native_client_sdk/src/tools/run.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698