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