Skip to content

Commit 503a882

Browse files
committed
test: mac yak shaving
1 parent 5a2f673 commit 503a882

11 files changed

+71
-90
lines changed

gyp/XCodeDetect.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ def GetSdkVersionInfoItem(sdk, item):
3636
# Since the CLT has no SDK paths anyway, returning None is the most sensible route and should still do the right thing.
3737
try:
3838
return run('xcrun', '--sdk', sdk, item)
39-
except subprocess.CalledProcessError:
39+
except subprocess.CalledProcessError as e:
40+
stdout = e.output
41+
status = e.returncode
42+
cmd = ' '.join(e.cmd)
4043
return None
4144

4245

gyp/buildtime_helpers/mac_tool.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def _CopyStringsFile(self, source, dest):
137137
# on invalid files. Do the same kind of validation.
138138
import CoreFoundation
139139
s = open(source, 'rb').read()
140+
# noinspection PyUnresolvedReferences
140141
d = CoreFoundation.CFDataCreate(None, s, len(s))
142+
# noinspection PyUnresolvedReferences
141143
_, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None)
142144
if error:
143145
return
@@ -175,7 +177,9 @@ def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys):
175177
# Insert synthesized key/value pairs (e.g. BuildMachineOSBuild).
176178
plist = plistlib.readPlistFromString(lines)
177179
if keys:
178-
plist.update(json.loads(keys[0]))
180+
j = json.loads(keys[0])
181+
j = dict([i for i in j.items() if i[0] and i[1]])
182+
plist.update(j)
179183
lines = plistlib.writePlistToString(plist)
180184

181185
# Go through all the environment variables and replace them as variables in
@@ -284,7 +288,7 @@ def ExecFilterLibtool(self, *cmd_list):
284288
def ExecPackageIosFramework(self, framework):
285289
# Find the name of the binary based on the part before the ".framework".
286290
binary = os.path.basename(framework).split('.')[0]
287-
module_path = os.path.join(framework, 'Modules');
291+
module_path = os.path.join(framework, 'Modules')
288292
if not os.path.exists(module_path):
289293
os.mkdir(module_path)
290294
module_template = 'framework module %s {\n' \
@@ -345,7 +349,7 @@ def ExecCompileIosFrameworkHeaderMap(self, out, framework, *all_headers):
345349
WriteHmap(out, filelist)
346350

347351
def ExecCopyIosFrameworkHeaders(self, framework, *copy_headers):
348-
header_path = os.path.join(framework, 'Headers');
352+
header_path = os.path.join(framework, 'Headers')
349353
if not os.path.exists(header_path):
350354
os.makedirs(header_path)
351355
for header in copy_headers:

gyp/xcode_emulation.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ def _AppendPlatformVersionMinFlags(self, lst):
529529
self._Appendf(lst, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s')
530530
if 'IPHONEOS_DEPLOYMENT_TARGET' in self._Settings():
531531
# TODO: Implement this better?
532-
sdk_path_basename = os.path.basename(self._SdkPath())
532+
skd_path = self._SdkPath()
533+
sdk_path_basename = os.path.basename(skd_path)
533534
if sdk_path_basename.lower().startswith('iphonesimulator'):
534535
self._Appendf(lst, 'IPHONEOS_DEPLOYMENT_TARGET', '-mios-simulator-version-min=%s')
535536
else:
@@ -1420,8 +1421,12 @@ def _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration, add
14201421
'TEMP_DIR': '${TMPDIR}',
14211422
'XCODE_VERSION_ACTUAL': XCodeDetect.Version(),
14221423
}
1423-
if xcode_settings.GetPerConfigSetting('SDKROOT', configuration):
1424-
env['SDKROOT'] = xcode_settings._SdkPath(configuration)
1424+
wanted_sdk = xcode_settings.GetPerConfigSetting('SDKROOT', configuration)
1425+
if wanted_sdk:
1426+
sdk_root = xcode_settings._SdkPath(configuration)
1427+
if sdk_root is None:
1428+
raise GypError('Could not find `%s` SDK' % wanted_sdk)
1429+
env['SDKROOT'] = sdk_root
14251430
else:
14261431
env['SDKROOT'] = ''
14271432

gyptest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def print_configuration_info():
121121
if sys.platform == 'darwin':
122122
print(' Mac %s %s' % (platform.mac_ver()[0], platform.mac_ver()[2]))
123123
try:
124-
from XCodeDetect import XCodeDetect
124+
import XCodeDetect
125125
print(' Xcode %s' % XCodeDetect.Version())
126126
except:
127127
pass
@@ -136,7 +136,7 @@ def print_configuration_info():
136136
elif sys.platform in ('linux', 'linux2'):
137137
# noinspection PyBroadException
138138
try:
139-
with open('/etc/lsb-release', mode='r', encoding='utf-8') as f:
139+
with open('/etc/lsb-release', mode='r') as f:
140140
dist = f.read().strip()
141141
print(' Linux %s' % dist)
142142
except:

pylib/__init__.py

Whitespace-only changes.

pylib/util.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/ios/gyptest-app-ios-assets-catalog.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
if XCodeDetect.Version() < '0600':
1414
test.skip_test('Skip test on XCode < 0600')
1515

16+
if not XCodeDetect.IPhoneSDKPath():
17+
test.skip_test('Skip test when no IPhone SDK')
18+
1619
test_gyp_path = 'test-assets-catalog.gyp'
1720
test_app_path = 'Test App Assets Catalog Gyp.app'
1821
test.run_gyp(test_gyp_path, chdir='app-bundle')

test/ios/gyptest-archs.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
Verifies that device and simulator bundles are built correctly.
99
"""
1010

11-
import collections
12-
1311
import TestGyp
1412
import XCodeDetect
1513

1614
test = TestGyp.TestGyp(formats=['ninja', 'xcode'], platforms=['darwin'])
1715

18-
if test.format == 'xcode':
19-
# This test appears to hang flakily.
20-
test.skip_test() # bug=532
16+
if not XCodeDetect.IPhoneSDKPath():
17+
test.skip_test('Skip test when no IPhone SDK')
2118

2219
test_cases = [
2320
('Default', 'TestArch32Bits', ['i386']),
@@ -40,7 +37,7 @@
4037
for configuration, target, archs in test_cases:
4138
is_device_build = configuration.endswith('-iphoneos')
4239

43-
kwds = collections.defaultdict(list)
40+
kwds = {}
4441
if test.format == 'xcode':
4542
if is_device_build:
4643
configuration, sdk = configuration.split('-')

test/ios/gyptest-copies-with-xcode-envvars.py

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,41 @@
1111
"""
1212

1313
import TestGyp
14-
15-
import os
16-
import stat
17-
import sys
18-
19-
20-
test = TestGyp.TestGyp(formats=['ninja', 'xcode'])
21-
22-
if sys.platform == 'darwin':
23-
test.run_gyp('copies-with-xcode-envvars.gyp',
24-
chdir='copies-with-xcode-envvars')
25-
26-
test.build('copies-with-xcode-envvars.gyp', chdir='copies-with-xcode-envvars')
27-
28-
wrapper_name = 'copies-with-xcode-envvars.app/'
29-
contents_path = wrapper_name
30-
out_path = test.built_file_path('file0', chdir='copies-with-xcode-envvars')
31-
test.must_contain(out_path, 'file0 contents\n')
32-
out_path = test.built_file_path(wrapper_name + 'file1', chdir='copies-with-xcode-envvars')
33-
test.must_contain(out_path, 'file1 contents\n')
34-
out_path = test.built_file_path(contents_path + 'file2', chdir='copies-with-xcode-envvars')
35-
test.must_contain(out_path, 'file2 contents\n')
36-
out_path = test.built_file_path(contents_path + 'file3', chdir='copies-with-xcode-envvars')
37-
test.must_contain(out_path, 'file3 contents\n')
38-
out_path = test.built_file_path(contents_path + 'testimages/file4', chdir='copies-with-xcode-envvars')
39-
test.must_contain(out_path, 'file4 contents\n')
40-
out_path = test.built_file_path(contents_path + 'Java/file5', chdir='copies-with-xcode-envvars')
41-
test.must_contain(out_path, 'file5 contents\n')
42-
out_path = test.built_file_path(contents_path + 'Frameworks/file6', chdir='copies-with-xcode-envvars')
43-
test.must_contain(out_path, 'file6 contents\n')
44-
out_path = test.built_file_path(contents_path + 'Frameworks/file7', chdir='copies-with-xcode-envvars')
45-
test.must_contain(out_path, 'file7 contents\n')
46-
out_path = test.built_file_path(contents_path + 'SharedFrameworks/file8', chdir='copies-with-xcode-envvars')
47-
test.must_contain(out_path, 'file8 contents\n')
48-
out_path = test.built_file_path(contents_path + 'SharedSupport/file9', chdir='copies-with-xcode-envvars')
49-
test.must_contain(out_path, 'file9 contents\n')
50-
out_path = test.built_file_path(contents_path + 'PlugIns/file10', chdir='copies-with-xcode-envvars')
51-
test.must_contain(out_path, 'file10 contents\n')
52-
out_path = test.built_file_path(contents_path + 'XPCServices/file11', chdir='copies-with-xcode-envvars')
53-
test.must_contain(out_path, 'file11 contents\n')
54-
test.pass_test()
14+
import XCodeDetect
15+
16+
test = TestGyp.TestGyp(formats=['ninja', 'xcode'], platforms=['darwin'])
17+
18+
if not XCodeDetect.IPhoneSDKPath():
19+
test.skip_test('Skip test when no IPhone SDK')
20+
21+
test.run_gyp('copies-with-xcode-envvars.gyp', chdir='copies-with-xcode-envvars')
22+
23+
test.build('copies-with-xcode-envvars.gyp', chdir='copies-with-xcode-envvars')
24+
25+
wrapper_name = 'copies-with-xcode-envvars.app/'
26+
contents_path = wrapper_name
27+
out_path = test.built_file_path('file0', chdir='copies-with-xcode-envvars')
28+
test.must_contain(out_path, 'file0 contents\n')
29+
out_path = test.built_file_path(wrapper_name + 'file1', chdir='copies-with-xcode-envvars')
30+
test.must_contain(out_path, 'file1 contents\n')
31+
out_path = test.built_file_path(contents_path + 'file2', chdir='copies-with-xcode-envvars')
32+
test.must_contain(out_path, 'file2 contents\n')
33+
out_path = test.built_file_path(contents_path + 'file3', chdir='copies-with-xcode-envvars')
34+
test.must_contain(out_path, 'file3 contents\n')
35+
out_path = test.built_file_path(contents_path + 'testimages/file4', chdir='copies-with-xcode-envvars')
36+
test.must_contain(out_path, 'file4 contents\n')
37+
out_path = test.built_file_path(contents_path + 'Java/file5', chdir='copies-with-xcode-envvars')
38+
test.must_contain(out_path, 'file5 contents\n')
39+
out_path = test.built_file_path(contents_path + 'Frameworks/file6', chdir='copies-with-xcode-envvars')
40+
test.must_contain(out_path, 'file6 contents\n')
41+
out_path = test.built_file_path(contents_path + 'Frameworks/file7', chdir='copies-with-xcode-envvars')
42+
test.must_contain(out_path, 'file7 contents\n')
43+
out_path = test.built_file_path(contents_path + 'SharedFrameworks/file8', chdir='copies-with-xcode-envvars')
44+
test.must_contain(out_path, 'file8 contents\n')
45+
out_path = test.built_file_path(contents_path + 'SharedSupport/file9', chdir='copies-with-xcode-envvars')
46+
test.must_contain(out_path, 'file9 contents\n')
47+
out_path = test.built_file_path(contents_path + 'PlugIns/file10', chdir='copies-with-xcode-envvars')
48+
test.must_contain(out_path, 'file10 contents\n')
49+
out_path = test.built_file_path(contents_path + 'XPCServices/file11', chdir='copies-with-xcode-envvars')
50+
test.must_contain(out_path, 'file11 contents\n')
51+
test.pass_test()

test/ios/gyptest-framework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
if XCodeDetect.Version() < '0700':
1111
test.skip_test('Skip test on XCode < 0700')
1212

13-
if test.format == 'xcode-ninja':
14-
test.skip_test()
13+
if not XCodeDetect.IPhoneSDKPath():
14+
test.skip_test('Skip test when no IPhone SDK')
1515

1616
test.run_gyp('framework.gyp', chdir='framework')
1717

0 commit comments

Comments
 (0)