| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Generates test runner factory and tests for performance tests.""" | 5 """Generates test runner factory and tests for performance tests.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import fnmatch | 8 import fnmatch |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 Returns: | 59 Returns: |
| 60 A tuple of (TestRunnerFactory, tests). | 60 A tuple of (TestRunnerFactory, tests). |
| 61 """ | 61 """ |
| 62 if os.path.exists(constants.PERF_OUTPUT_DIR): | 62 if os.path.exists(constants.PERF_OUTPUT_DIR): |
| 63 shutil.rmtree(constants.PERF_OUTPUT_DIR) | 63 shutil.rmtree(constants.PERF_OUTPUT_DIR) |
| 64 os.makedirs(constants.PERF_OUTPUT_DIR) | 64 os.makedirs(constants.PERF_OUTPUT_DIR) |
| 65 | 65 |
| 66 # Before running the tests, kill any leftover server. | 66 # Before running the tests, kill any leftover server. |
| 67 _KillPendingServers() | 67 _KillPendingServers() |
| 68 | 68 |
| 69 with file(test_options.steps, 'r') as f: | 69 if test_options.single_step: |
| 70 tests = json.load(f) | 70 # Running a single command, build the tests structure. |
| 71 tests = [['single_step', test_options.single_step]] |
| 72 |
| 73 if test_options.steps: |
| 74 with file(test_options.steps, 'r') as f: |
| 75 tests = json.load(f) |
| 71 | 76 |
| 72 # The list is necessary to keep the steps order, but internally | 77 # The list is necessary to keep the steps order, but internally |
| 73 # the format is squashed from a list of lists into a single dict: | 78 # the format is squashed from a list of lists into a single dict: |
| 74 # [["A", "cmd"], ["B", "cmd"]] into {"A": "cmd", "B": "cmd"} | 79 # [["A", "cmd"], ["B", "cmd"]] into {"A": "cmd", "B": "cmd"} |
| 75 sorted_test_names = [i[0] for i in tests] | 80 sorted_test_names = [i[0] for i in tests] |
| 76 tests_dict = dict(tests) | 81 tests_dict = dict(tests) |
| 77 | 82 |
| 78 if test_options.test_filter: | 83 if test_options.test_filter: |
| 79 sorted_test_names = fnmatch.filter(sorted_test_names, | 84 sorted_test_names = fnmatch.filter(sorted_test_names, |
| 80 test_options.test_filter) | 85 test_options.test_filter) |
| 81 tests_dict = dict((k, v) for k, v in tests_dict.iteritems() | 86 tests_dict = dict((k, v) for k, v in tests_dict.iteritems() |
| 82 if k in sorted_test_names) | 87 if k in sorted_test_names) |
| 83 | 88 |
| 84 flaky_steps = [] | 89 flaky_steps = [] |
| 85 if test_options.flaky_steps: | 90 if test_options.flaky_steps: |
| 86 with file(test_options.flaky_steps, 'r') as f: | 91 with file(test_options.flaky_steps, 'r') as f: |
| 87 flaky_steps = json.load(f) | 92 flaky_steps = json.load(f) |
| 88 | 93 |
| 89 def TestRunnerFactory(device, shard_index): | 94 def TestRunnerFactory(device, shard_index): |
| 90 return test_runner.TestRunner( | 95 return test_runner.TestRunner( |
| 91 test_options, device, tests_dict, flaky_steps) | 96 test_options, device, tests_dict, flaky_steps) |
| 92 | 97 |
| 93 return (TestRunnerFactory, sorted_test_names) | 98 return (TestRunnerFactory, sorted_test_names) |
| OLD | NEW |