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

Side by Side Diff: testing/test_env.py

Issue 10413055: Adjust Commands Paths for Result File on Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 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
« no previous file with comments | « no previous file | tools/isolate/run_test_from_archive.py » ('j') | 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 subprocess 9 import subprocess
10 import sys 10 import sys
11 11
12 # This is hardcoded to be src/ relative to this script. 12 # This is hardcoded to be src/ relative to this script.
13 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 13 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
14 14
15 15
16 def run_executable(cmd, env): 16 def run_executable(cmd, env):
17 """Runs an executable with: 17 """Runs an executable with:
18 - environment variable CR_SOURCE_ROOT set to the root directory. 18 - environment variable CR_SOURCE_ROOT set to the root directory.
19 - environment variable LANGUAGE to en_US.UTF-8. 19 - environment variable LANGUAGE to en_US.UTF-8.
20 - Reuses sys.executable automatically. 20 - Reuses sys.executable automatically.
21 """ 21 """
22 # Many tests assume a English interface... 22 # Many tests assume a English interface...
23 env['LANGUAGE'] = 'en_US.UTF-8' 23 env['LANGUAGE'] = 'en_US.UTF-8'
24 # Used by base/base_paths_linux.cc 24 # Used by base/base_paths_linux.cc
25 env['CR_SOURCE_ROOT'] = os.path.abspath(ROOT_DIR).encode('utf-8') 25 env['CR_SOURCE_ROOT'] = os.path.abspath(ROOT_DIR).encode('utf-8')
26 # Ensure paths are correctly separatored on windows.
M-A Ruel 2012/05/23 14:26:15 separated.
csharp 2012/05/23 14:29:47 Done.
27 cmd[0] = cmd[0].replace('/', os.path.sep)
26 if cmd[0].endswith('.py'): 28 if cmd[0].endswith('.py'):
27 cmd.insert(0, sys.executable) 29 cmd.insert(0, sys.executable)
28 try: 30 try:
29 return subprocess.call(cmd, env=env) 31 return subprocess.call(cmd, env=env)
30 except OSError: 32 except OSError:
31 print >> sys.stderr, 'Failed to start %s' % cmd 33 print >> sys.stderr, 'Failed to start %s' % cmd
32 raise 34 raise
33 35
34 36
35 def main(): 37 def main():
36 return run_executable(sys.argv[1:], os.environ.copy()) 38 return run_executable(sys.argv[1:], os.environ.copy())
37 39
38 40
39 if __name__ == "__main__": 41 if __name__ == "__main__":
40 sys.exit(main()) 42 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/isolate/run_test_from_archive.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698