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

Side by Side Diff: testing/test_env.py

Issue 2515643003: Flush stdout before shelling out. (Closed)
Patch Set: Created 4 years, 1 month 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
« 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 # 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
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())
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