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 | 5 |
6 import logging | 6 import logging |
7 import multiprocessing | 7 import multiprocessing |
8 | 8 |
9 from pylib import android_commands | 9 from pylib import android_commands |
10 from pylib.base.test_result import TestResults | 10 from pylib.base.test_result import TestResults |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 self.attached_devices = android_commands.GetAttachedDevices() | 120 self.attached_devices = android_commands.GetAttachedDevices() |
121 continue | 121 continue |
122 test_results = TestResults.FromTestResults(results_lists) | 122 test_results = TestResults.FromTestResults(results_lists) |
123 # Re-check the attached devices for some devices may | 123 # Re-check the attached devices for some devices may |
124 # become offline | 124 # become offline |
125 retry_devices = set(android_commands.GetAttachedDevices()) | 125 retry_devices = set(android_commands.GetAttachedDevices()) |
126 # Remove devices that had exceptions. | 126 # Remove devices that had exceptions. |
127 retry_devices -= TestResults.DeviceExceptions(results_lists) | 127 retry_devices -= TestResults.DeviceExceptions(results_lists) |
128 # Retry on devices that didn't have any exception. | 128 # Retry on devices that didn't have any exception. |
129 self.attached_devices = list(retry_devices) | 129 self.attached_devices = list(retry_devices) |
| 130 |
| 131 # TODO(frankf): Fix the retry logic: |
| 132 # - GetAllBroken() should report all tests not ran. |
| 133 # - Do not break TestResults encapsulation. |
130 if (retry == self.retries - 1 or | 134 if (retry == self.retries - 1 or |
131 len(self.attached_devices) == 0): | 135 len(self.attached_devices) == 0): |
132 all_passed = final_results.ok + test_results.ok | 136 all_passed = final_results.ok + test_results.ok |
133 final_results = test_results | 137 final_results = test_results |
134 final_results.ok = all_passed | 138 final_results.ok = all_passed |
135 break | 139 break |
136 else: | 140 else: |
137 final_results.ok += test_results.ok | 141 final_results.ok += test_results.ok |
138 # Timed out tests are not reported in GetAllBroken(). | 142 final_results.overall_timed_out = (final_results.overall_timed_out or |
139 if test_results.timed_out: | 143 test_results.overall_timed_out) |
140 final_results.timed_out = True | 144 final_results.overall_fail = (final_results.overall_fail or |
| 145 test_results.overall_fail) |
| 146 |
141 self.tests = [] | 147 self.tests = [] |
142 for t in test_results.GetAllBroken(): | 148 for t in test_results.GetAllBroken(): |
143 self.tests += [t.name] | 149 self.tests += [t.name] |
144 if not self.tests: | 150 if not self.tests: |
145 break | 151 break |
146 else: | 152 else: |
147 # We ran out retries, possibly out of healthy devices. | 153 # We ran out retries, possibly out of healthy devices. |
148 # There's no recovery at this point. | 154 # There's no recovery at this point. |
149 raise Exception('Unrecoverable error while retrying test runs.') | 155 raise Exception('Unrecoverable error while retrying test runs.') |
150 self.OnTestsCompleted(test_runners, final_results) | 156 self.OnTestsCompleted(test_runners, final_results) |
151 self._KillHostForwarder() | 157 self._KillHostForwarder() |
152 return final_results | 158 return final_results |
OLD | NEW |