| 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 app bundles are built correctly. | 8 Verifies that app bundles are built correctly. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import TestGyp | 11 import TestGyp |
| 12 import TestMac | 12 import TestMac |
| 13 | 13 |
| 14 import os | 14 import os |
| 15 import plistlib | 15 import plistlib |
| 16 import subprocess | 16 import subprocess |
| 17 import sys | 17 import sys |
| 18 | 18 |
| 19 | 19 |
| 20 def CheckFileXMLPropertyList(file): |
| 21 output = subprocess.check_output(['file', file]) |
| 22 # The double space after XML is intentional. |
| 23 if not 'XML document text' in output: |
| 24 print 'File: Expected XML document text, got %s' % output |
| 25 test.fail_test() |
| 26 |
| 20 def ExpectEq(expected, actual): | 27 def ExpectEq(expected, actual): |
| 21 if expected != actual: | 28 if expected != actual: |
| 22 print >>sys.stderr, 'Expected "%s", got "%s"' % (expected, actual) | 29 print >>sys.stderr, 'Expected "%s", got "%s"' % (expected, actual) |
| 23 test.fail_test() | 30 test.fail_test() |
| 24 | 31 |
| 25 def ls(path): | 32 def ls(path): |
| 26 '''Returns a list of all files in a directory, relative to the directory.''' | 33 '''Returns a list of all files in a directory, relative to the directory.''' |
| 27 result = [] | 34 result = [] |
| 28 for dirpath, _, files in os.walk(path): | 35 for dirpath, _, files in os.walk(path): |
| 29 for f in files: | 36 for f in files: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 # Binary | 48 # Binary |
| 42 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp', | 49 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp', |
| 43 chdir='app-bundle') | 50 chdir='app-bundle') |
| 44 | 51 |
| 45 # Info.plist | 52 # Info.plist |
| 46 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist', | 53 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist', |
| 47 chdir='app-bundle') | 54 chdir='app-bundle') |
| 48 test.must_exist(info_plist) | 55 test.must_exist(info_plist) |
| 49 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion | 56 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion |
| 50 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); | 57 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); |
| 58 CheckFileXMLPropertyList(info_plist) |
| 51 | 59 |
| 52 if test.format != 'make': | 60 if test.format != 'make': |
| 53 # TODO: Synthesized plist entries aren't hooked up in the make generator. | 61 # TODO: Synthesized plist entries aren't hooked up in the make generator. |
| 54 machine = subprocess.check_output(['sw_vers', '-buildVersion']).rstrip('\n') | 62 machine = subprocess.check_output(['sw_vers', '-buildVersion']).rstrip('\n') |
| 55 plist = plistlib.readPlist(info_plist) | 63 plist = plistlib.readPlist(info_plist) |
| 56 ExpectEq(machine, plist['BuildMachineOSBuild']) | 64 ExpectEq(machine, plist['BuildMachineOSBuild']) |
| 57 | 65 |
| 58 # Prior to Xcode 5.0.0, SDKROOT (and thus DTSDKName) was only defined if | 66 # Prior to Xcode 5.0.0, SDKROOT (and thus DTSDKName) was only defined if |
| 59 # set in the Xcode project file. Starting with that version, it is always | 67 # set in the Xcode project file. Starting with that version, it is always |
| 60 # defined. | 68 # defined. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 set(['Contents/MacOS/Test App Gyp', | 106 set(['Contents/MacOS/Test App Gyp', |
| 99 'Contents/Info.plist', | 107 'Contents/Info.plist', |
| 100 'Contents/Resources/English.lproj/MainMenu.nib', | 108 'Contents/Resources/English.lproj/MainMenu.nib', |
| 101 'Contents/PkgInfo', | 109 'Contents/PkgInfo', |
| 102 ] + | 110 ] + |
| 103 [os.path.join('Contents/Resources/English.lproj', f) | 111 [os.path.join('Contents/Resources/English.lproj', f) |
| 104 for f in strings_files]): | 112 for f in strings_files]): |
| 105 test.fail_test() | 113 test.fail_test() |
| 106 | 114 |
| 107 test.pass_test() | 115 test.pass_test() |
| OLD | NEW |