Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | |
michael@0 | 3 | # Copyright (c) 2012 Google Inc. All rights reserved. |
michael@0 | 4 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | # found in the LICENSE file. |
michael@0 | 6 | |
michael@0 | 7 | """ |
michael@0 | 8 | Verifies build of an executable with C++ define specified by a gyp define, and |
michael@0 | 9 | the use of the environment during regeneration when the gyp file changes. |
michael@0 | 10 | """ |
michael@0 | 11 | |
michael@0 | 12 | import os |
michael@0 | 13 | import TestGyp |
michael@0 | 14 | |
michael@0 | 15 | env_stack = [] |
michael@0 | 16 | |
michael@0 | 17 | |
michael@0 | 18 | def PushEnv(): |
michael@0 | 19 | env_copy = os.environ.copy() |
michael@0 | 20 | env_stack.append(env_copy) |
michael@0 | 21 | |
michael@0 | 22 | def PopEnv(): |
michael@0 | 23 | os.eniron=env_stack.pop() |
michael@0 | 24 | |
michael@0 | 25 | # Regenerating build files when a gyp file changes is currently only supported |
michael@0 | 26 | # by the make and Android generators. |
michael@0 | 27 | test = TestGyp.TestGyp(formats=['make', 'android']) |
michael@0 | 28 | |
michael@0 | 29 | try: |
michael@0 | 30 | PushEnv() |
michael@0 | 31 | os.environ['CFLAGS'] = '-O0' |
michael@0 | 32 | test.run_gyp('cflags.gyp') |
michael@0 | 33 | finally: |
michael@0 | 34 | # We clear the environ after calling gyp. When the auto-regeneration happens, |
michael@0 | 35 | # the same define should be reused anyway. Reset to empty string first in |
michael@0 | 36 | # case the platform doesn't support unsetenv. |
michael@0 | 37 | PopEnv() |
michael@0 | 38 | |
michael@0 | 39 | test.build('cflags.gyp') |
michael@0 | 40 | |
michael@0 | 41 | expect = """\ |
michael@0 | 42 | Using no optimization flag |
michael@0 | 43 | """ |
michael@0 | 44 | test.run_built_executable('cflags', stdout=expect) |
michael@0 | 45 | |
michael@0 | 46 | test.sleep() |
michael@0 | 47 | |
michael@0 | 48 | try: |
michael@0 | 49 | PushEnv() |
michael@0 | 50 | os.environ['CFLAGS'] = '-O2' |
michael@0 | 51 | test.run_gyp('cflags.gyp') |
michael@0 | 52 | finally: |
michael@0 | 53 | # We clear the environ after calling gyp. When the auto-regeneration happens, |
michael@0 | 54 | # the same define should be reused anyway. Reset to empty string first in |
michael@0 | 55 | # case the platform doesn't support unsetenv. |
michael@0 | 56 | PopEnv() |
michael@0 | 57 | |
michael@0 | 58 | test.build('cflags.gyp') |
michael@0 | 59 | |
michael@0 | 60 | expect = """\ |
michael@0 | 61 | Using an optimization flag |
michael@0 | 62 | """ |
michael@0 | 63 | test.run_built_executable('cflags', stdout=expect) |
michael@0 | 64 | |
michael@0 | 65 | test.pass_test() |