gyptest-defines.py 973 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. # Copyright (c) 2011 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 build of an executable with C++ defines.
  7. """
  8. import TestGyp
  9. test = TestGyp.TestGyp()
  10. test.run_gyp('defines.gyp')
  11. expect = """\
  12. FOO is defined
  13. VALUE is 1
  14. 2*PAREN_VALUE is 12
  15. """
  16. #CMake loudly warns about passing '#' to the compiler and drops the define.
  17. expect_stderr = ''
  18. if test.format == 'cmake':
  19. expect_stderr = (
  20. """WARNING: Preprocessor definitions containing '#' may not be passed on the"""
  21. """ compiler command line because many compilers do not support it.\n"""
  22. """CMake is dropping a preprocessor definition: HASH_VALUE="a#1"\n"""
  23. """Consider defining the macro in a (configured) header file.\n\n""")
  24. else:
  25. expect += """HASH_VALUE is a#1
  26. """
  27. test.build('defines.gyp', stderr=expect_stderr)
  28. test.run_built_executable('defines', stdout=expect)
  29. test.pass_test()