| 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 30 matching lines...) Expand all Loading... |
| 41 if verbose: | 41 if verbose: |
| 42 print 'Enabling sandbox. Setting environment variable:' | 42 print 'Enabling sandbox. Setting environment variable:' |
| 43 print ' %s="%s"' % (CHROME_SANDBOX_ENV, chrome_sandbox_path) | 43 print ' %s="%s"' % (CHROME_SANDBOX_ENV, chrome_sandbox_path) |
| 44 env[CHROME_SANDBOX_ENV] = chrome_sandbox_path | 44 env[CHROME_SANDBOX_ENV] = chrome_sandbox_path |
| 45 else: | 45 else: |
| 46 if verbose: | 46 if verbose: |
| 47 print 'Sandbox not properly installed. Unsetting:' | 47 print 'Sandbox not properly installed. Unsetting:' |
| 48 print ' %s' % CHROME_SANDBOX_ENV | 48 print ' %s' % CHROME_SANDBOX_ENV |
| 49 # The variable should be removed from the environment, making | 49 # The variable should be removed from the environment, making |
| 50 # the variable empty silently disables the sandbox. | 50 # the variable empty silently disables the sandbox. |
| 51 env.pop(CHROME_SANDBOX_ENV) | 51 if env.get(CHROME_SANDBOX_ENV): |
| 52 env.pop(CHROME_SANDBOX_ENV) |
| 52 | 53 |
| 53 | 54 |
| 54 def fix_python_path(cmd): | 55 def fix_python_path(cmd): |
| 55 """Returns the fixed command line to call the right python executable.""" | 56 """Returns the fixed command line to call the right python executable.""" |
| 56 out = cmd[:] | 57 out = cmd[:] |
| 57 if out[0] == 'python': | 58 if out[0] == 'python': |
| 58 out[0] = sys.executable | 59 out[0] = sys.executable |
| 59 elif out[0].endswith('.py'): | 60 elif out[0].endswith('.py'): |
| 60 out.insert(0, sys.executable) | 61 out.insert(0, sys.executable) |
| 61 return out | 62 return out |
| (...skipping 21 matching lines...) Expand all Loading... |
| 83 print >> sys.stderr, 'Failed to start %s' % cmd | 84 print >> sys.stderr, 'Failed to start %s' % cmd |
| 84 raise | 85 raise |
| 85 | 86 |
| 86 | 87 |
| 87 def main(): | 88 def main(): |
| 88 return run_executable(sys.argv[1:], os.environ.copy()) | 89 return run_executable(sys.argv[1:], os.environ.copy()) |
| 89 | 90 |
| 90 | 91 |
| 91 if __name__ == '__main__': | 92 if __name__ == '__main__': |
| 92 sys.exit(main()) | 93 sys.exit(main()) |
| OLD | NEW |