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 when multiple values are supplied for a gyp define, the last one 9 is used. 10 """ 11 12 import os 13 import TestGyp 14 15 test = TestGyp.TestGyp() 16 17 os.environ['GYP_DEFINES'] = 'key=value1 key=value2 key=value3' 18 test.run_gyp('defines.gyp') 19 test.build('defines.gyp') 20 test.must_contain('action.txt', 'value3') 21 22 # The last occurrence of a repeated set should take precedence over other 23 # values. 24 os.environ['GYP_DEFINES'] = 'key=repeated_value key=value1 key=repeated_value' 25 test.run_gyp('defines.gyp') 26 if test.format == 'msvs' and not test.uses_msbuild: 27 # msvs versions before 2010 don't detect build rule changes not reflected 28 # in file system timestamps. Rebuild to see differences. 29 test.build('defines.gyp', rebuild=True) 30 elif test.format == 'android': 31 # The Android build system doesn't currently have a way to get files whose 32 # build rules have changed (but whose timestamps haven't) to be rebuilt. 33 # See bug http://code.google.com/p/gyp/issues/detail?id=308 34 test.unlink('action.txt') 35 test.build('defines.gyp') 36 else: 37 test.build('defines.gyp') 38 test.must_contain('action.txt', 'repeated_value') 39 40 test.pass_test() 41