Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: test/make_global_settings/ar/gyptest-make_global_settings_ar.py

Issue 321183002: Use context manager to manage OS environment in tests (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2014 Google Inc. All rights reserved. 3 # Copyright (c) 2014 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """ 7 """
8 Verifies 'AR' in make_global_settings. 8 Verifies 'AR' in make_global_settings.
9 """ 9 """
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 test.run_gyp('make_global_settings_ar.gyp', 94 test.run_gyp('make_global_settings_ar.gyp',
95 '-Dcustom_ar_target=my_ar_target1', 95 '-Dcustom_ar_target=my_ar_target1',
96 '-Dcustom_ar_host=my_ar_host1') 96 '-Dcustom_ar_host=my_ar_host1')
97 # TODO(yukawa): Support 'AR'/'AR.host' in Ninja generator 97 # TODO(yukawa): Support 'AR'/'AR.host' in Ninja generator
98 if test.format == 'make': 98 if test.format == 'make':
99 verify_ar_target(test, ar='my_ar_target1', rel_path=True) 99 verify_ar_target(test, ar='my_ar_target1', rel_path=True)
100 verify_ar_host(test, ar='my_ar_host1', rel_path=True) 100 verify_ar_host(test, ar='my_ar_host1', rel_path=True)
101 101
102 102
103 # Test $AR and $AR_host environment variables. 103 # Test $AR and $AR_host environment variables.
104 try: 104 with TestGyp.LocalEnv({'AR': 'my_ar_target2',
105 os.environ['AR'] = 'my_ar_target2' 105 'AR_host': 'my_ar_host2'}):
106 os.environ['AR_host'] = 'my_ar_host2'
107 test.run_gyp('make_global_settings_ar.gyp') 106 test.run_gyp('make_global_settings_ar.gyp')
108 finally:
109 del os.environ['AR']
110 del os.environ['AR_host']
111 # Ninja generator resolves $AR in gyp phase. Make generator doesn't. 107 # Ninja generator resolves $AR in gyp phase. Make generator doesn't.
112 if test.format == 'ninja': 108 if test.format == 'ninja':
113 if sys.platform == 'win32': 109 if sys.platform == 'win32':
114 # TODO(yukawa): Make sure if this is an expected result or not. 110 # TODO(yukawa): Make sure if this is an expected result or not.
115 verify_ar_target(test, ar='lib.exe', rel_path=False) 111 verify_ar_target(test, ar='lib.exe', rel_path=False)
116 else: 112 else:
117 verify_ar_target(test, ar='my_ar_target2', rel_path=False) 113 verify_ar_target(test, ar='my_ar_target2', rel_path=False)
118 verify_ar_host(test, ar='my_ar_host2', rel_path=False) 114 verify_ar_host(test, ar='my_ar_host2', rel_path=False)
119 115
120 116
121 # Test 'AR' in 'make_global_settings' with $AR_host environment variable. 117 # Test 'AR' in 'make_global_settings' with $AR_host environment variable.
122 try: 118 with TestGyp.LocalEnv({'AR_host': 'my_ar_host3'}):
123 os.environ['AR_host'] = 'my_ar_host3'
124 test.run_gyp('make_global_settings_ar.gyp', 119 test.run_gyp('make_global_settings_ar.gyp',
125 '-Dcustom_ar_target=my_ar_target3') 120 '-Dcustom_ar_target=my_ar_target3')
126 finally:
127 del os.environ['AR_host']
128 # TODO(yukawa): Support 'AR' in Ninja generator 121 # TODO(yukawa): Support 'AR' in Ninja generator
129 if test.format == 'make': 122 if test.format == 'make':
130 verify_ar_target(test, ar='my_ar_target3', rel_path=True) 123 verify_ar_target(test, ar='my_ar_target3', rel_path=True)
131 verify_ar_host(test, ar='my_ar_host3', rel_path=False) 124 verify_ar_host(test, ar='my_ar_host3', rel_path=False)
132 125
133 126
134 test.pass_test() 127 test.pass_test()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698