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

Side by Side Diff: test/lib/TestMac.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 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
OLDNEW
1 # Copyright (c) 2014 Google Inc. All rights reserved. 1 # Copyright (c) 2014 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """ 5 """
6 TestMac.py: a collection of helper function shared between test on Mac OS X. 6 TestMac.py: a collection of helper function shared between test on Mac OS X.
7 """ 7 """
8 8
9 from __future__ import print_function
10
9 import re 11 import re
10 import subprocess 12 import subprocess
11 13
12 __all__ = ['Xcode', 'CheckFileType'] 14 __all__ = ['Xcode', 'CheckFileType']
13 15
14 16
15 def CheckFileType(test, file, archs): 17 def CheckFileType(test, file, archs):
16 """Check that |file| contains exactly |archs| or fails |test|.""" 18 """Check that |file| contains exactly |archs| or fails |test|."""
17 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) 19 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE)
18 o = proc.communicate()[0].strip() 20 o = proc.communicate()[0].strip()
19 assert not proc.returncode 21 assert not proc.returncode
20 if len(archs) == 1: 22 if len(archs) == 1:
21 pattern = re.compile('^Non-fat file: (.*) is architecture: (.*)$') 23 pattern = re.compile('^Non-fat file: (.*) is architecture: (.*)$')
22 else: 24 else:
23 pattern = re.compile('^Architectures in the fat file: (.*) are: (.*)$') 25 pattern = re.compile('^Architectures in the fat file: (.*) are: (.*)$')
24 match = pattern.match(o) 26 match = pattern.match(o)
25 if match is None: 27 if match is None:
26 print 'Ouput does not match expected pattern: %s' % (pattern.pattern) 28 print('Ouput does not match expected pattern: %s' % (pattern.pattern))
27 test.fail_test() 29 test.fail_test()
28 else: 30 else:
29 found_file, found_archs = match.groups() 31 found_file, found_archs = match.groups()
30 if found_file != file or set(found_archs.split()) != set(archs): 32 if found_file != file or set(found_archs.split()) != set(archs):
31 print 'Expected file %s with arch %s, got %s with arch %s' % ( 33 print('Expected file %s with arch %s, got %s with arch %s' % (
32 file, ' '.join(archs), found_file, found_archs) 34 file, ' '.join(archs), found_file, found_archs))
33 test.fail_test() 35 test.fail_test()
34 36
35 37
36 class XcodeInfo(object): 38 class XcodeInfo(object):
37 """Simplify access to Xcode informations.""" 39 """Simplify access to Xcode informations."""
38 40
39 def __init__(self): 41 def __init__(self):
40 self._cache = {} 42 self._cache = {}
41 43
42 def _XcodeVersion(self): 44 def _XcodeVersion(self):
(...skipping 21 matching lines...) Expand all
64 66
65 def SDKVersion(self): 67 def SDKVersion(self):
66 if 'SDKVersion' not in self._cache: 68 if 'SDKVersion' not in self._cache:
67 self._cache['SDKVersion'] = subprocess.check_output( 69 self._cache['SDKVersion'] = subprocess.check_output(
68 ['xcodebuild', '-version', '-sdk', '', 'SDKVersion']) 70 ['xcodebuild', '-version', '-sdk', '', 'SDKVersion'])
69 self._cache['SDKVersion'] = self._cache['SDKVersion'].rstrip('\n') 71 self._cache['SDKVersion'] = self._cache['SDKVersion'].rstrip('\n')
70 return self._cache['SDKVersion'] 72 return self._cache['SDKVersion']
71 73
72 74
73 Xcode = XcodeInfo() 75 Xcode = XcodeInfo()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698