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

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
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')
16 21
17 def ls(path): 22 def ls(path):
18 '''Returns a list of all files in a directory, relative to the directory.''' 23 '''Returns a list of all files in a directory, relative to the directory.'''
19 result = [] 24 result = []
20 for dirpath, _, files in os.walk(path): 25 for dirpath, _, files in os.walk(path):
21 for f in files: 26 for f in files:
22 result.append(os.path.join(dirpath, f)[len(path) + 1:]) 27 result.append(os.path.join(dirpath, f)[len(path) + 1:])
23 return result 28 return result
24 29
25 30
26 if sys.platform == 'darwin': 31 if sys.platform == 'darwin':
27 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) 32 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
28 33
29 test.run_gyp('test.gyp', chdir='app-bundle') 34 test.run_gyp('test.gyp', chdir='app-bundle')
30 35
31 test.build('test.gyp', test.ALL, chdir='app-bundle') 36 test.build('test.gyp', test.ALL, chdir='app-bundle')
32 37
33 # Binary 38 # Binary
34 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp', 39 test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp',
35 chdir='app-bundle') 40 chdir='app-bundle')
36 41
37 # Info.plist 42 # Info.plist
38 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist', 43 info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist',
39 chdir='app-bundle') 44 chdir='app-bundle')
40 test.must_exist(info_plist) 45 test.must_exist(info_plist)
41 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion 46 test.must_contain(info_plist, 'com.google.Test-App-Gyp') # Variable expansion
42 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); 47 test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}');
43 48
49 if test.format != 'make':
50 # TODO: Synthesized plist entries aren't hooked up in the make generator.
51 plist = plistlib.readPlist(info_plist)
52 if plist['BuildMachineOSBuild'] != GetStdout(['sw_vers', '-buildVersion']):
53 test.fail_test()
54 if plist['DTSDKName'] != '':
55 test.fail_test()
56 if plist['DTSDKBuild'] != GetStdout(
57 ['xcodebuild', '-version', '-sdk', '', 'ProductBuildVersion']):
58 test.fail_test()
59 xcode, build = GetStdout(['xcodebuild', '-version']).splitlines()
60 xcode = xcode.split()[-1].replace('.', '').zfill(4)
Nico 2013/09/17 22:03:49 It might seem silly to have the same test here as
scottmg 2013/09/17 22:27:44 Oh, I thought maybe that was a first https://code.
61 build = build.split()[-1]
62 if plist['DTXcode'] != xcode:
63 test.fail_test()
64 if plist['DTXcodeBuild'] != build:
65 test.fail_test()
66
44 # Resources 67 # Resources
45 strings_files = ['InfoPlist.strings', 'utf-16be.strings', 'utf-16le.strings'] 68 strings_files = ['InfoPlist.strings', 'utf-16be.strings', 'utf-16le.strings']
46 for f in strings_files: 69 for f in strings_files:
47 strings = test.built_file_path( 70 strings = test.built_file_path(
48 os.path.join('Test App Gyp.app/Contents/Resources/English.lproj', f), 71 os.path.join('Test App Gyp.app/Contents/Resources/English.lproj', f),
49 chdir='app-bundle') 72 chdir='app-bundle')
50 test.must_exist(strings) 73 test.must_exist(strings)
51 # Xcodes writes UTF-16LE with BOM. 74 # Xcodes writes UTF-16LE with BOM.
52 contents = open(strings, 'rb').read() 75 contents = open(strings, 'rb').read()
53 if not contents.startswith('\xff\xfe' + '/* Localized'.encode('utf-16le')): 76 if not contents.startswith('\xff\xfe' + '/* Localized'.encode('utf-16le')):
(...skipping 14 matching lines...) Expand all
68 set(['Contents/MacOS/Test App Gyp', 91 set(['Contents/MacOS/Test App Gyp',
69 'Contents/Info.plist', 92 'Contents/Info.plist',
70 'Contents/Resources/English.lproj/MainMenu.nib', 93 'Contents/Resources/English.lproj/MainMenu.nib',
71 'Contents/PkgInfo', 94 'Contents/PkgInfo',
72 ] + 95 ] +
73 [os.path.join('Contents/Resources/English.lproj', f) 96 [os.path.join('Contents/Resources/English.lproj', f)
74 for f in strings_files]): 97 for f in strings_files]):
75 test.fail_test() 98 test.fail_test()
76 99
77 test.pass_test() 100 test.pass_test()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698