OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 import fnmatch | 4 import fnmatch |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import traceback | 7 import traceback |
8 import unittest | 8 import unittest |
9 | 9 |
10 from telemetry import gtest_testrunner | 10 from telemetry.core import browser_options |
11 from telemetry import browser_options | 11 from telemetry.test import gtest_testrunner |
12 from telemetry import options_for_unittests | 12 from telemetry.test import options_for_unittests |
13 | 13 |
14 | 14 |
15 def RequiresBrowserOfType(*types): | 15 def RequiresBrowserOfType(*types): |
16 def wrap(func): | 16 def wrap(func): |
17 func._requires_browser_types = types | 17 func._requires_browser_types = types |
18 return func | 18 return func |
19 return wrap | 19 return wrap |
20 | 20 |
21 | 21 |
22 def Discover(start_dir, pattern = 'test*.py', top_level_dir = None): | 22 def Discover(start_dir, pattern = 'test*.py', top_level_dir = None): |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 parser = default_options.CreateParser('run_tests [options] [test names]') | 115 parser = default_options.CreateParser('run_tests [options] [test names]') |
116 parser.add_option('--repeat-count', dest='run_test_repeat_count', | 116 parser.add_option('--repeat-count', dest='run_test_repeat_count', |
117 type='int', default=1, | 117 type='int', default=1, |
118 help='Repeats each a provided number of times.') | 118 help='Repeats each a provided number of times.') |
119 | 119 |
120 _, args = parser.parse_args(args) | 120 _, args = parser.parse_args(args) |
121 | 121 |
122 if default_options.verbosity == 0: | 122 if default_options.verbosity == 0: |
123 logging.getLogger().setLevel(logging.ERROR) | 123 logging.getLogger().setLevel(logging.ERROR) |
124 | 124 |
125 from telemetry import browser_finder | 125 from telemetry.core import browser_finder |
126 browser_to_create = browser_finder.FindBrowser(default_options) | 126 browser_to_create = browser_finder.FindBrowser(default_options) |
127 if browser_to_create == None: | 127 if browser_to_create == None: |
128 logging.error('No browser found of type %s. Cannot run tests.', | 128 logging.error('No browser found of type %s. Cannot run tests.', |
129 default_options.browser_type) | 129 default_options.browser_type) |
130 logging.error('Re-run with --browser=list to see available browser types.') | 130 logging.error('Re-run with --browser=list to see available browser types.') |
131 return 1 | 131 return 1 |
132 | 132 |
133 options_for_unittests.Set(default_options, | 133 options_for_unittests.Set(default_options, |
134 browser_to_create.browser_type) | 134 browser_to_create.browser_type) |
135 olddir = os.getcwd() | 135 olddir = os.getcwd() |
136 try: | 136 try: |
137 os.chdir(top_level_dir) | 137 os.chdir(top_level_dir) |
138 success = True | 138 success = True |
139 for _ in range( | 139 for _ in range( |
140 default_options.run_test_repeat_count): # pylint: disable=E1101 | 140 default_options.run_test_repeat_count): # pylint: disable=E1101 |
141 success = success and DiscoverAndRunTests(start_dir, args, top_level_dir, | 141 success = success and DiscoverAndRunTests(start_dir, args, top_level_dir, |
142 runner) | 142 runner) |
143 if success: | 143 if success: |
144 return 0 | 144 return 0 |
145 finally: | 145 finally: |
146 os.chdir(olddir) | 146 os.chdir(olddir) |
147 options_for_unittests.Set(None, None) | 147 options_for_unittests.Set(None, None) |
148 | 148 |
149 return 1 | 149 return 1 |
OLD | NEW |