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""" 8Verifies that when the same value is repeated for a gyp define, duplicates are 9stripped from the regeneration rule. 10""" 11 12import os 13import TestGyp 14 15# Regenerating build files when a gyp file changes is currently only supported 16# by the make generator. 17test = TestGyp.TestGyp(formats=['make']) 18 19os.environ['GYP_DEFINES'] = 'key=repeated_value key=value1 key=repeated_value' 20test.run_gyp('defines.gyp') 21test.build('defines.gyp') 22 23# The last occurrence of a repeated set should take precedence over other 24# values. See gyptest-multiple-values.py. 25test.must_contain('action.txt', 'repeated_value') 26 27# So the regeneration rule needs to use the correct order. 28test.must_not_contain( 29 'Makefile', '"-Dkey=repeated_value" "-Dkey=value1" "-Dkey=repeated_value"') 30test.must_contain('Makefile', '"-Dkey=value1" "-Dkey=repeated_value"') 31 32# Sleep so that the changed gyp file will have a newer timestamp than the 33# previously generated build files. 34test.sleep() 35os.utime("defines.gyp", None) 36 37test.build('defines.gyp') 38test.must_contain('action.txt', 'repeated_value') 39 40test.pass_test() 41