Commit 5ad8167a authored by eakuefner's avatar eakuefner Committed by Commit bot

[Telemetry] Migrate find_dependencies internals to tools/perf

Now that tools/perf/find_dependencies is the only find_dependencies, this CL
moves all the related under-the-hood code to tools/perf/core. It also moves the
davclient dependency out of tools/telemetry, since find_dependencies is the
only user of it.

BUG=528331
TEST=tools/perf/find_dependencies

Review URL: https://codereview.chromium.org/1467143006

Cr-Commit-Position: refs/heads/master@{#361256}
parent 6fbb4139
......@@ -25,6 +25,7 @@ import urlparse
davclient = None
# TODO(eakuefner): Switch this link to tools/perf version after verifying.
# Link to file containing the 'davclient' WebDAV client library.
_DAVCLIENT_URL = ('https://src.chromium.org/chrome/trunk/src/tools/'
'telemetry/third_party/davclient/davclient.py')
......
......@@ -12,13 +12,14 @@ import zipfile
from telemetry import benchmark
from telemetry.core import discover
from telemetry.internal.util import bootstrap
from telemetry.internal.util import command_line
from telemetry.internal.util import path
from telemetry.internal.util import path_set
from modulegraph import modulegraph
from modulegraph import modulegraph # pylint: disable=import-error
from core import bootstrap
from core import path_util
DEPS_FILE = 'bootstrap_deps'
......@@ -29,7 +30,7 @@ def FindBootstrapDependencies(base_dir):
return []
deps_paths = bootstrap.ListAllDepsPaths(deps_file)
return set(os.path.realpath(os.path.join(
path.GetChromiumSrcDir(), '..', deps_path))
path_util.GetChromiumSrcDir(), '..', deps_path))
for deps_path in deps_paths)
......@@ -64,7 +65,7 @@ def FindPythonDependencies(module_path):
# This check is done after the logging/printing above to make sure that
# we also print out the dependency edges that include python packages
# that are not in chromium.
if not path.IsSubpath(module_path, path.GetChromiumSrcDir()):
if not path.IsSubpath(module_path, path_util.GetChromiumSrcDir()):
continue
yield module_path
......@@ -149,9 +150,10 @@ def FindDependencies(target_paths, options):
# and all its dependencies. If the user doesn't pass any arguments, we just
# have Telemetry.
dependencies |= FindPythonDependencies(os.path.realpath(
os.path.join(path.GetTelemetryDir(), 'telemetry', 'benchmark_runner.py')))
os.path.join(path_util.GetTelemetryDir(),
'telemetry', 'benchmark_runner.py')))
dependencies |= FindPythonDependencies(os.path.realpath(
os.path.join(path.GetTelemetryDir(),
os.path.join(path_util.GetTelemetryDir(),
'telemetry', 'testing', 'run_tests.py')))
# Add dependencies.
......@@ -171,7 +173,7 @@ def FindDependencies(target_paths, options):
def ZipDependencies(target_paths, dependencies, options):
base_dir = os.path.dirname(os.path.realpath(path.GetChromiumSrcDir()))
base_dir = os.path.dirname(os.path.realpath(path_util.GetChromiumSrcDir()))
with zipfile.ZipFile(options.zip, 'w', zipfile.ZIP_DEFLATED) as zip_file:
# Add dependencies to archive.
......
......@@ -6,7 +6,8 @@ import os
import unittest
from telemetry.core import util
from telemetry.internal.util import find_dependencies
from core import find_dependencies
class FindDependenciesTest(unittest.TestCase):
......
......@@ -2,18 +2,22 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import json
# TODO(eakuefner): Remove this test once Telemetry lives in Catapult.
import os
import platform
import sys
import unittest
from telemetry.internal.util import find_dependencies
from telemetry.internal.util import path
from core import find_dependencies
from core import path_util
_TELEMETRY_DEPS_PATH = os.path.join(
path.GetTelemetryDir(), 'telemetry', 'TELEMETRY_DEPS')
_TELEMETRY_DEPS = [
'build/android/devil/',
'build/android/pylib/',
'third_party/catapult/',
'tools/telemetry/']
def _GetCurrentTelemetryDependencies():
......@@ -25,20 +29,13 @@ def _GetCurrentTelemetryDependencies():
def _GetRestrictedTelemetryDeps():
with open(_TELEMETRY_DEPS_PATH, 'r') as f:
telemetry_deps = json.load(f)
# Normalize paths in telemetry_deps since TELEMETRY_DEPS file only contain
# the relative path in chromium/src/.
def NormalizePath(p):
p = p.replace('/', os.path.sep)
return os.path.realpath(os.path.join(path.GetChromiumSrcDir(), p))
return os.path.realpath(os.path.join(path_util.GetChromiumSrcDir(), p))
telemetry_deps['file_deps'] = [
NormalizePath(p) for p in telemetry_deps['file_deps']]
telemetry_deps['directory_deps'] = [
NormalizePath(p) for p in telemetry_deps['directory_deps']]
return telemetry_deps
return map(NormalizePath, _TELEMETRY_DEPS)
class TelemetryDependenciesTest(unittest.TestCase):
......@@ -48,9 +45,7 @@ class TelemetryDependenciesTest(unittest.TestCase):
current_dependencies = _GetCurrentTelemetryDependencies()
extra_dep_paths = []
for dep_path in current_dependencies:
if not (dep_path in telemetry_deps['file_deps'] or
any(path.IsSubpath(dep_path, d)
for d in telemetry_deps['directory_deps'])):
if not any(path.IsSubpath(dep_path, d) for d in telemetry_deps):
extra_dep_paths.append(dep_path)
# Temporarily ignore failure on Mac because test is failing on Mac 10.8 bot.
# crbug.com/522335
......
......@@ -5,10 +5,7 @@
import sys
from core import path_util
sys.path.append(path_util.GetTelemetryDir())
from telemetry.internal.util import find_dependencies
from core import find_dependencies
if __name__ == '__main__':
......
# Copyright 2015 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.
{
"NOTE": [
"Please do NOT add new dependencies into this file. Contact ",
"aiolos@, dtu@, or nednguyen@ on how to proceed with your change."
],
"directory_deps": [
"build/android/devil/",
"build/android/pylib/",
"third_party/catapult/",
"tools/telemetry/"
],
"file_deps": [
]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment