Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: tools/perf/core/telemetry_dependencies_unittest.py

Issue 1467143006: [Telemetry] Migrate find_dependencies internals to tools/perf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Ned's comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/perf/core/find_dependencies_unittest.py ('k') | tools/perf/find_dependencies » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import json 5 # TODO(eakuefner): Remove this test once Telemetry lives in Catapult.
6 import os 6 import os
7 import platform 7 import platform
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
11 from telemetry.internal.util import find_dependencies
12 from telemetry.internal.util import path 11 from telemetry.internal.util import path
13 12
13 from core import find_dependencies
14 from core import path_util
14 15
15 _TELEMETRY_DEPS_PATH = os.path.join( 16 _TELEMETRY_DEPS = [
16 path.GetTelemetryDir(), 'telemetry', 'TELEMETRY_DEPS') 17 'build/android/devil/',
18 'build/android/pylib/',
19 'third_party/catapult/',
20 'tools/telemetry/']
17 21
18 22
19 def _GetCurrentTelemetryDependencies(): 23 def _GetCurrentTelemetryDependencies():
20 parser = find_dependencies.FindDependenciesCommand.CreateParser() 24 parser = find_dependencies.FindDependenciesCommand.CreateParser()
21 find_dependencies.FindDependenciesCommand.AddCommandLineArgs(parser, None) 25 find_dependencies.FindDependenciesCommand.AddCommandLineArgs(parser, None)
22 options, args = parser.parse_args(['']) 26 options, args = parser.parse_args([''])
23 options.positional_args = args 27 options.positional_args = args
24 return find_dependencies.FindDependencies([], options=options) 28 return find_dependencies.FindDependencies([], options=options)
25 29
26 30
27 def _GetRestrictedTelemetryDeps(): 31 def _GetRestrictedTelemetryDeps():
28 with open(_TELEMETRY_DEPS_PATH, 'r') as f:
29 telemetry_deps = json.load(f)
30
31 # Normalize paths in telemetry_deps since TELEMETRY_DEPS file only contain 32 # Normalize paths in telemetry_deps since TELEMETRY_DEPS file only contain
32 # the relative path in chromium/src/. 33 # the relative path in chromium/src/.
33 def NormalizePath(p): 34 def NormalizePath(p):
34 p = p.replace('/', os.path.sep) 35 p = p.replace('/', os.path.sep)
35 return os.path.realpath(os.path.join(path.GetChromiumSrcDir(), p)) 36 return os.path.realpath(os.path.join(path_util.GetChromiumSrcDir(), p))
36 37
37 telemetry_deps['file_deps'] = [ 38 return map(NormalizePath, _TELEMETRY_DEPS)
38 NormalizePath(p) for p in telemetry_deps['file_deps']]
39 telemetry_deps['directory_deps'] = [
40 NormalizePath(p) for p in telemetry_deps['directory_deps']]
41 return telemetry_deps
42 39
43 40
44 class TelemetryDependenciesTest(unittest.TestCase): 41 class TelemetryDependenciesTest(unittest.TestCase):
45 42
46 def testNoNewTelemetryDependencies(self): 43 def testNoNewTelemetryDependencies(self):
47 telemetry_deps = _GetRestrictedTelemetryDeps() 44 telemetry_deps = _GetRestrictedTelemetryDeps()
48 current_dependencies = _GetCurrentTelemetryDependencies() 45 current_dependencies = _GetCurrentTelemetryDependencies()
49 extra_dep_paths = [] 46 extra_dep_paths = []
50 for dep_path in current_dependencies: 47 for dep_path in current_dependencies:
51 if not (dep_path in telemetry_deps['file_deps'] or 48 if not any(path.IsSubpath(dep_path, d) for d in telemetry_deps):
52 any(path.IsSubpath(dep_path, d)
53 for d in telemetry_deps['directory_deps'])):
54 extra_dep_paths.append(dep_path) 49 extra_dep_paths.append(dep_path)
55 # Temporarily ignore failure on Mac because test is failing on Mac 10.8 bot. 50 # Temporarily ignore failure on Mac because test is failing on Mac 10.8 bot.
56 # crbug.com/522335 51 # crbug.com/522335
57 if extra_dep_paths: 52 if extra_dep_paths:
58 if platform.system() != 'Darwin': 53 if platform.system() != 'Darwin':
59 self.fail( 54 self.fail(
60 'Your patch adds new dependencies to telemetry. Please contact ' 55 'Your patch adds new dependencies to telemetry. Please contact '
61 'aiolos@,dtu@, or nednguyen@ on how to proceed with this change. ' 56 'aiolos@,dtu@, or nednguyen@ on how to proceed with this change. '
62 'Extra dependencies:\n%s' % '\n'.join(extra_dep_paths)) 57 'Extra dependencies:\n%s' % '\n'.join(extra_dep_paths))
63 else: 58 else:
64 print ('Dependencies check failed on mac platform. Extra deps: %s\n' 59 print ('Dependencies check failed on mac platform. Extra deps: %s\n'
65 ' sys.path: %s' % (extra_dep_paths, sys.path)) 60 ' sys.path: %s' % (extra_dep_paths, sys.path))
OLDNEW
« no previous file with comments | « tools/perf/core/find_dependencies_unittest.py ('k') | tools/perf/find_dependencies » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698