| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 json_path = get_json_path(cmd) | 149 json_path = get_json_path(cmd) |
| 150 if json_path is None: | 150 if json_path is None: |
| 151 return | 151 return |
| 152 | 152 |
| 153 try: | 153 try: |
| 154 symbolize_command = get_sanitizer_symbolize_command( | 154 symbolize_command = get_sanitizer_symbolize_command( |
| 155 json_path=json_path, executable_path=cmd[0]) | 155 json_path=json_path, executable_path=cmd[0]) |
| 156 p = subprocess.Popen(symbolize_command, stderr=subprocess.PIPE, env=env) | 156 p = subprocess.Popen(symbolize_command, stderr=subprocess.PIPE, env=env) |
| 157 (_, stderr) = p.communicate() | 157 (_, stderr) = p.communicate() |
| 158 except OSError as e: | 158 except OSError as e: |
| 159 print 'Exception while symbolizing snippets: %s' % e | 159 print >> sys.stderr, 'Exception while symbolizing snippets: %s' % e |
| 160 raise |
| 160 | 161 |
| 161 if p.returncode != 0: | 162 if p.returncode != 0: |
| 162 print "Error: failed to symbolize snippets in JSON:\n" | 163 print >> sys.stderr, "Error: failed to symbolize snippets in JSON:\n" |
| 163 print stderr | 164 print >> sys.stderr, stderr |
| 165 raise subprocess.CalledProcessError(p.returncode, symbolize_command) |
| 164 | 166 |
| 165 | 167 |
| 166 def run_executable(cmd, env): | 168 def run_executable(cmd, env): |
| 167 """Runs an executable with: | 169 """Runs an executable with: |
| 168 - environment variable CR_SOURCE_ROOT set to the root directory. | 170 - environment variable CR_SOURCE_ROOT set to the root directory. |
| 169 - environment variable LANGUAGE to en_US.UTF-8. | 171 - environment variable LANGUAGE to en_US.UTF-8. |
| 170 - environment variable CHROME_DEVEL_SANDBOX set | 172 - environment variable CHROME_DEVEL_SANDBOX set |
| 171 - Reuses sys.executable automatically. | 173 - Reuses sys.executable automatically. |
| 172 """ | 174 """ |
| 173 extra_env = {} | 175 extra_env = {} |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 print >> sys.stderr, 'Failed to start %s' % cmd | 233 print >> sys.stderr, 'Failed to start %s' % cmd |
| 232 raise | 234 raise |
| 233 | 235 |
| 234 | 236 |
| 235 def main(): | 237 def main(): |
| 236 return run_executable(sys.argv[1:], os.environ.copy()) | 238 return run_executable(sys.argv[1:], os.environ.copy()) |
| 237 | 239 |
| 238 | 240 |
| 239 if __name__ == '__main__': | 241 if __name__ == '__main__': |
| 240 sys.exit(main()) | 242 sys.exit(main()) |
| OLD | NEW |