1 #!/usr/bin/env python 2 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 5 # found in the LICENSE file. 6 7 """ 8 Verifies that dependent Xcode settings are processed correctly. 9 """ 10 11 import TestGyp 12 13 import subprocess 14 import sys 15 16 def XcodeVersion(): 17 stdout = subprocess.check_output(['xcodebuild', '-version']) 18 version = stdout.splitlines()[0].split()[-1].replace('.', '') 19 return (version + '0' * (3 - len(version))).zfill(4) 20 21 if sys.platform == 'darwin': 22 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) 23 24 CHDIR = 'xcode-env-order' 25 INFO_PLIST_PATH = 'Test.app/Contents/Info.plist' 26 27 test.run_gyp('test.gyp', chdir=CHDIR) 28 test.build('test.gyp', test.ALL, chdir=CHDIR) 29 30 # Env vars in 'copies' filenames. 31 test.built_file_must_exist('Test-copy-brace/main.c', chdir=CHDIR) 32 test.built_file_must_exist('Test-copy-paren/main.c', chdir=CHDIR) 33 test.built_file_must_exist('Test-copy-bare/main.c', chdir=CHDIR) 34 35 # Env vars in 'actions' filenames and inline actions 36 test.built_file_must_exist('action-copy-brace.txt', chdir=CHDIR) 37 test.built_file_must_exist('action-copy-paren.txt', chdir=CHDIR) 38 test.built_file_must_exist('action-copy-bare.txt', chdir=CHDIR) 39 40 # Env vars in 'rules' filenames and inline actions 41 test.built_file_must_exist('rule-copy-brace.txt', chdir=CHDIR) 42 test.built_file_must_exist('rule-copy-paren.txt', chdir=CHDIR) 43 # TODO: see comment in test.gyp for this file. 44 #test.built_file_must_exist('rule-copy-bare.txt', chdir=CHDIR) 45 46 # Env vars in Info.plist. 47 info_plist = test.built_file_path(INFO_PLIST_PATH, chdir=CHDIR) 48 test.must_exist(info_plist) 49 50 test.must_contain(info_plist, '''\ 51 \t<key>BraceProcessedKey1</key> 52 \t<string>D:/Source/Project/Test</string>''') 53 test.must_contain(info_plist, '''\ 54 \t<key>BraceProcessedKey2</key> 55 \t<string>/Source/Project/Test</string>''') 56 test.must_contain(info_plist, '''\ 57 \t<key>BraceProcessedKey3</key> 58 \t<string>com.apple.product-type.application:D:/Source/Project/Test</string>''') 59 60 test.must_contain(info_plist, '''\ 61 \t<key>ParenProcessedKey1</key> 62 \t<string>D:/Source/Project/Test</string>''') 63 test.must_contain(info_plist, '''\ 64 \t<key>ParenProcessedKey2</key> 65 \t<string>/Source/Project/Test</string>''') 66 test.must_contain(info_plist, '''\ 67 \t<key>ParenProcessedKey3</key> 68 \t<string>com.apple.product-type.application:D:/Source/Project/Test</string>''') 69 70 test.must_contain(info_plist, '''\ 71 \t<key>BareProcessedKey1</key> 72 \t<string>D:/Source/Project/Test</string>''') 73 test.must_contain(info_plist, '''\ 74 \t<key>BareProcessedKey2</key> 75 \t<string>/Source/Project/Test</string>''') 76 # NOTE: For bare variables, $PRODUCT_TYPE is not replaced! It _is_ replaced 77 # if it's not right at the start of the string (e.g. ':$PRODUCT_TYPE'), so 78 # this looks like an Xcode bug. This bug isn't emulated (yet?), so check this 79 # only for Xcode. 80 if test.format == 'xcode' and XcodeVersion() < '0500': 81 test.must_contain(info_plist, '''\ 82 \t<key>BareProcessedKey3</key> 83 \t<string>$PRODUCT_TYPE:D:/Source/Project/Test</string>''') 84 else: 85 # The bug has been fixed by Xcode version 5.0.0. 86 test.must_contain(info_plist, '''\ 87 \t<key>BareProcessedKey3</key> 88 \t<string>com.apple.product-type.application:D:/Source/Project/Test</string>''') 89 90 test.must_contain(info_plist, '''\ 91 \t<key>MixedProcessedKey</key> 92 \t<string>/Source/Project:Test:mh_execute</string>''') 93 94 test.pass_test() 95