diff options
22 files changed, 68 insertions, 66 deletions
diff --git a/tools/telemetry/PRESUBMIT.py b/tools/telemetry/PRESUBMIT.py index da4388d..5961c94 100644 --- a/tools/telemetry/PRESUBMIT.py +++ b/tools/telemetry/PRESUBMIT.py @@ -1,8 +1,6 @@ # Copyright 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import os -import sys def _CommonChecks(input_api, output_api): @@ -11,42 +9,45 @@ def _CommonChecks(input_api, output_api): # TODO(nduca): This should call update_docs.IsUpdateDocsNeeded(). # Disabled due to crbug.com/255326. if False: - update_docs_path = os.path.join( + update_docs_path = input_api.os_path.join( input_api.PresubmitLocalPath(), 'update_docs') - assert os.path.exists(update_docs_path) + assert input_api.os_path.exists(update_docs_path) results.append(output_api.PresubmitError( 'Docs are stale. Please run:\n' + - '$ %s' % os.path.abspath(update_docs_path))) + '$ %s' % input_api.os_path.abspath(update_docs_path))) pylint_checks = input_api.canned_checks.GetPylint( - input_api, output_api, black_list=[], pylintrc='pylintrc') + input_api, output_api, extra_paths_list=_GetPathsToPrepend(input_api), + pylintrc='pylintrc') results.extend(input_api.RunTests(pylint_checks)) return results -def GetPathsToPrepend(input_api): - return [input_api.PresubmitLocalPath(), - os.path.join(input_api.PresubmitLocalPath(), 'third_party', 'typ')] -def RunWithPrependedPath(prepended_path, fn, *args): - old_path = sys.path +def _GetPathsToPrepend(input_api): + telemetry_dir = input_api.PresubmitLocalPath() + chromium_src_dir = input_api.os_path.join(telemetry_dir, '..', '..') + return [ + telemetry_dir, + input_api.os_path.join(telemetry_dir, 'third_party', 'mock'), + input_api.os_path.join(telemetry_dir, 'third_party', 'typ'), + input_api.os_path.join(telemetry_dir, 'third_party', 'websocket-client'), + + input_api.os_path.join(chromium_src_dir, 'build', 'android'), + input_api.os_path.join( + chromium_src_dir, 'third_party', 'py_trace_event', 'src'), + input_api.os_path.join(chromium_src_dir, 'third_party', 'trace-viewer'), + input_api.os_path.join(chromium_src_dir, 'third_party', 'webpagereplay'), + ] - try: - sys.path = prepended_path + old_path - return fn(*args) - finally: - sys.path = old_path def CheckChangeOnUpload(input_api, output_api): - def go(): - results = [] - results.extend(_CommonChecks(input_api, output_api)) - return results - return RunWithPrependedPath(GetPathsToPrepend(input_api), go) + results = [] + results.extend(_CommonChecks(input_api, output_api)) + return results + def CheckChangeOnCommit(input_api, output_api): - def go(): - results = [] - results.extend(_CommonChecks(input_api, output_api)) - return results - return RunWithPrependedPath(GetPathsToPrepend(input_api), go) + results = [] + results.extend(_CommonChecks(input_api, output_api)) + return results diff --git a/tools/telemetry/telemetry/core/platform/android_device.py b/tools/telemetry/telemetry/core/platform/android_device.py index 105700f..2917ef0 100644 --- a/tools/telemetry/telemetry/core/platform/android_device.py +++ b/tools/telemetry/telemetry/core/platform/android_device.py @@ -11,9 +11,9 @@ from telemetry.core.platform.profiler import monsoon from telemetry.core import util util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') -from pylib import constants # pylint: disable=import-error -from pylib.device import device_errors # pylint: disable=import-error -from pylib.device import device_utils # pylint: disable=import-error +from pylib import constants +from pylib.device import device_errors +from pylib.device import device_utils class AndroidDevice(device.Device): diff --git a/tools/telemetry/telemetry/core/platform/android_device_unittest.py b/tools/telemetry/telemetry/core/platform/android_device_unittest.py index 9cddabf..b0e3429 100644 --- a/tools/telemetry/telemetry/core/platform/android_device_unittest.py +++ b/tools/telemetry/telemetry/core/platform/android_device_unittest.py @@ -10,10 +10,10 @@ from telemetry.internal.browser import browser_options from telemetry.testing import system_stub util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') -from pylib.device import device_utils # pylint: disable=import-error +from pylib.device import device_utils util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint: disable=import-error +import mock class _BaseAndroidDeviceTest(unittest.TestCase): diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend.py b/tools/telemetry/telemetry/core/platform/android_platform_backend.py index 8895378..28ebb6d 100644 --- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py +++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py @@ -32,23 +32,23 @@ from telemetry.internal.util import external_modules psutil = external_modules.ImportOptionalModule('psutil') util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'third_party', 'webpagereplay') -import adb_install_cert # pylint: disable=import-error -import certutils # pylint: disable=import-error -import platformsettings # pylint: disable=import-error +import adb_install_cert +import certutils +import platformsettings # Get build/android scripts into our path. util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') -from pylib import constants # pylint: disable=import-error -from pylib import screenshot # pylint: disable=import-error -from pylib.device import battery_utils # pylint: disable=import-error -from pylib.device import device_errors # pylint: disable=import-error -from pylib.device import device_utils # pylint: disable=import-error -from pylib.perf import cache_control # pylint: disable=import-error -from pylib.perf import perf_control # pylint: disable=import-error -from pylib.perf import thermal_throttle # pylint: disable=import-error +from pylib import constants +from pylib import screenshot +from pylib.device import battery_utils +from pylib.device import device_errors +from pylib.device import device_utils +from pylib.perf import cache_control +from pylib.perf import perf_control +from pylib.perf import thermal_throttle try: - from pylib.perf import surface_stats_collector # pylint: disable=import-error + from pylib.perf import surface_stats_collector except Exception: surface_stats_collector = None diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py b/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py index 7af3c84..3c6cc89 100644 --- a/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py +++ b/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py @@ -12,10 +12,10 @@ from telemetry.testing import options_for_unittests from telemetry.testing import system_stub util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint: disable=import-error +import mock util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') -from pylib.device import battery_utils # pylint: disable=import-error -from pylib.device import device_utils # pylint: disable=import-error +from pylib.device import battery_utils +from pylib.device import device_utils class AndroidPlatformBackendTest(unittest.TestCase): def setUp(self): diff --git a/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py b/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py index 66c25bf..eaa36f4 100644 --- a/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py +++ b/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py @@ -10,7 +10,7 @@ from telemetry.core.platform import linux_based_platform_backend from telemetry.core import util util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint: disable=import-error +import mock class TestBackend(linux_based_platform_backend.LinuxBasedPlatformBackend): diff --git a/tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py b/tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py index 8e714e3..1059285 100644 --- a/tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py +++ b/tools/telemetry/telemetry/core/platform/linux_platform_backend_unittest.py @@ -10,7 +10,7 @@ from telemetry.core import util from telemetry import decorators util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint:disable=import-error +import mock class LinuxPlatformBackendTest(unittest.TestCase): diff --git a/tools/telemetry/telemetry/decorators_unittest.py b/tools/telemetry/telemetry/decorators_unittest.py index d76f83d..7aecc84 100644 --- a/tools/telemetry/telemetry/decorators_unittest.py +++ b/tools/telemetry/telemetry/decorators_unittest.py @@ -8,7 +8,7 @@ from telemetry import decorators from telemetry.core import util util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint:disable=import-error +import mock class FakePlatform(object): diff --git a/tools/telemetry/telemetry/internal/actions/action_runner_unittest.py b/tools/telemetry/telemetry/internal/actions/action_runner_unittest.py index e4649b5..5962e90 100644 --- a/tools/telemetry/telemetry/internal/actions/action_runner_unittest.py +++ b/tools/telemetry/telemetry/internal/actions/action_runner_unittest.py @@ -15,7 +15,7 @@ from telemetry.timeline import tracing_options from telemetry.web_perf import timeline_interaction_record as tir_module util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint:disable=import-error +import mock class ActionRunnerInteractionTest(tab_test_case.TabTestCase): diff --git a/tools/telemetry/telemetry/internal/app/android_app_unittest.py b/tools/telemetry/telemetry/internal/app/android_app_unittest.py index ab8ad36..db09330 100644 --- a/tools/telemetry/telemetry/internal/app/android_app_unittest.py +++ b/tools/telemetry/telemetry/internal/app/android_app_unittest.py @@ -14,7 +14,7 @@ from telemetry.internal.backends import android_app_backend from telemetry.testing import options_for_unittests util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') -from pylib.device import intent # pylint: disable=import-error +from pylib.device import intent class AndroidAppTest(unittest.TestCase): diff --git a/tools/telemetry/telemetry/internal/app/android_process.py b/tools/telemetry/telemetry/internal/app/android_process.py index 03829e7..959719b 100644 --- a/tools/telemetry/telemetry/internal/app/android_process.py +++ b/tools/telemetry/telemetry/internal/app/android_process.py @@ -8,7 +8,7 @@ from telemetry.internal.browser import web_contents util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') try: - from pylib import ports # pylint: disable=import-error + from pylib import ports except ImportError: ports = None diff --git a/tools/telemetry/telemetry/internal/backends/android_command_line_backend_unittest.py b/tools/telemetry/telemetry/internal/backends/android_command_line_backend_unittest.py index a19a868..5d6138f 100644 --- a/tools/telemetry/telemetry/internal/backends/android_command_line_backend_unittest.py +++ b/tools/telemetry/telemetry/internal/backends/android_command_line_backend_unittest.py @@ -11,7 +11,7 @@ from telemetry.internal.backends import android_command_line_backend from telemetry.testing import options_for_unittests util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') -from pylib.device import device_utils # pylint: disable=import-error +from pylib.device import device_utils class _MockBackendSettings(object): diff --git a/tools/telemetry/telemetry/internal/backends/chrome/android_browser_backend.py b/tools/telemetry/telemetry/internal/backends/chrome/android_browser_backend.py index 698b300..d61d95f 100644 --- a/tools/telemetry/telemetry/internal/backends/chrome/android_browser_backend.py +++ b/tools/telemetry/telemetry/internal/backends/chrome/android_browser_backend.py @@ -16,10 +16,10 @@ from telemetry.internal import forwarders util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') try: - from pylib import ports # pylint: disable=import-error + from pylib import ports except ImportError: ports = None -from pylib.device import intent # pylint: disable=import-error +from pylib.device import intent class AndroidBrowserBackend(chrome_browser_backend.ChromeBrowserBackend): diff --git a/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder.py b/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder.py index 245ba59..a36acaf 100644 --- a/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder.py +++ b/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder.py @@ -18,7 +18,7 @@ from telemetry.internal.browser import browser from telemetry.internal.browser import possible_browser util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') -from pylib.utils import apk_helper # pylint: disable=import-error +from pylib.utils import apk_helper CHROME_PACKAGE_NAMES = { diff --git a/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder_unittest.py b/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder_unittest.py index 7e04024..9b7dbe9 100644 --- a/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder_unittest.py +++ b/tools/telemetry/telemetry/internal/backends/chrome/android_browser_finder_unittest.py @@ -10,7 +10,7 @@ from telemetry.internal.browser import browser_options from telemetry.testing import system_stub util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint: disable=import-error +import mock class FakeAndroidPlatform(object): diff --git a/tools/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend_unittest.py b/tools/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend_unittest.py index 073c118..41da978 100644 --- a/tools/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend_unittest.py +++ b/tools/telemetry/telemetry/internal/backends/chrome_inspector/tracing_backend_unittest.py @@ -14,7 +14,7 @@ from telemetry.timeline import tracing_category_filter from telemetry.timeline import tracing_options util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint:disable=import-error +import mock class FakeInspectorWebsocket(object): diff --git a/tools/telemetry/telemetry/internal/backends/chrome_inspector/websocket.py b/tools/telemetry/telemetry/internal/backends/chrome_inspector/websocket.py index f8682fd..9da12e9 100644 --- a/tools/telemetry/telemetry/internal/backends/chrome_inspector/websocket.py +++ b/tools/telemetry/telemetry/internal/backends/chrome_inspector/websocket.py @@ -9,7 +9,7 @@ from telemetry.core import util util.AddDirToPythonPath( util.GetTelemetryDir(), 'third_party', 'websocket-client') -# pylint: disable=import-error, unused-import +# pylint: disable=unused-import from websocket import create_connection as _create_connection from websocket import WebSocketException from websocket import WebSocketTimeoutException diff --git a/tools/telemetry/telemetry/internal/forwarders/android_forwarder.py b/tools/telemetry/telemetry/internal/forwarders/android_forwarder.py index 2a599e4..9fcc743 100644 --- a/tools/telemetry/telemetry/internal/forwarders/android_forwarder.py +++ b/tools/telemetry/telemetry/internal/forwarders/android_forwarder.py @@ -17,12 +17,12 @@ from telemetry.internal import forwarders util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android') try: - from pylib import forwarder # pylint: disable=import-error + from pylib import forwarder except ImportError: forwarder = None -from pylib.device import device_errors # pylint: disable=import-error -from pylib.device import device_utils # pylint: disable=import-error +from pylib.device import device_errors +from pylib.device import device_utils class AndroidForwarderFactory(forwarders.ForwarderFactory): diff --git a/tools/telemetry/telemetry/internal/util/py_trace.py b/tools/telemetry/telemetry/internal/util/py_trace.py index 54d2afc..01affc8 100644 --- a/tools/telemetry/telemetry/internal/util/py_trace.py +++ b/tools/telemetry/telemetry/internal/util/py_trace.py @@ -7,4 +7,5 @@ from telemetry.core import util util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'third_party', 'py_trace_event', 'src') -from trace_event import * # pylint: disable=import-error, wildcard-import +# pylint: disable=wildcard-import, unused-wildcard-import +from trace_event import * diff --git a/tools/telemetry/telemetry/timeline/memory_dump_event_unittest.py b/tools/telemetry/telemetry/timeline/memory_dump_event_unittest.py index efa48bf..852d8bd 100644 --- a/tools/telemetry/telemetry/timeline/memory_dump_event_unittest.py +++ b/tools/telemetry/telemetry/timeline/memory_dump_event_unittest.py @@ -8,7 +8,7 @@ from telemetry.core import util from telemetry.timeline import memory_dump_event util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint: disable=import-error +import mock def TestProcessDumpEvent(dump_id='123456ABCDEF', pid=1234, start=0, mmaps=None, diff --git a/tools/telemetry/telemetry/value/trace.py b/tools/telemetry/telemetry/value/trace.py index 3ea2b5d..b8e068b 100644 --- a/tools/telemetry/telemetry/value/trace.py +++ b/tools/telemetry/telemetry/value/trace.py @@ -21,7 +21,7 @@ from telemetry import value as value_module util.AddDirToPythonPath( util.GetChromiumSrcDir(), 'third_party', 'trace-viewer') -from tracing.build import trace2html # pylint:disable=import-error +from tracing.build import trace2html class TraceValue(value_module.Value): def __init__(self, page, trace_data, important=False, description=None): diff --git a/tools/telemetry/telemetry/web_perf/metrics/memory_timeline_unittest.py b/tools/telemetry/telemetry/web_perf/metrics/memory_timeline_unittest.py index 9135472..01c54a1 100644 --- a/tools/telemetry/telemetry/web_perf/metrics/memory_timeline_unittest.py +++ b/tools/telemetry/telemetry/web_perf/metrics/memory_timeline_unittest.py @@ -13,7 +13,7 @@ from telemetry.web_perf.metrics import memory_timeline from telemetry.web_perf import timeline_interaction_record util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') -import mock # pylint: disable=import-error +import mock def MockProcessDumpEvent(dump_id, name, start, memory_usage): |