Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 import logging | 6 import logging |
| 7 import StringIO | |
| 6 import unittest | 8 import unittest |
| 9 import urllib2 | |
| 7 | 10 |
| 8 from telemetry import decorators | 11 from telemetry import decorators |
| 9 from telemetry.core import browser_finder | 12 from telemetry.core import browser_finder |
| 10 from telemetry.core import browser_options | 13 from telemetry.core import browser_options |
| 11 from telemetry.core import command_line | 14 from telemetry.core import command_line |
| 12 from telemetry.core import discover | 15 from telemetry.core import discover |
| 13 from telemetry.unittest import json_results | 16 from telemetry.unittest import json_results |
| 14 from telemetry.unittest import progress_reporter | 17 from telemetry.unittest import progress_reporter |
| 15 | 18 |
| 16 | 19 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 return func(*args, **kwargs) | 106 return func(*args, **kwargs) |
| 104 finally: | 107 finally: |
| 105 # Restore logging level, which may be changed in parser.parse_args. | 108 # Restore logging level, which may be changed in parser.parse_args. |
| 106 logging.getLogger().setLevel(logging_level) | 109 logging.getLogger().setLevel(logging_level) |
| 107 | 110 |
| 108 return _LoggingRestoreWrapper | 111 return _LoggingRestoreWrapper |
| 109 | 112 |
| 110 | 113 |
| 111 config = None | 114 config = None |
| 112 | 115 |
| 116 # pylint: disable=W0613 | |
| 117 def stuburlopen(url): | |
| 118 assert not hasattr(stuburlopen, 'called') | |
| 119 setattr(stuburlopen, 'called', 1) | |
| 120 return StringIO.StringIO(json.dumps({'builders':{ | |
| 121 'android_nexus4_perf_bisect': 'stuff', | |
| 122 'mac_10_9_perf_bisect': 'otherstuff', | |
| 123 'win_perf_bisect_builder': 'not a trybot', | |
| 124 }})) | |
| 125 | |
| 113 | 126 |
| 114 class RunTestsCommand(command_line.OptparseCommand): | 127 class RunTestsCommand(command_line.OptparseCommand): |
| 115 """Run unit tests""" | 128 """Run unit tests""" |
| 116 | 129 |
| 117 usage = '[test_name ...] [<options>]' | 130 usage = '[test_name ...] [<options>]' |
| 118 | 131 |
| 119 @classmethod | 132 @classmethod |
| 120 def CreateParser(cls): | 133 def CreateParser(cls): |
| 121 options = browser_options.BrowserFinderOptions() | 134 options = browser_options.BrowserFinderOptions() |
| 122 options.browser_type = 'any' | 135 options.browser_type = 'any' |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 possible_browser, args.positional_args, | 211 possible_browser, args.positional_args, |
| 199 args.exact_test_filter, args.run_disabled_tests) | 212 args.exact_test_filter, args.run_disabled_tests) |
| 200 runner = progress_reporter.TestRunner() | 213 runner = progress_reporter.TestRunner() |
| 201 result = runner.run(test_suite, config.progress_reporters, | 214 result = runner.run(test_suite, config.progress_reporters, |
| 202 args.repeat_count, args) | 215 args.repeat_count, args) |
| 203 return test_suite, result | 216 return test_suite, result |
| 204 | 217 |
| 205 @classmethod | 218 @classmethod |
| 206 @RestoreLoggingLevel | 219 @RestoreLoggingLevel |
| 207 def main(cls, args=None): | 220 def main(cls, args=None): |
| 221 urllib2.urlopen = stuburlopen | |
| 208 return super(RunTestsCommand, cls).main(args) | 222 return super(RunTestsCommand, cls).main(args) |
|
sullivan
2014/08/15 14:58:37
There's one big problem with this CL: the unit tes
| |
| OLD | NEW |