1
0

gyptest-regyp.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # Copyright (c) 2012 Google Inc. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """
  6. Verifies that when the same value is repeated for a gyp define, duplicates are
  7. stripped from the regeneration rule.
  8. """
  9. import os
  10. import TestGyp
  11. # Regenerating build files when a gyp file changes is currently only supported
  12. # by the make generator.
  13. test = TestGyp.TestGyp(formats=['make'])
  14. os.environ['GYP_DEFINES'] = 'key=repeated_value key=value1 key=repeated_value'
  15. test.run_gyp('defines.gyp')
  16. test.build('defines.gyp')
  17. # The last occurrence of a repeated set should take precedence over other
  18. # values. See gyptest-multiple-values.py.
  19. test.must_contain('action.txt', 'repeated_value')
  20. # So the regeneration rule needs to use the correct order.
  21. test.must_not_contain(
  22. 'Makefile', '"-Dkey=repeated_value" "-Dkey=value1" "-Dkey=repeated_value"')
  23. test.must_contain('Makefile', '"-Dkey=value1" "-Dkey=repeated_value"')
  24. # Sleep so that the changed gyp file will have a newer timestamp than the
  25. # previously generated build files.
  26. test.sleep()
  27. os.utime("defines.gyp", None)
  28. test.build('defines.gyp')
  29. test.must_contain('action.txt', 'repeated_value')
  30. test.pass_test()