OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 fnmatch | 5 import fnmatch |
6 import imp | 6 import imp |
7 import logging | 7 import logging |
8 import modulefinder | 8 import modulefinder |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
11 import sys | 11 import sys |
12 import zipfile | 12 import zipfile |
13 | 13 |
14 from telemetry import benchmark | 14 from telemetry import benchmark |
15 from telemetry.core import discover | |
16 from telemetry.internal.util import bootstrap | 15 from telemetry.internal.util import bootstrap |
17 from telemetry.internal.util import command_line | 16 from telemetry.internal.util import command_line |
18 from telemetry.internal.util import path | 17 from telemetry.internal.util import path |
19 from telemetry.internal.util import path_set | 18 from telemetry.internal.util import path_set |
| 19 from telemetry.util import classes_util |
| 20 |
20 | 21 |
21 DEPS_FILE = 'bootstrap_deps' | 22 DEPS_FILE = 'bootstrap_deps' |
22 | 23 |
23 | 24 |
24 def FindBootstrapDependencies(base_dir): | 25 def FindBootstrapDependencies(base_dir): |
25 deps_file = os.path.join(base_dir, DEPS_FILE) | 26 deps_file = os.path.join(base_dir, DEPS_FILE) |
26 if not os.path.exists(deps_file): | 27 if not os.path.exists(deps_file): |
27 return [] | 28 return [] |
28 deps_paths = bootstrap.ListAllDepsPaths(deps_file) | 29 deps_paths = bootstrap.ListAllDepsPaths(deps_file) |
29 return set(os.path.realpath(os.path.join( | 30 return set(os.path.realpath(os.path.join( |
(...skipping 24 matching lines...) Expand all Loading... |
54 continue | 55 continue |
55 | 56 |
56 yield module_path | 57 yield module_path |
57 | 58 |
58 | 59 |
59 def FindPageSetDependencies(base_dir): | 60 def FindPageSetDependencies(base_dir): |
60 logging.info('Finding page sets in %s' % base_dir) | 61 logging.info('Finding page sets in %s' % base_dir) |
61 | 62 |
62 # Add base_dir to path so our imports relative to base_dir will work. | 63 # Add base_dir to path so our imports relative to base_dir will work. |
63 sys.path.append(base_dir) | 64 sys.path.append(base_dir) |
64 tests = discover.DiscoverClasses(base_dir, base_dir, benchmark.Benchmark, | 65 tests = classes_util.DiscoverClasses(base_dir, base_dir, benchmark.Benchmark) |
65 index_by_class_name=True) | |
66 | 66 |
67 for test_class in tests.itervalues(): | 67 for test_class in tests: |
68 test_obj = test_class() | 68 test_obj = test_class() |
69 | 69 |
70 # Ensure the test's default options are set if needed. | 70 # Ensure the test's default options are set if needed. |
71 parser = optparse.OptionParser() | 71 parser = optparse.OptionParser() |
72 test_obj.AddCommandLineArgs(parser, None) | 72 test_obj.AddCommandLineArgs(parser, None) |
73 options = optparse.Values() | 73 options = optparse.Values() |
74 for k, v in parser.get_default_values().__dict__.iteritems(): | 74 for k, v in parser.get_default_values().__dict__.iteritems(): |
75 options.ensure_value(k, v) | 75 options.ensure_value(k, v) |
76 | 76 |
77 # Page set paths are relative to their runner script, not relative to us. | 77 # Page set paths are relative to their runner script, not relative to us. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 def Run(self, args): | 214 def Run(self, args): |
215 target_paths = args.positional_args | 215 target_paths = args.positional_args |
216 dependencies = FindDependencies(target_paths, args) | 216 dependencies = FindDependencies(target_paths, args) |
217 if args.zip: | 217 if args.zip: |
218 ZipDependencies(target_paths, dependencies, args) | 218 ZipDependencies(target_paths, dependencies, args) |
219 print 'Zip archive written to %s.' % args.zip | 219 print 'Zip archive written to %s.' % args.zip |
220 else: | 220 else: |
221 print '\n'.join(sorted(dependencies)) | 221 print '\n'.join(sorted(dependencies)) |
222 return 0 | 222 return 0 |
OLD | NEW |