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

Side by Side Diff: test/mac/gyptest-app.py

Issue 23781011: ninja/mac: Insert a few synthesized Info.plist entries. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « test/mac/app-bundle/TestApp/TestApp-Info.plist ('k') | test/mac/gyptest-sdkroot.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 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 12
13 import os 13 import os
14 import plistlib
15 import subprocess
14 import sys 16 import sys
15 17
18 def GetStdout(cmdlist):
19 return subprocess.Popen(cmdlist,
20 stdout=subprocess.PIPE).communicate()[0].rstrip('\n')
21
22 def ExpectEq(expected, actual):
23 if expected != actual:
24 print >>sys.stderr, 'Expected "%s", got "%s"' % (expected, actual)
25 test.fail_test()
16 26
17 def ls(path): 27 def ls(path):
18 '''Returns a list of all files in a directory, relative to the directory.''' 28 '''Returns a list of all files in a directory, relative to the directory.'''
19 result = [] 29 result = []
20 for dirpath, _, files in os.walk(path): 30 for dirpath, _, files in os.walk(path):
21 for f in files: 31 for f in files:
22 result.append(os.path.join(dirpath, f)[len(path) + 1:]) 32 result.append(os.path.join(dirpath, f)[len(path) + 1:])
23 return result 33 return result
24 34
25 35
26 if sys.platform == 'darwin': 36 if sys.platform == 'darwin':
27 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) 37 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
28 38
29 test.run_gyp('test.gyp', chdir='app-bundle') 39 test.run_gyp('test.gyp', chdir='app-bundle')
30 40
31 test.build('test.gyp', test.ALL, chdir='app-bundle') 41 test.build('test.gyp', test.ALL, chdir='app-bundle')
32 42
33 # Binary 43 # Binary
34 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp', 44 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp',
35 chdir='app-bundle') 45 chdir='app-bundle')
36 46
37 # Info.plist 47 # Info.plist
38 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist', 48 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist',
39 chdir='app-bundle') 49 chdir='app-bundle')
40 test.must_exist(info_plist) 50 test.must_exist(info_plist)
41 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion 51 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion
42 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); 52 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}');
43 53
54 if test.format != 'make':
55 # TODO: Synthesized plist entries aren't hooked up in the make generator.
56 plist = plistlib.readPlist(info_plist)
57 ExpectEq(GetStdout(['sw_vers', '-buildVersion']),
58 plist['BuildMachineOSBuild'])
59 ExpectEq('', plist['DTSDKName'])
60 sdkbuild = GetStdout(
61 ['xcodebuild', '-version', '-sdk', '', 'ProductBuildVersion'])
62 if not sdkbuild:
63 # Above command doesn't work in Xcode 4.2.
64 sdkbuild = plist['BuildMachineOSBuild']
65 ExpectEq(sdkbuild, plist['DTSDKBuild'])
66 xcode, build = GetStdout(['xcodebuild', '-version']).splitlines()
67 xcode = xcode.split()[-1].replace('.', '')
68 xcode = (xcode + '0' * (3 - len(xcode))).zfill(4)
69 build = build.split()[-1]
70 ExpectEq(xcode, plist['DTXcode'])
71 ExpectEq(build, plist['DTXcodeBuild'])
72
44 # Resources 73 # Resources
45 strings_files = ['InfoPlist.strings', 'utf-16be.strings', 'utf-16le.strings'] 74 strings_files = ['InfoPlist.strings', 'utf-16be.strings', 'utf-16le.strings']
46 for f in strings_files: 75 for f in strings_files:
47 strings = test.built_file_path( 76 strings = test.built_file_path(
48 os.path.join('Test App Gyp.app/Contents/Resources/English.lproj', f), 77 os.path.join('Test App Gyp.app/Contents/Resources/English.lproj', f),
49 chdir='app-bundle') 78 chdir='app-bundle')
50 test.must_exist(strings) 79 test.must_exist(strings)
51 # Xcodes writes UTF-16LE with BOM. 80 # Xcodes writes UTF-16LE with BOM.
52 contents = open(strings, 'rb').read() 81 contents = open(strings, 'rb').read()
53 if not contents.startswith('\xff\xfe' + '/* Localized'.encode('utf-16le')): 82 if not contents.startswith('\xff\xfe' + '/* Localized'.encode('utf-16le')):
(...skipping 14 matching lines...) Expand all
68 set(['Contents/MacOS/Test App Gyp', 97 set(['Contents/MacOS/Test App Gyp',
69 'Contents/Info.plist', 98 'Contents/Info.plist',
70 'Contents/Resources/English.lproj/MainMenu.nib', 99 'Contents/Resources/English.lproj/MainMenu.nib',
71 'Contents/PkgInfo', 100 'Contents/PkgInfo',
72 ] + 101 ] +
73 [os.path.join('Contents/Resources/English.lproj', f) 102 [os.path.join('Contents/Resources/English.lproj', f)
74 for f in strings_files]): 103 for f in strings_files]):
75 test.fail_test() 104 test.fail_test()
76 105
77 test.pass_test() 106 test.pass_test()
OLDNEW
« no previous file with comments | « test/mac/app-bundle/TestApp/TestApp-Info.plist ('k') | test/mac/gyptest-sdkroot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698