#!/usr/bin/env python
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Verifies that dependent Xcode settings are processed correctly.
"""
from __future__ import print_function
import TestGyp
import TestMac
import subprocess
import sys
if sys.platform == 'darwin':
print("This test is currently disabled: https://crbug.com/483696.")
sys.exit(0)
test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
CHDIR = 'xcode-env-order'
INFO_PLIST_PATH = 'Test.app/Contents/Info.plist'
test.run_gyp('test.gyp', chdir=CHDIR)
test.build('test.gyp', test.ALL, chdir=CHDIR)
# Env vars in 'copies' filenames.
test.built_file_must_exist('Test-copy-brace/main.c', chdir=CHDIR)
test.built_file_must_exist('Test-copy-paren/main.c', chdir=CHDIR)
test.built_file_must_exist('Test-copy-bare/main.c', chdir=CHDIR)
# Env vars in 'actions' filenames and inline actions
test.built_file_must_exist('action-copy-brace.txt', chdir=CHDIR)
test.built_file_must_exist('action-copy-paren.txt', chdir=CHDIR)
test.built_file_must_exist('action-copy-bare.txt', chdir=CHDIR)
# Env vars in 'rules' filenames and inline actions
test.built_file_must_exist('rule-copy-brace.txt', chdir=CHDIR)
test.built_file_must_exist('rule-copy-paren.txt', chdir=CHDIR)
# TODO: see comment in test.gyp for this file.
#test.built_file_must_exist('rule-copy-bare.txt', chdir=CHDIR)
# Env vars in Info.plist.
info_plist = test.built_file_path(INFO_PLIST_PATH, chdir=CHDIR)
test.must_exist(info_plist)
test.must_contain(info_plist, '''\
\tBraceProcessedKey1
\tD:/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tBraceProcessedKey2
\t/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tBraceProcessedKey3
\tcom.apple.product-type.application:D:/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tParenProcessedKey1
\tD:/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tParenProcessedKey2
\t/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tParenProcessedKey3
\tcom.apple.product-type.application:D:/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tBareProcessedKey1
\tD:/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tBareProcessedKey2
\t/Source/Project/Test''')
# NOTE: For bare variables, $PRODUCT_TYPE is not replaced! It _is_ replaced
# if it's not right at the start of the string (e.g. ':$PRODUCT_TYPE'), so
# this looks like an Xcode bug. This bug isn't emulated (yet?), so check this
# only for Xcode.
if test.format == 'xcode' and TestMac.Xcode.Version() < '0500':
test.must_contain(info_plist, '''\
\tBareProcessedKey3
\t$PRODUCT_TYPE:D:/Source/Project/Test''')
else:
# The bug has been fixed by Xcode version 5.0.0.
test.must_contain(info_plist, '''\
\tBareProcessedKey3
\tcom.apple.product-type.application:D:/Source/Project/Test''')
test.must_contain(info_plist, '''\
\tMixedProcessedKey
\t/Source/Project:Test:mh_execute''')
test.pass_test()