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 """Runs all ChromeDriver end to end tests.""" | 6 """Runs all ChromeDriver end to end tests.""" |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
11 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 11 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
12 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) | 12 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) |
13 | 13 |
14 from common import chrome_paths | 14 from common import chrome_paths |
15 from common import util | 15 from common import util |
16 | 16 |
17 def _AppendEnvironmentPath(env_name, path): | |
18 if env_name in os.environ: | |
19 lib_path = os.environ[env_name] | |
20 if path not in lib_path: | |
21 os.environ[env_name] += os.pathsep + path | |
22 else: | |
23 os.environ[env_name] = path | |
24 | |
25 def _FindChromeBinary(path): | |
26 if util.IsLinux(): | |
27 exes = ['chrome'] | |
28 elif util.IsMac(): | |
29 exes = [ | |
30 'Google Chrome.app/Contents/MacOS/Google Chrome', | |
31 'Chromium.app/Contents/MacOS/Chromium' | |
32 ] | |
33 elif util.IsWindows(): | |
34 exes = ['chrome.exe'] | |
35 else: | |
36 exes = [] | |
37 for exe in exes: | |
38 binary = os.path.join(path, exe) | |
39 if os.path.exists(binary): | |
40 return binary | |
41 return None | |
17 | 42 |
18 def Main(): | 43 def Main(): |
19 print '@@@BUILD_STEP chromedriver2_tests@@@' | 44 print '@@@BUILD_STEP chromedriver2_tests@@@' |
20 chromedriver_map = { | 45 chromedriver_map = { |
21 'win': 'chromedriver2.dll', | 46 'win': 'chromedriver2.dll', |
22 'mac': 'chromedriver2.so', | 47 'mac': 'chromedriver2.so', |
23 'linux': 'libchromedriver2.so', | 48 'linux': 'libchromedriver2.so', |
24 } | 49 } |
25 chromedriver = chromedriver_map[util.GetPlatformName()] | 50 chromedriver = chromedriver_map[util.GetPlatformName()] |
26 build_dir = chrome_paths.GetBuildDir([chromedriver]) | 51 build_dir = chrome_paths.GetBuildDir([chromedriver]) |
27 cmd = [ | 52 cmd = [ |
28 sys.executable, | 53 sys.executable, |
29 os.path.join(_THIS_DIR, 'test.py'), | 54 os.path.join(_THIS_DIR, 'test.py'), |
30 os.path.join(build_dir, chromedriver), | 55 os.path.join(build_dir, chromedriver), |
31 ] | 56 ] |
57 # Set the built chrome binary | |
kkania
2012/12/04 01:30:25
'.' at end of comments
chrisgao (Use stgao instead)
2012/12/04 01:51:34
Done.
| |
58 chrome_binary = _FindChromeBinary(build_dir) | |
59 if chrome_binary is not None: | |
60 cmd.append(chrome_binary) | |
61 if util.IsLinux(): | |
62 # Set LD_LIBRARY_PATH to enable successful loading of shared object files, | |
63 # when chromedriver2.so is not a static build. | |
64 _AppendEnvironmentPath('LD_LIBRARY_PATH', os.path.join(build_dir, 'lib')) | |
65 elif util.IsMac(): | |
66 # In Mac, chromedriver2.so is a 32-bit build, so run with the 32-bit python. | |
67 os.environ['VERSIONER_PYTHON_PREFER_32_BIT'] = 'yes' | |
32 code = util.RunCommand(cmd) | 68 code = util.RunCommand(cmd) |
33 if code != 0: | 69 if code != 0: |
34 print '@@@STEP_FAILURE@@@' | 70 print '@@@STEP_FAILURE@@@' |
35 return code | 71 return code |
36 | 72 |
37 | 73 |
38 if __name__ == '__main__': | 74 if __name__ == '__main__': |
39 sys.exit(Main()) | 75 sys.exit(Main()) |
OLD | NEW |