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

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

Issue 2093593002: luci-py: Making __file__ usage unicode safe. (Closed) Base URL: https://github.com/luci/luci-py.git@master
Patch Set: Small fixes. Created 4 years, 5 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/tests/isolate_format_test.py ('k') | client/tests/isolate_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 os 10 import os
11 import re 11 import re
12 import stat 12 import stat
13 import subprocess 13 import subprocess
14 import sys 14 import sys
15 import tempfile 15 import tempfile
16 import unittest 16 import unittest
17 17
18 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 18 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(
19 __file__.decode(sys.getfilesystemencoding()))))
19 sys.path.insert(0, ROOT_DIR) 20 sys.path.insert(0, ROOT_DIR)
20 21
21 import isolate 22 import isolate
22 import isolated_format 23 import isolated_format
23 from depot_tools import fix_encoding 24 from depot_tools import fix_encoding
24 from utils import file_path 25 from utils import file_path
25 26
26 import test_utils 27 import test_utils
27 28
28 29
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 'command': ['python', 'touch_root.py'], 295 'command': ['python', 'touch_root.py'],
295 'files': ['../../at_root', 'touch_root.py'], 296 'files': ['../../at_root', 'touch_root.py'],
296 }, 297 },
297 }], 298 }],
298 ], 299 ],
299 }""", 300 }""",
300 'tests/isolate/touch_root.py': 301 'tests/isolate/touch_root.py':
301 """if __name__ == '__main__': 302 """if __name__ == '__main__':
302 import os, sys 303 import os, sys
303 print('child_touch_root: Verify the relative directories') 304 print('child_touch_root: Verify the relative directories')
304 root_dir = os.path.dirname(os.path.abspath(__file__)) 305 root_dir = os.path.dirname(os.path.abspath(
306 __file__.decode(sys.getfilesystemencoding())))
305 parent_dir, base = os.path.split(root_dir) 307 parent_dir, base = os.path.split(root_dir)
306 parent_dir, base2 = os.path.split(parent_dir) 308 parent_dir, base2 = os.path.split(parent_dir)
307 if base != 'isolate' or base2 != 'tests': 309 if base != 'isolate' or base2 != 'tests':
308 print('Invalid root dir %s' % root_dir) 310 print('Invalid root dir %s' % root_dir)
309 sys.exit(4) 311 sys.exit(4)
310 content = open(os.path.join(parent_dir, 'at_root'), 'r').read() 312 content = open(os.path.join(parent_dir, 'at_root'), 'r').read()
311 sys.exit(int(content != 'foo'))""", 313 sys.exit(int(content != 'foo'))""",
312 'at_root': 'foo', 314 'at_root': 'foo',
313 }, 315 },
314 [ 316 [
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 for filename in filenames: 355 for filename in filenames:
354 fullpath = os.path.join(relroot, filename) 356 fullpath = os.path.join(relroot, filename)
355 actual[fullpath[len(root)+1:]] = open(fullpath, 'r').read() 357 actual[fullpath[len(root)+1:]] = open(fullpath, 'r').read()
356 if mode == 'trace' and '.svn' in dirnames: 358 if mode == 'trace' and '.svn' in dirnames:
357 dirnames.remove('.svn') 359 dirnames.remove('.svn')
358 if actual != expected: 360 if actual != expected:
359 print('Failure') 361 print('Failure')
360 print(actual) 362 print(actual)
361 print(expected) 363 print(expected)
362 sys.exit(1) 364 sys.exit(1)
363 root_dir = os.path.dirname(os.path.abspath(__file__)) 365 root_dir = os.path.dirname(os.path.abspath(
366 __file__.decode(sys.getfilesystemencoding())))
364 parent_dir, base = os.path.split(root_dir) 367 parent_dir, base = os.path.split(root_dir)
365 if mode == 'trace': 368 if mode == 'trace':
366 # Verify the parent directory. 369 # Verify the parent directory.
367 parent_dir, base2 = os.path.split(parent_dir) 370 parent_dir, base2 = os.path.split(parent_dir)
368 if base != 'isolate' or base2 != 'tests': 371 if base != 'isolate' or base2 != 'tests':
369 print('mode trace: Invalid root dir %s' % root_dir) 372 print('mode trace: Invalid root dir %s' % root_dir)
370 sys.exit(4) 373 sys.exit(4)
371 else: 374 else:
372 # Verify that we are not inside a checkout. 375 # Verify that we are not inside a checkout.
373 if base == 'tests': 376 if base == 'tests':
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 # Move the .isolate file aside and rerun the command with the new source but 1065 # Move the .isolate file aside and rerun the command with the new source but
1063 # same destination. 1066 # same destination.
1064 b_isolate = os.path.join(self.tempdir, 'b.isolate') 1067 b_isolate = os.path.join(self.tempdir, 'b.isolate')
1065 os.rename(a_isolate, b_isolate) 1068 os.rename(a_isolate, b_isolate)
1066 subprocess.check_call(cmd + ['-i', b_isolate], cwd=ROOT_DIR) 1069 subprocess.check_call(cmd + ['-i', b_isolate], cwd=ROOT_DIR)
1067 1070
1068 1071
1069 if __name__ == '__main__': 1072 if __name__ == '__main__':
1070 fix_encoding.fix_encoding() 1073 fix_encoding.fix_encoding()
1071 test_utils.main() 1074 test_utils.main()
OLDNEW
« no previous file with comments | « client/tests/isolate_format_test.py ('k') | client/tests/isolate_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698