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

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

Issue 2844063005: Add option to collapse symlinks in isolate.py (Closed)
Patch Set: Add -L Created 3 years, 7 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/isolateserver.py ('k') | client/tests/isolated_format_test.py » ('j') | 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 2012 The LUCI Authors. All rights reserved. 2 # Copyright 2012 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 import cStringIO 6 import cStringIO
7 import hashlib 7 import hashlib
8 import json 8 import json
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 tools.write_json(isolate_file, isolate_content, False) 250 tools.write_json(isolate_file, isolate_content, False)
251 expected = { 251 expected = {
252 'algo': 'sha-1', 252 'algo': 'sha-1',
253 'files': {}, 253 'files': {},
254 'read_only': 0, 254 'read_only': 0,
255 'relative_cwd': '.', 255 'relative_cwd': '.',
256 'version': isolated_format.ISOLATED_FILE_VERSION, 256 'version': isolated_format.ISOLATED_FILE_VERSION,
257 } 257 }
258 complete_state = isolate.CompleteState(None, isolate.SavedState(self.cwd)) 258 complete_state = isolate.CompleteState(None, isolate.SavedState(self.cwd))
259 complete_state.load_isolate( 259 complete_state.load_isolate(
260 unicode(self.cwd), unicode(isolate_file), {}, {}, {}, None, False) 260 unicode(self.cwd), unicode(isolate_file), {}, {}, {}, None, False,
261 False)
261 self.assertEqual(expected, complete_state.saved_state.to_isolated()) 262 self.assertEqual(expected, complete_state.saved_state.to_isolated())
262 263
263 264
264 class IsolateLoad(IsolateBase): 265 class IsolateLoad(IsolateBase):
265 def setUp(self): 266 def setUp(self):
266 super(IsolateLoad, self).setUp() 267 super(IsolateLoad, self).setUp()
267 self.directory = tempfile.mkdtemp(prefix=u'isolate_') 268 self.directory = tempfile.mkdtemp(prefix=u'isolate_')
268 self.isolate_dir = os.path.join(self.directory, u'isolate') 269 self.isolate_dir = os.path.join(self.directory, u'isolate')
269 self.isolated_dir = os.path.join(self.directory, u'isolated') 270 self.isolated_dir = os.path.join(self.directory, u'isolated')
270 os.mkdir(self.isolated_dir, 0700) 271 os.mkdir(self.isolated_dir, 0700)
(...skipping 11 matching lines...) Expand all
282 outdir = os.path.join(self.directory, 'outdir') 283 outdir = os.path.join(self.directory, 'outdir')
283 isolate = isolate_file 284 isolate = isolate_file
284 blacklist = list(isolateserver.DEFAULT_BLACKLIST) 285 blacklist = list(isolateserver.DEFAULT_BLACKLIST)
285 path_variables = {} 286 path_variables = {}
286 config_variables = { 287 config_variables = {
287 'OS': 'linux', 288 'OS': 'linux',
288 'chromeos': 1, 289 'chromeos': 1,
289 } 290 }
290 extra_variables = {'foo': 'bar'} 291 extra_variables = {'foo': 'bar'}
291 ignore_broken_items = False 292 ignore_broken_items = False
293 collapse_symlinks = False
292 return Options() 294 return Options()
293 295
294 def _cleanup_isolated(self, expected_isolated): 296 def _cleanup_isolated(self, expected_isolated):
295 """Modifies isolated to remove the non-deterministic parts.""" 297 """Modifies isolated to remove the non-deterministic parts."""
296 if sys.platform == 'win32': 298 if sys.platform == 'win32':
297 # 'm' are not saved in windows. 299 # 'm' are not saved in windows.
298 for values in expected_isolated['files'].itervalues(): 300 for values in expected_isolated['files'].itervalues():
299 self.assertTrue(values.pop('m')) 301 self.assertTrue(values.pop('m'))
300 302
301 def _cleanup_saved_state(self, actual_saved_state): 303 def _cleanup_saved_state(self, actual_saved_state):
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 base = os.path.dirname(f) 971 base = os.path.dirname(f)
970 if not os.path.isdir(base): 972 if not os.path.isdir(base):
971 os.mkdir(base) 973 os.mkdir(base)
972 open(f, 'wb').close() 974 open(f, 'wb').close()
973 975
974 c = isolate.CompleteState(isolated, isolate.SavedState(isolated_dir)) 976 c = isolate.CompleteState(isolated, isolate.SavedState(isolated_dir))
975 config = { 977 config = {
976 'OS': config_os, 978 'OS': config_os,
977 } 979 }
978 c.load_isolate( 980 c.load_isolate(
979 unicode(self.cwd), root_isolate, {}, config, {}, None, False) 981 unicode(self.cwd), root_isolate, {}, config, {}, None, False, False)
980 # Note that load_isolate() doesn't retrieve the meta data about each file. 982 # Note that load_isolate() doesn't retrieve the meta data about each file.
981 expected = { 983 expected = {
982 'algo': 'sha-1', 984 'algo': 'sha-1',
983 'command': command, 985 'command': command,
984 'files': { 986 'files': {
985 unicode(f.replace('/', os.path.sep)):{} for f in expected_files 987 unicode(f.replace('/', os.path.sep)):{} for f in expected_files
986 }, 988 },
987 'read_only': 1, 989 'read_only': 1,
988 'relative_cwd': relative_cwd.replace('/', os.path.sep), 990 'relative_cwd': relative_cwd.replace('/', os.path.sep),
989 'version': isolated_format.ISOLATED_FILE_VERSION, 991 'version': isolated_format.ISOLATED_FILE_VERSION,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 config = { 1166 config = {
1165 'OS': config_os, 1167 'OS': config_os,
1166 } 1168 }
1167 paths = { 1169 paths = {
1168 'PATH': 'path/', 1170 'PATH': 'path/',
1169 } 1171 }
1170 extra = { 1172 extra = {
1171 'EXTRA': 'indeed', 1173 'EXTRA': 'indeed',
1172 } 1174 }
1173 c.load_isolate( 1175 c.load_isolate(
1174 unicode(cwd), root_isolate, paths, config, extra, None, False) 1176 unicode(cwd), root_isolate, paths, config, extra, None, False, False)
1175 # Note that load_isolate() doesn't retrieve the meta data about each file. 1177 # Note that load_isolate() doesn't retrieve the meta data about each file.
1176 expected = { 1178 expected = {
1177 'algo': 'sha-1', 1179 'algo': 'sha-1',
1178 'command': command, 1180 'command': command,
1179 'files': { 1181 'files': {
1180 unicode(os.path.join(cwd_name, config_os, 'path', f)): {} 1182 unicode(os.path.join(cwd_name, config_os, 'path', f)): {}
1181 for f in expected_files 1183 for f in expected_files
1182 }, 1184 },
1183 'read_only': 1, 1185 'read_only': 1,
1184 'relative_cwd': relative_cwd, 1186 'relative_cwd': relative_cwd,
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 1621
1620 def clear_env_vars(): 1622 def clear_env_vars():
1621 for e in ('ISOLATE_DEBUG', 'ISOLATE_SERVER'): 1623 for e in ('ISOLATE_DEBUG', 'ISOLATE_SERVER'):
1622 os.environ.pop(e, None) 1624 os.environ.pop(e, None)
1623 1625
1624 1626
1625 if __name__ == '__main__': 1627 if __name__ == '__main__':
1626 fix_encoding.fix_encoding() 1628 fix_encoding.fix_encoding()
1627 clear_env_vars() 1629 clear_env_vars()
1628 test_utils.main() 1630 test_utils.main()
OLDNEW
« no previous file with comments | « client/isolateserver.py ('k') | client/tests/isolated_format_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698