| OLD | NEW |
| 1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Encapsulates running tests defined in tests.py. | 6 """Encapsulates running tests defined in tests.py. |
| 7 | 7 |
| 8 Running this script requires passing --config-path with a path to a config file | 8 Running this script requires passing --config-path with a path to a config file |
| 9 of the following structure: | 9 of the following structure: |
| 10 | 10 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 (On SCRIPT_DEBUG it returns diagnostics for this script.) | 149 (On SCRIPT_DEBUG it returns diagnostics for this script.) |
| 150 | 150 |
| 151 Args: | 151 Args: |
| 152 config_path: The path to the config INI file. See the top of the file | 152 config_path: The path to the config INI file. See the top of the file |
| 153 for format description. | 153 for format description. |
| 154 """ | 154 """ |
| 155 config = Config(config_path) | 155 config = Config(config_path) |
| 156 logger = logging.getLogger("run_tests") | 156 logger = logging.getLogger("run_tests") |
| 157 logger.log(SCRIPT_DEBUG, "%d tests to run: %s", len(config.tests_to_run), | 157 logger.log(SCRIPT_DEBUG, "%d tests to run: %s", len(config.tests_to_run), |
| 158 config.tests_to_run) | 158 config.tests_to_run) |
| 159 logger.log(SCRIPT_DEBUG, "%d test cases to run: %s", |
| 160 len(config.test_cases_to_run), |
| 161 config.test_cases_to_run) |
| 159 data = [(website, test_case, config) | 162 data = [(website, test_case, config) |
| 160 for website in config.tests_to_run | 163 for website in config.tests_to_run |
| 161 for test_case in config.test_cases_to_run] | 164 for test_case in config.test_cases_to_run] |
| 162 number_of_processes = min([config.max_tests_in_parallel, | 165 number_of_processes = min([config.max_tests_in_parallel, |
| 163 len(config.test_cases_to_run) * | 166 len(config.test_cases_to_run) * |
| 164 len(config.tests_to_run)]) | 167 len(config.tests_to_run)]) |
| 165 p = multiprocessing.Pool(number_of_processes) | 168 p = multiprocessing.Pool(number_of_processes) |
| 166 results = p.map(RunTestCaseOnWebsite, data) | 169 results = p.map(RunTestCaseOnWebsite, data) |
| 167 p.close() | 170 p.close() |
| 168 p.join() | 171 p.join() |
| 169 LogResultsOfTestRun(config, results) | 172 LogResultsOfTestRun(config, results) |
| 170 | 173 |
| 171 | 174 |
| 172 def main(): | 175 def main(): |
| 173 parser = argparse.ArgumentParser() | 176 parser = argparse.ArgumentParser() |
| 174 parser.add_argument("config_path", metavar="N", | 177 parser.add_argument("config_path", metavar="N", |
| 175 help="Path to the config.ini file.") | 178 help="Path to the config.ini file.") |
| 176 args = parser.parse_args() | 179 args = parser.parse_args() |
| 177 RunTests(args.config_path) | 180 RunTests(args.config_path) |
| 178 | 181 |
| 179 | 182 |
| 180 if __name__ == "__main__": | 183 if __name__ == "__main__": |
| 181 main() | 184 main() |
| OLD | NEW |