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

Side by Side Diff: client/tests/run_isolated_test.py

Issue 2800643003: Switch run_isolated.py to use a constant path 'ir'. (Closed)
Patch Set: comments Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « client/run_isolated.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 2013 The LUCI Authors. All rights reserved. 2 # Copyright 2013 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 # pylint: disable=R0201 6 # pylint: disable=R0201
7 7
8 import StringIO 8 import StringIO
9 import base64 9 import base64
10 import contextlib 10 import contextlib
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 def get_storage(_isolate_server, _namespace): 166 def get_storage(_isolate_server, _namespace):
167 return StorageFake({isolated_hash:isolated}) 167 return StorageFake({isolated_hash:isolated})
168 self.mock(isolateserver, 'get_storage', get_storage) 168 self.mock(isolateserver, 'get_storage', get_storage)
169 169
170 cmd = [ 170 cmd = [
171 '--no-log', 171 '--no-log',
172 '--isolated', isolated_hash, 172 '--isolated', isolated_hash,
173 '--cache', self.tempdir, 173 '--cache', self.tempdir,
174 '--named-cache-root', os.path.join(self.tempdir, 'c'), 174 '--named-cache-root', os.path.join(self.tempdir, 'c'),
175 '--isolate-server', 'https://localhost', 175 '--isolate-server', 'https://localhost',
176 '--root-dir', self.tempdir,
176 ] 177 ]
177 ret = run_isolated.main(cmd) 178 ret = run_isolated.main(cmd)
178 self.assertEqual(0, ret) 179 self.assertEqual(0, ret)
179 self.assertEqual( 180 self.assertEqual(
180 [([self.temp_join(u'foo.exe'), u'cmd with space'], {'detached': True})], 181 [([self.temp_join(u'foo.exe'), u'cmd with space'], {'detached': True})],
181 self.popen_calls) 182 self.popen_calls)
182 183
183 def test_main_args(self): 184 def test_main_args(self):
184 self.mock(tools, 'disable_buffering', lambda: None) 185 self.mock(tools, 'disable_buffering', lambda: None)
185 isolated = json_dumps({'command': ['foo.exe', 'cmd w/ space']}) 186 isolated = json_dumps({'command': ['foo.exe', 'cmd w/ space']})
186 isolated_hash = isolateserver_mock.hash_content(isolated) 187 isolated_hash = isolateserver_mock.hash_content(isolated)
187 def get_storage(_isolate_server, _namespace): 188 def get_storage(_isolate_server, _namespace):
188 return StorageFake({isolated_hash:isolated}) 189 return StorageFake({isolated_hash:isolated})
189 self.mock(isolateserver, 'get_storage', get_storage) 190 self.mock(isolateserver, 'get_storage', get_storage)
190 191
191 cmd = [ 192 cmd = [
192 '--use-symlinks', 193 '--use-symlinks',
193 '--no-log', 194 '--no-log',
194 '--isolated', isolated_hash, 195 '--isolated', isolated_hash,
195 '--cache', self.tempdir, 196 '--cache', self.tempdir,
196 '--isolate-server', 'https://localhost', 197 '--isolate-server', 'https://localhost',
197 '--named-cache-root', os.path.join(self.tempdir, 'c'), 198 '--named-cache-root', os.path.join(self.tempdir, 'c'),
199 '--root-dir', self.tempdir,
198 '--', 200 '--',
199 '--extraargs', 201 '--extraargs',
200 'bar', 202 'bar',
201 ] 203 ]
202 ret = run_isolated.main(cmd) 204 ret = run_isolated.main(cmd)
203 self.assertEqual(0, ret) 205 self.assertEqual(0, ret)
204 self.assertEqual( 206 self.assertEqual(
205 [ 207 [
206 ([self.temp_join(u'foo.exe'), u'cmd w/ space', '--extraargs', 'bar'], 208 ([self.temp_join(u'foo.exe'), u'cmd w/ space', '--extraargs', 'bar'],
207 {'detached': True}), 209 {'detached': True}),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 def get_storage(_isolate_server, _namespace): 330 def get_storage(_isolate_server, _namespace):
329 return StorageFake({isolated_hash:isolated}) 331 return StorageFake({isolated_hash:isolated})
330 self.mock(isolateserver, 'get_storage', get_storage) 332 self.mock(isolateserver, 'get_storage', get_storage)
331 333
332 cmd = [ 334 cmd = [
333 '--no-log', 335 '--no-log',
334 '--isolated', isolated_hash, 336 '--isolated', isolated_hash,
335 '--cache', self.tempdir, 337 '--cache', self.tempdir,
336 '--isolate-server', 'https://localhost', 338 '--isolate-server', 'https://localhost',
337 '--named-cache-root', os.path.join(self.tempdir, 'c'), 339 '--named-cache-root', os.path.join(self.tempdir, 'c'),
340 '--root-dir', self.tempdir,
338 ] 341 ]
339 ret = run_isolated.main(cmd) 342 ret = run_isolated.main(cmd)
340 self.assertEqual(1, ret) 343 self.assertEqual(1, ret)
341 self.assertEqual(1, len(self.popen_calls)) 344 self.assertEqual(1, len(self.popen_calls))
342 self.assertEqual( 345 self.assertEqual(
343 [([self.temp_join(u'invalid'), u'command'], {'detached': True})], 346 [([self.temp_join(u'invalid'), u'command'], {'detached': True})],
344 self.popen_calls) 347 self.popen_calls)
345 348
346 def test_main_naked_without_isolated(self): 349 def test_main_naked_without_isolated(self):
347 self.mock_popen_with_oserr() 350 self.mock_popen_with_oserr()
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 self.mock(isolateserver, 'get_storage', get_storage) 781 self.mock(isolateserver, 'get_storage', get_storage)
779 782
780 out = os.path.join(self.tempdir, 'res.json') 783 out = os.path.join(self.tempdir, 'res.json')
781 cmd = [ 784 cmd = [
782 '--no-log', 785 '--no-log',
783 '--isolated', isolated_in_hash, 786 '--isolated', isolated_in_hash,
784 '--cache', self.tempdir, 787 '--cache', self.tempdir,
785 '--isolate-server', 'https://localhost:1', 788 '--isolate-server', 'https://localhost:1',
786 '--named-cache-root', os.path.join(self.tempdir, 'c'), 789 '--named-cache-root', os.path.join(self.tempdir, 'c'),
787 '--json', out, 790 '--json', out,
791 '--root-dir', self.tempdir,
788 ] 792 ]
789 ret = run_isolated.main(cmd) 793 ret = run_isolated.main(cmd)
790 self.assertEqual(0, ret) 794 self.assertEqual(0, ret)
791 # Replace ${ISOLATED_OUTDIR} with the temporary directory. 795 # Replace ${ISOLATED_OUTDIR} with the temporary directory.
792 sub_cmd[2] = self.popen_calls[0][0][2] 796 sub_cmd[2] = self.popen_calls[0][0][2]
793 self.assertNotIn('ISOLATED_OUTDIR', sub_cmd[2]) 797 self.assertNotIn('ISOLATED_OUTDIR', sub_cmd[2])
794 self.assertEqual([(sub_cmd, {'detached': True})], self.popen_calls) 798 self.assertEqual([(sub_cmd, {'detached': True})], self.popen_calls)
795 isolated_out = { 799 isolated_out = {
796 'algo': 'sha-1', 800 'algo': 'sha-1',
797 'files': { 801 'files': {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 self.assertEqual(expected, actual) 850 self.assertEqual(expected, actual)
847 851
848 852
849 if __name__ == '__main__': 853 if __name__ == '__main__':
850 fix_encoding.fix_encoding() 854 fix_encoding.fix_encoding()
851 if '-v' in sys.argv: 855 if '-v' in sys.argv:
852 unittest.TestCase.maxDiff = None 856 unittest.TestCase.maxDiff = None
853 logging.basicConfig( 857 logging.basicConfig(
854 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 858 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
855 unittest.main() 859 unittest.main()
OLDNEW
« no previous file with comments | « client/run_isolated.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698