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 the use of the environment during regeneration when the gyp file 9 changes, specifically via build of an executable with C++ flags specified by 10 CXXFLAGS. 11 12 In this test, gyp happens within a local environment, but build outside of it. 13 """ 14 15 import TestGyp 16 17 FORMATS = ('ninja',) 18 19 test = TestGyp.TestGyp(formats=FORMATS) 20 21 # We reset the environ after calling gyp. When the auto-regeneration happens, 22 # the same define should be reused anyway. 23 with TestGyp.LocalEnv({'CXXFLAGS': ''}): 24 test.run_gyp('cxxflags.gyp') 25 26 test.build('cxxflags.gyp') 27 28 expect = """\ 29 No define 30 """ 31 test.run_built_executable('cxxflags', stdout=expect) 32 33 test.sleep() 34 35 with TestGyp.LocalEnv({'CXXFLAGS': '-DABC'}): 36 test.run_gyp('cxxflags.gyp') 37 38 test.build('cxxflags.gyp') 39 40 expect = """\ 41 With define 42 """ 43 test.run_built_executable('cxxflags', stdout=expect) 44 45 test.pass_test() 46