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 20 test.build('defines.gyp') 21 test.must_contain('action.txt', 'value3') 22 23 # The last occurrence of a repeated set should take precedence over other 24 # values. 25 os.environ['GYP_DEFINES'] = 'key=repeated_value key=value1 key=repeated_value' 26 test.run_gyp('defines.gyp') 27 28 if test.format == 'msvs' and not test.uses_msbuild: 29 # msvs versions before 2010 don't detect build rule changes not reflected 30 # in file system timestamps. Rebuild to see differences. 31 test.build('defines.gyp', rebuild=True) 32 else: 33 test.build('defines.gyp') 34 test.must_contain('action.txt', 'repeated_value') 35 36 test.pass_test() 37