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 logging | 5 import logging |
6 import unittest | 6 import unittest |
7 | 7 |
8 from telemetry import decorators | 8 from telemetry import decorators |
9 from telemetry.core import browser_finder | 9 from telemetry.core import browser_finder |
10 from telemetry.core import browser_options | 10 from telemetry.core import browser_options |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return parser | 119 return parser |
120 | 120 |
121 @classmethod | 121 @classmethod |
122 def AddCommandLineArgs(cls, parser): | 122 def AddCommandLineArgs(cls, parser): |
123 parser.add_option('--repeat-count', type='int', default=1, | 123 parser.add_option('--repeat-count', type='int', default=1, |
124 help='Repeats each a provided number of times.') | 124 help='Repeats each a provided number of times.') |
125 parser.add_option('-d', '--also-run-disabled-tests', | 125 parser.add_option('-d', '--also-run-disabled-tests', |
126 dest='run_disabled_tests', | 126 dest='run_disabled_tests', |
127 action='store_true', default=False, | 127 action='store_true', default=False, |
128 help='Ignore @Disabled and @Enabled restrictions.') | 128 help='Ignore @Disabled and @Enabled restrictions.') |
129 parser.add_option('--retry-limit', type='int', default=0, | 129 parser.add_option('--retry-limit', type='int', |
130 help='Retry each failure up to N times (default %default)' | 130 help='Retry each failure up to N times' |
131 ' to de-flake things.') | 131 ' to de-flake things.') |
132 json_results.AddOptions(parser) | 132 json_results.AddOptions(parser) |
133 | 133 |
134 @classmethod | 134 @classmethod |
135 def ProcessCommandLineArgs(cls, parser, args): | 135 def ProcessCommandLineArgs(cls, parser, args): |
136 if args.verbosity == 0: | 136 if args.verbosity == 0: |
137 logging.getLogger().setLevel(logging.WARN) | 137 logging.getLogger().setLevel(logging.WARN) |
138 | 138 |
| 139 # We retry failures by default unless we're running a list of tests |
| 140 # explicitly. |
| 141 if args.retry_limit is None and not args.positional_args: |
| 142 args.retry_limit = 3 |
| 143 |
139 try: | 144 try: |
140 possible_browser = browser_finder.FindBrowser(args) | 145 possible_browser = browser_finder.FindBrowser(args) |
141 except browser_finder.BrowserFinderException, ex: | 146 except browser_finder.BrowserFinderException, ex: |
142 parser.error(ex) | 147 parser.error(ex) |
143 | 148 |
144 if not possible_browser: | 149 if not possible_browser: |
145 parser.error('No browser found of type %s. Cannot run tests.\n' | 150 parser.error('No browser found of type %s. Cannot run tests.\n' |
146 'Re-run with --browser=list to see ' | 151 'Re-run with --browser=list to see ' |
147 'available browser types.' % args.browser_type) | 152 'available browser types.' % args.browser_type) |
148 | 153 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 args.run_disabled_tests) | 190 args.run_disabled_tests) |
186 runner = progress_reporter.TestRunner() | 191 runner = progress_reporter.TestRunner() |
187 result = runner.run(test_suite, config.progress_reporters, | 192 result = runner.run(test_suite, config.progress_reporters, |
188 args.repeat_count, args) | 193 args.repeat_count, args) |
189 return test_suite, result | 194 return test_suite, result |
190 | 195 |
191 @classmethod | 196 @classmethod |
192 @RestoreLoggingLevel | 197 @RestoreLoggingLevel |
193 def main(cls, args=None): | 198 def main(cls, args=None): |
194 return super(RunTestsCommand, cls).main(args) | 199 return super(RunTestsCommand, cls).main(args) |
OLD | NEW |