OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """A library for cross-platform browser tests.""" | 5 """A library for cross-platform browser tests.""" |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 | 8 |
9 # Ensure Python >= 2.7. | 9 # Ensure Python >= 2.7. |
10 if sys.version_info < (2, 7): | 10 if sys.version_info < (2, 7): |
11 print >> sys.stderr, 'Need Python 2.7 or greater.' | 11 print >> sys.stderr, 'Need Python 2.7 or greater.' |
12 sys.exit(-1) | 12 sys.exit(-1) |
13 | 13 |
14 from telemetry.internal.util import global_hooks | 14 from telemetry.internal.util import global_hooks |
15 global_hooks.InstallHooks() | 15 global_hooks.InstallHooks() |
16 | 16 |
17 # Add depdendencies into our path. | 17 # Add depdendencies into our path. |
18 from telemetry.core import util | 18 from telemetry.core import util |
19 | 19 |
20 def _AddDirToPythonPath(*path_parts): | 20 def _AddDirToPythonPath(*path_parts): |
21 path = os.path.abspath(os.path.join(*path_parts)) | 21 path = os.path.abspath(os.path.join(*path_parts)) |
22 if os.path.isdir(path) and path not in sys.path: | 22 if os.path.isdir(path) and path not in sys.path: |
23 # Some callsite that use telemetry assumes that sys.path[0] is the directory | 23 # Some callsite that use telemetry assumes that sys.path[0] is the directory |
24 # containing the script, so we add these extra paths to right after it. | 24 # containing the script, so we add these extra paths to right after it. |
25 sys.path.insert(1, path) | 25 sys.path.insert(1, path) |
26 | 26 |
27 | 27 |
28 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'altgraph') | 28 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'altgraph') |
| 29 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'coverage') |
29 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'mock') | 30 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'mock') |
30 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'modulegraph') | 31 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'modulegraph') |
31 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'pexpect') | 32 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'pexpect') |
32 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'png') | 33 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'png') |
33 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'pyserial') | 34 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'pyserial') |
34 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'typ') | 35 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'typ') |
35 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'webpagereplay') | 36 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'webpagereplay') |
36 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'websocket-client') | 37 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'websocket-client') |
37 | 38 |
38 _AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') | 39 _AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') |
39 _AddDirToPythonPath(util.GetChromiumSrcDir(), | 40 _AddDirToPythonPath(util.GetChromiumSrcDir(), |
40 'third_party', 'catapult', 'tracing') | 41 'third_party', 'catapult', 'tracing') |
OLD | NEW |