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

Side by Side Diff: testing/test_env.py

Issue 17702004: Only remove CHROME_SANDBOX_ENV from env if it is present. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 # 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
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
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())
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