OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Verifies that device and simulator bundles are built correctly. | 8 Verifies that device and simulator bundles are built correctly. |
9 """ | 9 """ |
10 | 10 |
11 import plistlib | |
11 import TestGyp | 12 import TestGyp |
12 import subprocess | 13 import subprocess |
13 import sys | 14 import sys |
14 | 15 |
15 | 16 |
16 def CheckFileType(file, expected): | 17 def CheckFileType(file, expected): |
17 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) | 18 proc = subprocess.Popen(['lipo', '-info', file], stdout=subprocess.PIPE) |
18 o = proc.communicate()[0].strip() | 19 o = proc.communicate()[0].strip() |
19 assert not proc.returncode | 20 assert not proc.returncode |
20 if not expected in o: | 21 if not expected in o: |
21 print 'File: Expected %s, got %s' % (expected, o) | 22 print 'File: Expected %s, got %s' % (expected, o) |
22 test.fail_test() | 23 test.fail_test() |
23 | 24 |
24 | 25 |
26 def CheckPlistvalue(plist, key, expected): | |
27 if key not in plist: | |
28 print '%s not set in plist' % key | |
29 test.fail_test() | |
30 return | |
31 actual = plist[key] | |
32 if actual != expected: | |
33 print 'File: Expected %s, got %s for %s' % (expected, actual, key) | |
34 test.fail_test() | |
35 | |
36 | |
25 if sys.platform == 'darwin': | 37 if sys.platform == 'darwin': |
26 # TODO(justincohen): Enable this in xcode too once ninja can codesign and bots | 38 # TODO(justincohen): Enable this in xcode too once ninja can codesign and bots |
27 # are configured with signing certs. | 39 # are configured with signing certs. |
28 test = TestGyp.TestGyp(formats=['ninja']) | 40 test = TestGyp.TestGyp(formats=['ninja']) |
29 | 41 |
30 test.run_gyp('test-device.gyp', chdir='app-bundle') | 42 test.run_gyp('test-device.gyp', chdir='app-bundle') |
31 | 43 |
32 for configuration in ['Default-iphoneos', 'Default']: | 44 for configuration in ['Default-iphoneos', 'Default']: |
33 test.set_configuration(configuration) | 45 test.set_configuration(configuration) |
34 test.build('test-device.gyp', test.ALL, chdir='app-bundle') | 46 test.build('test-device.gyp', test.ALL, chdir='app-bundle') |
35 result_file = test.built_file_path('Test App Gyp.bundle/Test App Gyp', | 47 result_file = test.built_file_path('Test App Gyp.bundle/Test App Gyp', |
36 chdir='app-bundle') | 48 chdir='app-bundle') |
37 test.must_exist(result_file) | 49 test.must_exist(result_file) |
50 | |
51 info_plist = test.built_file_path('Test App Gyp.bundle/Info.plist', | |
52 chdir='app-bundle') | |
53 plist = plistlib.readPlist(info_plist) | |
Nico
2013/10/11 20:20:49
Is it possible to put this in a test that runs und
justincohen
2013/10/12 14:52:28
Done, although I had to disable device builds for
| |
54 | |
55 CheckPlistvalue(plist, 'UIDeviceFamily', [1, 2]) | |
56 | |
38 if configuration == 'Default-iphoneos': | 57 if configuration == 'Default-iphoneos': |
39 CheckFileType(result_file, 'armv7') | 58 CheckFileType(result_file, 'armv7') |
59 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneOS']) | |
40 else: | 60 else: |
41 CheckFileType(result_file, 'i386') | 61 CheckFileType(result_file, 'i386') |
62 CheckPlistvalue(plist, 'CFBundleSupportedPlatforms', ['iPhoneSimulator']) | |
42 | 63 |
43 test.pass_test() | 64 test.pass_test() |
OLD | NEW |