OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Common paths for pyauto tests.""" | 6 """Common paths for pyauto tests.""" |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
11 | 11 |
12 def GetSourceDir(): | 12 def GetSourceDir(): |
13 """Returns src/ directory.""" | 13 """Returns src/ directory.""" |
14 script_dir = os.path.abspath(os.path.dirname(__file__)) | 14 script_dir = os.path.abspath(os.path.dirname(__file__)) |
15 return os.path.join(script_dir, os.pardir, os.pardir, os.pardir) | 15 return os.path.join(script_dir, os.pardir, os.pardir, os.pardir) |
16 | 16 |
17 | 17 |
18 def GetThirdPartyDir(): | 18 def GetThirdPartyDir(): |
19 """Returns src/third_party directory.""" | 19 """Returns src/third_party directory.""" |
20 return os.path.join(GetSourceDir(), 'third_party') | 20 return os.path.join(GetSourceDir(), 'third_party') |
21 | 21 |
22 | 22 |
23 def GetBuildDirs(): | 23 def GetBuildDirs(): |
24 """Returns list of possible build directories.""" | 24 """Returns list of possible build directories.""" |
25 build_dirs = { | 25 # List of dirs that can contain a Debug/Release build. |
26 'linux2': [ os.path.join('out', 'Debug'), | 26 outer_dirs = { |
27 os.path.join('sconsbuild', 'Debug'), | 27 'linux2': ['out', 'sconsbuild'], |
28 os.path.join('out', 'Release'), | 28 'linux3': ['out', 'sconsbuild'], |
29 os.path.join('sconsbuild', 'Release')], | 29 'darwin': ['xcodebuild', 'out'], |
Nirnimesh
2011/08/30 16:49:11
reverse the order? 'out', 'xcodebuild'
| |
30 'linux3': [ os.path.join('out', 'Debug'), | 30 'win32': ['chrome', 'build'], |
31 os.path.join('sconsbuild', 'Debug'), | 31 'cygwin': ['chrome'], |
32 os.path.join('out', 'Release'), | 32 }.get(sys.platform, []) |
33 os.path.join('sconsbuild', 'Release')], | |
34 'darwin': [ os.path.join('xcodebuild', 'Debug'), | |
35 os.path.join('xcodebuild', 'Release')], | |
36 'win32': [ os.path.join('chrome', 'Debug'), | |
37 os.path.join('build', 'Debug'), | |
38 os.path.join('chrome', 'Release'), | |
39 os.path.join('build', 'Release')], | |
40 'cygwin': [ os.path.join('chrome', 'Debug'), | |
41 os.path.join('chrome', 'Release')], | |
42 } | |
43 src_dir = GetSourceDir() | 33 src_dir = GetSourceDir() |
44 return map(lambda dir: os.path.join(src_dir, dir), | 34 build_dirs = [] |
45 build_dirs.get(sys.platform, [])) | 35 for dir in outer_dirs: |
36 build_dirs += [os.path.join(src_dir, dir, 'Debug')] | |
37 build_dirs += [os.path.join(src_dir, dir, 'Release')] | |
38 return build_dirs | |
46 | 39 |
47 | 40 |
48 def GetChromeDriverExe(): | 41 def GetChromeDriverExe(): |
49 """Returns path to ChromeDriver executable, or None if cannot be found.""" | 42 """Returns path to ChromeDriver executable, or None if cannot be found.""" |
50 exe_name = 'chromedriver' | 43 exe_name = 'chromedriver' |
51 if sys.platform == 'win32': | 44 if sys.platform == 'win32': |
52 exe_name += '.exe' | 45 exe_name += '.exe' |
53 for dir in GetBuildDirs(): | 46 for dir in GetBuildDirs(): |
54 exe = os.path.join(dir, exe_name) | 47 exe = os.path.join(dir, exe_name) |
55 if os.path.exists(exe): | 48 if os.path.exists(exe): |
56 return exe | 49 return exe |
57 return None | 50 return None |
OLD | NEW |