initial import
[vuplus_webkit] / Source / ThirdParty / gyp / test / defines / gyptest-defines-env-regyp.py
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 build of an executable with C++ define specified by a gyp define, and
9 the use of the environment during regeneration when the gyp file changes.
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 try:
20   os.environ['GYP_DEFINES'] = 'value=50'
21   test.run_gyp('defines.gyp')
22 finally:
23   # We clear the environ after calling gyp.  When the auto-regeneration happens,
24   # the same define should be reused anyway.  Reset to empty string first in
25   # case the platform doesn't support unsetenv.
26   os.environ['GYP_DEFINES'] = ''
27   del os.environ['GYP_DEFINES']
28
29 test.build('defines.gyp')
30
31 expect = """\
32 FOO is defined
33 VALUE is 1
34 """
35 test.run_built_executable('defines', stdout=expect)
36
37 # Sleep so that the changed gyp file will have a newer timestamp than the
38 # previously generated build files.
39 test.sleep()
40 test.write('defines.gyp', test.read('defines-env.gyp'))
41
42 test.build('defines.gyp', test.ALL)
43
44 expect = """\
45 VALUE is 50
46 """
47 test.run_built_executable('defines', stdout=expect)
48
49 test.pass_test()