OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Sets environment variables needed to run a chromium unit test.""" | 6 """Sets environment variables needed to run a chromium unit test.""" |
7 | 7 |
8 import os | 8 import os |
9 import stat | 9 import stat |
10 import subprocess | 10 import subprocess |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 # Ensure paths are correctly separated on windows. | 205 # Ensure paths are correctly separated on windows. |
206 cmd[0] = cmd[0].replace('/', os.path.sep) | 206 cmd[0] = cmd[0].replace('/', os.path.sep) |
207 cmd = fix_python_path(cmd) | 207 cmd = fix_python_path(cmd) |
208 | 208 |
209 print('Additional test environment:\n%s\n' | 209 print('Additional test environment:\n%s\n' |
210 'Command: %s\n' % ( | 210 'Command: %s\n' % ( |
211 '\n'.join(' %s=%s' % | 211 '\n'.join(' %s=%s' % |
212 (k, v) for k, v in sorted(extra_env.iteritems())), | 212 (k, v) for k, v in sorted(extra_env.iteritems())), |
213 ' '.join(cmd))) | 213 ' '.join(cmd))) |
| 214 sys.stdout.flush() |
214 env.update(extra_env or {}) | 215 env.update(extra_env or {}) |
215 try: | 216 try: |
216 # See above comment regarding offline symbolization. | 217 # See above comment regarding offline symbolization. |
217 if use_symbolization_script: | 218 if use_symbolization_script: |
218 # Need to pipe to the symbolizer script. | 219 # Need to pipe to the symbolizer script. |
219 p1 = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, | 220 p1 = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, |
220 stderr=sys.stdout) | 221 stderr=sys.stdout) |
221 p2 = subprocess.Popen( | 222 p2 = subprocess.Popen( |
222 get_sanitizer_symbolize_command(executable_path=cmd[0]), | 223 get_sanitizer_symbolize_command(executable_path=cmd[0]), |
223 env=env, stdin=p1.stdout) | 224 env=env, stdin=p1.stdout) |
224 p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. | 225 p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. |
225 p1.wait() | 226 p1.wait() |
226 p2.wait() | 227 p2.wait() |
227 # Also feed the out-of-band JSON output to the symbolizer script. | 228 # Also feed the out-of-band JSON output to the symbolizer script. |
228 symbolize_snippets_in_json(cmd, env) | 229 symbolize_snippets_in_json(cmd, env) |
229 return p1.returncode | 230 return p1.returncode |
230 else: | 231 else: |
231 return subprocess.call(cmd, env=env) | 232 return subprocess.call(cmd, env=env) |
232 except OSError: | 233 except OSError: |
233 print >> sys.stderr, 'Failed to start %s' % cmd | 234 print >> sys.stderr, 'Failed to start %s' % cmd |
234 raise | 235 raise |
235 | 236 |
236 | 237 |
237 def main(): | 238 def main(): |
238 return run_executable(sys.argv[1:], os.environ.copy()) | 239 return run_executable(sys.argv[1:], os.environ.copy()) |
239 | 240 |
240 | 241 |
241 if __name__ == '__main__': | 242 if __name__ == '__main__': |
242 sys.exit(main()) | 243 sys.exit(main()) |
OLD | NEW |