Home | History | Annotate | Download | only in defines
      1 #!/usr/bin/env python
      2 
      3 # Copyright (c) 2009 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 a default gyp define can be overridden.
      9 """
     10 
     11 import os
     12 import TestGyp
     13 
     14 test = TestGyp.TestGyp()
     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 
     25 # Command-line define
     26 test.run_gyp('defines.gyp', '-D', 'OS=fakeos')
     27 test.build('defines.gyp', stderr=expect_stderr)
     28 test.built_file_must_exist('fakeosprogram', type=test.EXECUTABLE)
     29 # Clean up the exe so subsequent tests don't find an old exe.
     30 os.remove(test.built_file_path('fakeosprogram', type=test.EXECUTABLE))
     31 
     32 # Without "OS" override, fokeosprogram shouldn't be built.
     33 test.run_gyp('defines.gyp')
     34 test.build('defines.gyp', stderr=expect_stderr)
     35 test.built_file_must_not_exist('fakeosprogram', type=test.EXECUTABLE)
     36 
     37 # Environment define
     38 os.environ['GYP_DEFINES'] = 'OS=fakeos'
     39 test.run_gyp('defines.gyp')
     40 test.build('defines.gyp', stderr=expect_stderr)
     41 test.built_file_must_exist('fakeosprogram', type=test.EXECUTABLE)
     42 
     43 test.pass_test()
     44