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