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 in lib_path: | |
kkania
2012/12/03 20:34:07
if path not in lib_path:
os.environ[env_name] +=
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
21 pass | |
22 else: | |
23 os.environ[env_name] += os.pathsep + path | |
24 else: | |
25 os.environ[env_name] = path | |
26 | |
27 def _FindChromeBinary(loc): | |
kkania
2012/12/03 20:34:07
loc is not a very common abbreviation for location
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
28 if util.IsLinux(): | |
29 exexutables = [ | |
kkania
2012/12/03 20:34:07
should be executables, not exexutables. You can ju
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
30 "google-chrome", | |
kkania
2012/12/03 20:34:07
use ' instead of " for python
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
31 "chrome", | |
kkania
2012/12/03 20:34:07
this is the only one you need
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
32 "chromium", | |
33 "chromium-browser" | |
34 ] | |
35 elif util.IsMac(): | |
36 exexutables = [ | |
37 "Google Chrome.app/Contents/MacOS/Google Chrome", | |
38 "Chromium.app/Contents/MacOS/Chromium" | |
39 ] | |
40 elif util.IsWindows(): | |
41 exexutables = [ | |
42 "Google\\Chrome\\Application\\chrome.exe", | |
kkania
2012/12/03 20:34:07
executables = ['chrome.exe']
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
43 "Chromium\\Application\\chrome.exe" | |
44 ] | |
45 else: | |
46 exexutables = [] | |
47 for exe in exexutables: | |
48 binary = os.path.join(loc, exe) | |
49 if os.path.exists(binary): | |
50 return binary | |
51 return "" | |
17 | 52 |
18 def Main(): | 53 def Main(): |
19 print '@@@BUILD_STEP chromedriver2_tests@@@' | 54 print '@@@BUILD_STEP chromedriver2_tests@@@' |
20 chromedriver_map = { | 55 chromedriver_map = { |
21 'win': 'chromedriver2.dll', | 56 'win': 'chromedriver2.dll', |
22 'mac': 'chromedriver2.so', | 57 'mac': 'chromedriver2.so', |
23 'linux': 'libchromedriver2.so', | 58 'linux': 'libchromedriver2.so', |
24 } | 59 } |
25 chromedriver = chromedriver_map[util.GetPlatformName()] | 60 chromedriver = chromedriver_map[util.GetPlatformName()] |
26 build_dir = chrome_paths.GetBuildDir([chromedriver]) | 61 build_dir = chrome_paths.GetBuildDir([chromedriver]) |
27 cmd = [ | 62 cmd = [ |
28 sys.executable, | 63 sys.executable, |
29 os.path.join(_THIS_DIR, 'test.py'), | 64 os.path.join(_THIS_DIR, 'test.py'), |
30 os.path.join(build_dir, chromedriver), | 65 os.path.join(build_dir, chromedriver), |
66 _FindChromeBinary(build_dir), | |
kkania
2012/12/03 20:34:07
i think we should also support, if the user hasn't
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Set the path to chrome only when it is built.
When
| |
31 ] | 67 ] |
68 if util.IsLinux(): | |
69 _AppendEnvironmentPath('LD_LIBRARY_PATH', os.path.join(build_dir, 'lib')) | |
kkania
2012/12/03 20:34:07
how about short comment here why this is needed
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
70 elif util.IsMac(): | |
71 os.environ['VERSIONER_PYTHON_PREFER_32_BIT'] = 'yes' | |
kkania
2012/12/03 20:34:07
how about short comment here why this is needed
chrisgao (Use stgao instead)
2012/12/04 00:13:59
Done.
| |
32 code = util.RunCommand(cmd) | 72 code = util.RunCommand(cmd) |
33 if code != 0: | 73 if code != 0: |
34 print '@@@STEP_FAILURE@@@' | 74 print '@@@STEP_FAILURE@@@' |
35 return code | 75 return code |
36 | 76 |
37 | 77 |
38 if __name__ == '__main__': | 78 if __name__ == '__main__': |
39 sys.exit(Main()) | 79 sys.exit(Main()) |
OLD | NEW |