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 """Parses the command line, discovers the appropriate benchmarks, and runs them. | 5 """Parses the command line, discovers the appropriate benchmarks, and runs them. |
6 | 6 |
7 Handles benchmark configuration, but all the logic for | 7 Handles benchmark configuration, but all the logic for |
8 actually running the benchmark is in Benchmark and PageRunner.""" | 8 actually running the benchmark is in Benchmark and PageRunner.""" |
9 | 9 |
10 import hashlib | 10 import hashlib |
11 import inspect | 11 import inspect |
12 import json | 12 import json |
13 import os | 13 import os |
14 import sys | 14 import sys |
15 | 15 |
16 from telemetry import benchmark | 16 from telemetry import benchmark |
17 from telemetry.core import discover | 17 from telemetry.core import discover |
18 from telemetry import decorators | 18 from telemetry import decorators |
19 from telemetry.internal.browser import browser_finder | 19 from telemetry.internal.browser import browser_finder |
20 from telemetry.internal.browser import browser_options | 20 from telemetry.internal.browser import browser_options |
| 21 from telemetry.internal.util import binary_manager |
21 from telemetry.internal.util import command_line | 22 from telemetry.internal.util import command_line |
22 | 23 |
23 | 24 |
24 def PrintBenchmarkList(benchmarks, possible_browser, output_pipe=sys.stdout): | 25 def PrintBenchmarkList(benchmarks, possible_browser, output_pipe=sys.stdout): |
25 """ Print benchmarks that are not filtered in the same order of benchmarks in | 26 """ Print benchmarks that are not filtered in the same order of benchmarks in |
26 the |benchmarks| list. | 27 the |benchmarks| list. |
27 | 28 |
28 Args: | 29 Args: |
29 benchmarks: the list of benchmarks to be printed (in the same order of the | 30 benchmarks: the list of benchmarks to be printed (in the same order of the |
30 list). | 31 list). |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 class ProjectConfig(object): | 70 class ProjectConfig(object): |
70 """Contains information about the benchmark runtime environment. | 71 """Contains information about the benchmark runtime environment. |
71 | 72 |
72 Attributes: | 73 Attributes: |
73 top_level_dir: A dir that contains benchmark, page test, and/or story | 74 top_level_dir: A dir that contains benchmark, page test, and/or story |
74 set dirs and associated artifacts. | 75 set dirs and associated artifacts. |
75 benchmark_dirs: A list of dirs containing benchmarks. | 76 benchmark_dirs: A list of dirs containing benchmarks. |
76 benchmark_aliases: A dict of name:alias string pairs to be matched against | 77 benchmark_aliases: A dict of name:alias string pairs to be matched against |
77 exactly during benchmark selection. | 78 exactly during benchmark selection. |
| 79 client_config: A path to a ProjectDependencies json file. |
78 """ | 80 """ |
79 def __init__(self, top_level_dir, benchmark_dirs=None, | 81 def __init__(self, top_level_dir, benchmark_dirs=None, |
80 benchmark_aliases=None): | 82 benchmark_aliases=None, client_config=None): |
81 self._top_level_dir = top_level_dir | 83 self._top_level_dir = top_level_dir |
82 self._benchmark_dirs = benchmark_dirs or [] | 84 self._benchmark_dirs = benchmark_dirs or [] |
83 self._benchmark_aliases = benchmark_aliases or dict() | 85 self._benchmark_aliases = benchmark_aliases or dict() |
84 | 86 self._client_config = client_config or '' |
85 if benchmark_aliases: | |
86 self._benchmark_aliases = benchmark_aliases | |
87 else: | |
88 self._benchmark_aliases = {} | |
89 | 87 |
90 @property | 88 @property |
91 def top_level_dir(self): | 89 def top_level_dir(self): |
92 return self._top_level_dir | 90 return self._top_level_dir |
93 | 91 |
94 @property | 92 @property |
95 def benchmark_dirs(self): | 93 def benchmark_dirs(self): |
96 return self._benchmark_dirs | 94 return self._benchmark_dirs |
97 | 95 |
98 @property | 96 @property |
99 def benchmark_aliases(self): | 97 def benchmark_aliases(self): |
100 return self._benchmark_aliases | 98 return self._benchmark_aliases |
101 | 99 |
| 100 @property |
| 101 def client_config(self): |
| 102 return self._client_config |
102 | 103 |
103 class Help(command_line.OptparseCommand): | 104 class Help(command_line.OptparseCommand): |
104 """Display help information about a command""" | 105 """Display help information about a command""" |
105 | 106 |
106 usage = '[command]' | 107 usage = '[command]' |
107 | 108 |
108 def Run(self, args): | 109 def Run(self, args): |
109 if len(args.positional_args) == 1: | 110 if len(args.positional_args) == 1: |
110 commands = _MatchingCommands(args.positional_args[0]) | 111 commands = _MatchingCommands(args.positional_args[0]) |
111 if len(commands) == 1: | 112 if len(commands) == 1: |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 % (command_name, _ScriptName())) | 402 % (command_name, _ScriptName())) |
402 for command in commands: | 403 for command in commands: |
403 print >> sys.stderr, ' %-10s %s' % ( | 404 print >> sys.stderr, ' %-10s %s' % ( |
404 command.Name(), command.Description()) | 405 command.Name(), command.Description()) |
405 return 1 | 406 return 1 |
406 if commands: | 407 if commands: |
407 command = commands[0] | 408 command = commands[0] |
408 else: | 409 else: |
409 command = Run | 410 command = Run |
410 | 411 |
| 412 binary_manager.InitDependencyManager(environment.client_config) |
| 413 |
411 # Parse and run the command. | 414 # Parse and run the command. |
412 parser = command.CreateParser() | 415 parser = command.CreateParser() |
413 command.AddCommandLineArgs(parser, environment) | 416 command.AddCommandLineArgs(parser, environment) |
414 options, args = parser.parse_args() | 417 options, args = parser.parse_args() |
415 if commands: | 418 if commands: |
416 args = args[1:] | 419 args = args[1:] |
417 options.positional_args = args | 420 options.positional_args = args |
418 command.ProcessCommandLineArgs(parser, options, environment) | 421 command.ProcessCommandLineArgs(parser, options, environment) |
419 return command().Run(options) | 422 return command().Run(options) |
OLD | NEW |