~hjd/ubuntu/wily/gyp/debian-merged

« back to all changes in this revision

Viewing changes to test/cflags/gyptest-cflags.py

  • Committer: Hans Joachim Desserud
  • Date: 2015-10-31 12:46:59 UTC
  • mfrom: (6.2.6 sid)
  • Revision ID: hans_joachim_desserud-20151031124659-lzxekr6woskh4k0b
Merge latest Debian version

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
# found in the LICENSE file.
6
6
 
7
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.
 
8
Verifies the use of the environment during regeneration when the gyp file
 
9
changes, specifically via build of an executable with C preprocessor
 
10
definition specified by CFLAGS.
 
11
 
 
12
In this test, gyp and build both run in same local environment.
10
13
"""
11
14
 
12
 
import os
13
 
import sys
14
15
import TestGyp
15
16
 
16
 
env_stack = []
17
 
 
18
 
 
19
 
def PushEnv():
20
 
  env_copy = os.environ.copy()
21
 
  env_stack.append(env_copy)
22
 
 
23
 
def PopEnv():
24
 
  os.environ.clear()
25
 
  os.environ.update(env_stack.pop())
26
 
 
27
 
formats = ['make', 'ninja']
28
 
 
29
 
test = TestGyp.TestGyp(formats=formats)
30
 
 
31
 
try:
32
 
  PushEnv()
33
 
  os.environ['CFLAGS'] = ''
34
 
  os.environ['GYP_CROSSCOMPILE'] = '1'
 
17
# CPPFLAGS works in ninja but not make; CFLAGS works in both
 
18
FORMATS = ('make', 'ninja')
 
19
 
 
20
test = TestGyp.TestGyp(formats=FORMATS)
 
21
 
 
22
# First set CFLAGS to blank in case the platform doesn't support unsetenv.
 
23
with TestGyp.LocalEnv({'CFLAGS': '',
 
24
                       'GYP_CROSSCOMPILE': '1'}):
35
25
  test.run_gyp('cflags.gyp')
36
26
  test.build('cflags.gyp')
37
 
finally:
38
 
  # We clear the environ after calling gyp.  When the auto-regeneration happens,
39
 
  # the same define should be reused anyway.  Reset to empty string first in
40
 
  # case the platform doesn't support unsetenv.
41
 
  PopEnv()
42
 
 
43
27
 
44
28
expect = """FOO not defined\n"""
45
29
test.run_built_executable('cflags', stdout=expect)
47
31
 
48
32
test.sleep()
49
33
 
50
 
try:
51
 
  PushEnv()
52
 
  os.environ['CFLAGS'] = '-DFOO=1'
53
 
  os.environ['GYP_CROSSCOMPILE'] = '1'
 
34
with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1',
 
35
                       'GYP_CROSSCOMPILE': '1'}):
54
36
  test.run_gyp('cflags.gyp')
55
37
  test.build('cflags.gyp')
56
 
finally:
57
 
  # We clear the environ after calling gyp.  When the auto-regeneration happens,
58
 
  # the same define should be reused anyway.  Reset to empty string first in
59
 
  # case the platform doesn't support unsetenv.
60
 
  PopEnv()
61
 
 
62
38
 
63
39
expect = """FOO defined\n"""
64
40
test.run_built_executable('cflags', stdout=expect)
69
45
 
70
46
test.sleep()
71
47
 
72
 
try:
73
 
  PushEnv()
74
 
  os.environ['CFLAGS'] = ''
 
48
with TestGyp.LocalEnv({'CFLAGS': ''}):
75
49
  test.run_gyp('cflags.gyp')
76
50
  test.build('cflags.gyp')
77
 
finally:
78
 
  # We clear the environ after calling gyp.  When the auto-regeneration happens,
79
 
  # the same define should be reused anyway.  Reset to empty string first in
80
 
  # case the platform doesn't support unsetenv.
81
 
  PopEnv()
82
 
 
83
51
 
84
52
expect = """FOO not defined\n"""
85
53
test.run_built_executable('cflags', stdout=expect)
86
54
 
87
55
test.sleep()
88
56
 
89
 
try:
90
 
  PushEnv()
91
 
  os.environ['CFLAGS'] = '-DFOO=1'
 
57
with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1'}):
92
58
  test.run_gyp('cflags.gyp')
93
59
  test.build('cflags.gyp')
94
 
finally:
95
 
  # We clear the environ after calling gyp.  When the auto-regeneration happens,
96
 
  # the same define should be reused anyway.  Reset to empty string first in
97
 
  # case the platform doesn't support unsetenv.
98
 
  PopEnv()
99
 
 
100
60
 
101
61
expect = """FOO defined\n"""
102
62
test.run_built_executable('cflags', stdout=expect)