Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from collections import defaultdict | 5 from collections import defaultdict |
| 6 import json | 6 import json |
| 7 | 7 |
| 8 from recipe_engine.config import Dict | 8 from recipe_engine.config import Dict |
| 9 from recipe_engine.config import List | 9 from recipe_engine.config import List |
| 10 from recipe_engine.config import Single | 10 from recipe_engine.config import Single |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 class TestResult(object): | 70 class TestResult(object): |
| 71 SKIPPED = 'skipped' # A commit doesn't impact the test. | 71 SKIPPED = 'skipped' # A commit doesn't impact the test. |
| 72 PASSED = 'passed' # The compile or test passed. | 72 PASSED = 'passed' # The compile or test passed. |
| 73 FAILED = 'failed' # The compile or test failed. | 73 FAILED = 'failed' # The compile or test failed. |
| 74 INFRA_FAILED = 'infra_failed' # Infra failed. | 74 INFRA_FAILED = 'infra_failed' # Infra failed. |
| 75 | 75 |
| 76 | 76 |
| 77 def _check_and_remove_test_name(test_names, test_name): | |
| 78 """Check if a test_name is in the list and remove it if it is.""" | |
| 79 try: | |
| 80 test_names.remove(test_name) | |
| 81 return True | |
| 82 except ValueError: | |
| 83 return False | |
| 84 | |
| 85 | |
| 77 def _compile_and_test_at_revision(api, target_mastername, target_buildername, | 86 def _compile_and_test_at_revision(api, target_mastername, target_buildername, |
| 78 target_testername, revision, requested_tests, | 87 target_testername, revision, requested_tests, |
| 79 use_analyze): | 88 use_analyze): |
| 80 results = {} | 89 results = {} |
| 90 | |
| 81 with api.step.nest('test %s' % str(revision)): | 91 with api.step.nest('test %s' % str(revision)): |
| 82 # Checkout code at the given revision to recompile. | 92 # Checkout code at the given revision to recompile. |
| 83 bot_config = api.chromium_tests.create_bot_config_object( | 93 bot_config = api.chromium_tests.create_bot_config_object( |
| 84 target_mastername, target_buildername) | 94 target_mastername, target_buildername) |
| 85 bot_update_step, bot_db = api.chromium_tests.prepare_checkout( | 95 bot_update_step, bot_db = api.chromium_tests.prepare_checkout( |
| 86 bot_config, root_solution_revision=revision) | 96 bot_config, root_solution_revision=revision) |
| 87 | 97 |
| 88 # Figure out which test steps to run. | 98 # Figure out which test steps to run. |
| 89 _, all_tests = api.chromium_tests.get_tests(bot_config, bot_db) | 99 _, all_tests = api.chromium_tests.get_tests(bot_config, bot_db) |
| 100 requested_test_names = [k for k in requested_tests] | |
| 90 requested_tests_to_run = [ | 101 requested_tests_to_run = [ |
| 91 test for test in all_tests if test.name in requested_tests] | 102 test for test in all_tests if |
| 103 _check_and_remove_test_name(requested_test_names, test.name)] | |
|
stgao
2016/06/14 23:40:06
This fix might cause issue.
Each test will has som
| |
| 92 | 104 |
| 93 # Figure out the test targets to be compiled. | 105 # Figure out the test targets to be compiled. |
| 94 requested_test_targets = [] | 106 requested_test_targets = [] |
| 95 for test in requested_tests_to_run: | 107 for test in requested_tests_to_run: |
| 96 requested_test_targets.extend(test.compile_targets(api)) | 108 requested_test_targets.extend(test.compile_targets(api)) |
| 97 requested_test_targets = sorted(set(requested_test_targets)) | 109 requested_test_targets = sorted(set(requested_test_targets)) |
| 98 | 110 |
| 99 actual_tests_to_run = requested_tests_to_run | 111 actual_tests_to_run = requested_tests_to_run |
| 100 actual_compile_targets = requested_test_targets | 112 actual_compile_targets = requested_test_targets |
| 101 # Use dependency "analyze" to reduce tests to be run. | 113 # Use dependency "analyze" to reduce tests to be run. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 bot_db, | 145 bot_db, |
| 134 actual_compile_targets, | 146 actual_compile_targets, |
| 135 tests_including_triggered=actual_tests_to_run, | 147 tests_including_triggered=actual_tests_to_run, |
| 136 mb_mastername=target_mastername, | 148 mb_mastername=target_mastername, |
| 137 mb_buildername=target_buildername, | 149 mb_buildername=target_buildername, |
| 138 override_bot_type='builder_tester') | 150 override_bot_type='builder_tester') |
| 139 | 151 |
| 140 # Run the tests. | 152 # Run the tests. |
| 141 with api.chromium_tests.wrap_chromium_tests( | 153 with api.chromium_tests.wrap_chromium_tests( |
| 142 bot_config, actual_tests_to_run): | 154 bot_config, actual_tests_to_run): |
| 155 test_names = [te.name for te in actual_tests_to_run] | |
| 143 failed_tests = api.test_utils.run_tests( | 156 failed_tests = api.test_utils.run_tests( |
| 144 api, actual_tests_to_run, | 157 api, actual_tests_to_run, |
| 145 suffix=revision, test_filters=requested_tests) | 158 suffix=revision, test_filters=requested_tests) |
| 146 | 159 |
| 147 # Process failed tests. | 160 # Process failed tests. |
| 148 failed_tests_dict = defaultdict(list) | 161 failed_tests_dict = defaultdict(list) |
| 149 for failed_test in failed_tests: | 162 for failed_test in failed_tests: |
| 150 valid = failed_test.has_valid_results(api, suffix=revision) | 163 valid = failed_test.has_valid_results(api, suffix=revision) |
| 151 results[failed_test.name] = { | 164 results[failed_test.name] = { |
| 152 'status': TestResult.FAILED, | 165 'status': TestResult.FAILED, |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1092 'git commits in range', | 1105 'git commits in range', |
| 1093 api.raw_io.stream_output( | 1106 api.raw_io.stream_output( |
| 1094 '\n'.join('r%d' % i for i in reversed(range(1, 7))))) + | 1107 '\n'.join('r%d' % i for i in reversed(range(1, 7))))) + |
| 1095 api.override_step_data( | 1108 api.override_step_data( |
| 1096 'test r2.gl_tests (r2) on Mac-10.9', | 1109 'test r2.gl_tests (r2) on Mac-10.9', |
| 1097 simulated_gtest_output(passed_test_names=['Test.One'])) + | 1110 simulated_gtest_output(passed_test_names=['Test.One'])) + |
| 1098 api.override_step_data( | 1111 api.override_step_data( |
| 1099 'test r3.gl_tests (r3) on Mac-10.9', | 1112 'test r3.gl_tests (r3) on Mac-10.9', |
| 1100 simulated_gtest_output(failed_test_names=['Test.One'])) | 1113 simulated_gtest_output(failed_test_names=['Test.One'])) |
| 1101 ) | 1114 ) |
| OLD | NEW |