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 """An interface for holding state and result of revisions in a bisect job. | 5 """An interface for holding state and result of revisions in a bisect job. |
6 | 6 |
7 When implementing support for tests other than perf, one should extend this | 7 When implementing support for tests other than perf, one should extend this |
8 class so that the bisect module and recipe can use it. | 8 class so that the bisect module and recipe can use it. |
9 | 9 |
10 See perf_revision_state for an example. | 10 See perf_revision_state for an example. |
11 """ | 11 """ |
12 import hashlib | 12 import hashlib |
13 import os | 13 import os |
14 import re | 14 import re |
15 | 15 |
16 from . import depot_config | 16 from . import depot_config |
17 | 17 |
18 | 18 |
| 19 |
19 class RevisionState(object): | 20 class RevisionState(object): |
20 """Abstracts the state of a single revision on a bisect job.""" | 21 """Abstracts the state of a single revision on a bisect job.""" |
21 | 22 |
22 def __init__(self, revision_string, bisector, depot='chromium', | 23 def __init__(self, revision_string, bisector, depot='chromium', |
23 dependency_depot_name=None,base_revision=None, | 24 dependency_depot_name=None,base_revision=None, |
24 deps_revision=None): | 25 deps_revision=None): |
25 """Create a new instance to track the state of a revision. | 26 """Create a new instance to track the state of a revision. |
26 | 27 |
27 There are two use cases for this constructor: | 28 There are two use cases for this constructor: |
28 - Creating a revision state for a chromium revision, OR | 29 - Creating a revision state for a chromium revision, OR |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 209 |
209 To wait for the test we try to get the buildbot job url from GS, and if | 210 To wait for the test we try to get the buildbot job url from GS, and if |
210 available, we query the status of such job. | 211 available, we query the status of such job. |
211 """ | 212 """ |
212 if not self.in_progress: | 213 if not self.in_progress: |
213 return | 214 return |
214 if not self.built: | 215 if not self.built: |
215 if self._is_build_archived(): | 216 if self._is_build_archived(): |
216 self.start_job() | 217 self.start_job() |
217 else: | 218 else: |
218 pass # TODO: Check if build has not timed out. | 219 pass # TODO: Check if build has not timed out. |
219 return | 220 return |
220 if not self.build_status_url: | 221 if not self.build_status_url: |
221 self.build_status_url = self._get_build_status_url() | 222 self.build_status_url = self._get_build_status_url() |
222 if self.build_status_url: | 223 if self.build_status_url: |
223 if 'Complete' in self._get_build_status(): | 224 if 'Complete' in self._get_build_status(): |
224 self._read_test_results() | 225 self._read_test_results() |
225 self.in_progress = False | 226 self.in_progress = False |
226 | 227 |
227 def _is_build_archived(self): | 228 def _is_build_archived(self): |
228 """Checks if the revision is already built and archived.""" | 229 """Checks if the revision is already built and archived.""" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 int(s, 16) | 272 int(s, 16) |
272 return True | 273 return True |
273 | 274 |
274 def _get_pos_from_hash(self, sha): | 275 def _get_pos_from_hash(self, sha): |
275 api = self.bisector.api | 276 api = self.bisector.api |
276 return api.m.commit_position.chromium_commit_position_from_hash(sha) | 277 return api.m.commit_position.chromium_commit_position_from_hash(sha) |
277 | 278 |
278 def _get_hash_from_pos(self, pos): | 279 def _get_hash_from_pos(self, pos): |
279 api = self.bisector.api | 280 api = self.bisector.api |
280 return api.m.commit_position.chromium_hash_from_commit_position(pos) | 281 return api.m.commit_position.chromium_hash_from_commit_position(pos) |
OLD | NEW |