| 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 | 4 |
| 5 """Runs the Python tests (relies on using the Java test runner).""" | 5 """Runs the Python tests (relies on using the Java test runner).""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 import types | 10 import types |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 Args: | 111 Args: |
| 112 python_test_root: the path to walk, looking for pythonDrivenTests | 112 python_test_root: the path to walk, looking for pythonDrivenTests |
| 113 is_official_build: whether to run only those tests marked 'official' | 113 is_official_build: whether to run only those tests marked 'official' |
| 114 | 114 |
| 115 Returns: | 115 Returns: |
| 116 A list of Python modules which may have zero or more tests. | 116 A list of Python modules which may have zero or more tests. |
| 117 """ | 117 """ |
| 118 # By default run all python tests under pythonDrivenTests. | 118 # By default run all python tests under pythonDrivenTests. |
| 119 python_test_file_list = [] | 119 python_test_file_list = [] |
| 120 for root, _, files in os.walk(python_test_root): | 120 for root, _, files in os.walk(python_test_root): |
| 121 if (root.endswith('pythonDrivenTests') | 121 if (root.endswith('host_driven_tests') or |
| 122 or (is_official_build | 122 root.endswith('pythonDrivenTests') or |
| 123 and root.endswith('pythonDrivenTests/official'))): | 123 (is_official_build and root.endswith('pythonDrivenTests/official'))): |
| 124 python_test_file_list += _GetPythonFiles(root, files) | 124 python_test_file_list += _GetPythonFiles(root, files) |
| 125 python_test_file_list.sort() | 125 python_test_file_list.sort() |
| 126 | 126 |
| 127 test_module_list = [_GetModuleFromFile(test_file) | 127 test_module_list = [_GetModuleFromFile(test_file) |
| 128 for test_file in python_test_file_list] | 128 for test_file in python_test_file_list] |
| 129 return test_module_list | 129 return test_module_list |
| 130 | 130 |
| 131 | 131 |
| 132 def _GetModuleFromFile(python_file): | 132 def _GetModuleFromFile(python_file): |
| 133 """Gets the module associated with a file by importing it. | 133 """Gets the module associated with a file by importing it. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 Returns: | 199 Returns: |
| 200 List of test case objects for all available test methods. | 200 List of test case objects for all available test methods. |
| 201 """ | 201 """ |
| 202 if not test_root: | 202 if not test_root: |
| 203 return [] | 203 return [] |
| 204 all_tests = [] | 204 all_tests = [] |
| 205 test_module_list = _GetTestModules(test_root, is_official_build) | 205 test_module_list = _GetTestModules(test_root, is_official_build) |
| 206 for module in test_module_list: | 206 for module in test_module_list: |
| 207 all_tests.extend(_GetTestClassesFromModule(module)) | 207 all_tests.extend(_GetTestClassesFromModule(module)) |
| 208 return all_tests | 208 return all_tests |
| OLD | NEW |