Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 old_cxxflags = None | |
| 21 if old_cxxflags in os.environ.keys(): | |
| 22 old_cxxflags = os.environ['CXXFLAGS'] | |
| 23 os.environ['CXXFLAGS'] = '-O0' | |
|
Evan Martin
2010/12/17 22:10:54
One idea to make this test simpler is to instead u
| |
| 24 test.run_gyp('cxxflags.gyp') | |
| 25 finally: | |
| 26 # We clear the environ after calling gyp. When the auto-regeneration happens, | |
| 27 # the same define should be reused anyway. Reset to empty string first in | |
| 28 # case the platform doesn't support unsetenv. | |
| 29 if old_cxxflags: | |
| 30 os.environ['CXXFLAGS'] = old_cxxflags | |
| 31 elif 'CXXFLAGS' in os.environ.keys(): | |
| 32 del os.environ['CXXFLAGS'] | |
| 33 | |
| 34 test.build('cxxflags.gyp') | |
| 35 | |
| 36 expect = """\ | |
| 37 Using no optimization flag | |
| 38 """ | |
| 39 test.run_built_executable('cxxflags', stdout=expect) | |
| 40 | |
| 41 test.sleep() | |
| 42 | |
| 43 try: | |
| 44 old_cxxflags = None | |
| 45 if old_cxxflags in os.environ.keys(): | |
| 46 old_cxxflags = os.environ['CXXFLAGS'] | |
| 47 os.environ['CXXFLAGS'] = '-O2' | |
| 48 test.run_gyp('cxxflags.gyp') | |
| 49 finally: | |
| 50 # We clear the environ after calling gyp. When the auto-regeneration happens, | |
| 51 # the same define should be reused anyway. Reset to empty string first in | |
| 52 # case the platform doesn't support unsetenv. | |
| 53 if old_cxxflags: | |
| 54 os.environ['CXXFLAGS'] = old_cxxflags | |
| 55 elif 'CXXFLAGS' in os.environ.keys(): | |
| 56 del os.environ['CXXFLAGS'] | |
| 57 | |
| 58 test.build('cxxflags.gyp') | |
| 59 | |
| 60 expect = """\ | |
| 61 Using an optimization flag | |
| 62 """ | |
| 63 test.run_built_executable('cxxflags', stdout=expect) | |
| 64 | |
| 65 test.pass_test() | |
| OLD | NEW |