OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """A class for updating layout test expectations when updating w3c tests. | 5 """A class for updating layout test expectations when updating w3c tests. |
6 | 6 |
7 Specifically, this class fetches results from try bots for the current CL, and: | 7 Specifically, this class fetches results from try bots for the current CL, and: |
8 1. Downloads new baseline files for any tests that can be rebaselined. | 8 1. Downloads new baseline files for any tests that can be rebaselined. |
9 2. Updates the generic TestExpectations file for any other failing tests. | 9 2. Updates the generic TestExpectations file for any other failing tests. |
10 | 10 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 Args: | 264 Args: |
265 line_list: A list of lines to add to the TestExpectations file. | 265 line_list: A list of lines to add to the TestExpectations file. |
266 """ | 266 """ |
267 _log.debug('Lines to write to TestExpectations: %r', line_list) | 267 _log.debug('Lines to write to TestExpectations: %r', line_list) |
268 port = self.host.port_factory.get() | 268 port = self.host.port_factory.get() |
269 expectations_file_path = port.path_to_generic_test_expectations_file() | 269 expectations_file_path = port.path_to_generic_test_expectations_file() |
270 marker_comment = '# Tests added from W3C auto import bot' | 270 marker_comment = '# Tests added from W3C auto import bot' |
271 file_contents = self.host.filesystem.read_text_file(expectations_file_pa
th) | 271 file_contents = self.host.filesystem.read_text_file(expectations_file_pa
th) |
272 marker_comment_index = file_contents.find(marker_comment) | 272 marker_comment_index = file_contents.find(marker_comment) |
273 line_list = [line for line in line_list if self._test_name_from_expectat
ion_string(line) not in file_contents] | 273 line_list = [line for line in line_list if self._test_name_from_expectat
ion_string(line) not in file_contents] |
| 274 if not line_list: |
| 275 return |
274 if marker_comment_index == -1: | 276 if marker_comment_index == -1: |
275 file_contents += '\n%s\n' % marker_comment | 277 file_contents += '\n%s\n' % marker_comment |
276 file_contents += '\n'.join(line_list) | 278 file_contents += '\n'.join(line_list) |
277 else: | 279 else: |
278 end_of_marker_line = (file_contents[marker_comment_index:].find('\n'
)) + marker_comment_index | 280 end_of_marker_line = (file_contents[marker_comment_index:].find('\n'
)) + marker_comment_index |
279 file_contents = file_contents[:end_of_marker_line + 1] + '\n'.join(l
ine_list) + file_contents[end_of_marker_line:] | 281 file_contents = file_contents[:end_of_marker_line + 1] + '\n'.join(l
ine_list) + file_contents[end_of_marker_line:] |
280 self.host.filesystem.write_text_file(expectations_file_path, file_conten
ts) | 282 self.host.filesystem.write_text_file(expectations_file_path, file_conten
ts) |
281 | 283 |
282 @staticmethod | 284 @staticmethod |
283 def _test_name_from_expectation_string(expectation_string): | 285 def _test_name_from_expectation_string(expectation_string): |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 352 |
351 Args: | 353 Args: |
352 test_path: A file path relative to the layout tests directory. | 354 test_path: A file path relative to the layout tests directory. |
353 This might correspond to a deleted file or a non-test. | 355 This might correspond to a deleted file or a non-test. |
354 """ | 356 """ |
355 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir()
, test_path) | 357 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir()
, test_path) |
356 test_parser = TestParser(absolute_path, self.host) | 358 test_parser = TestParser(absolute_path, self.host) |
357 if not test_parser.test_doc: | 359 if not test_parser.test_doc: |
358 return False | 360 return False |
359 return test_parser.is_jstest() | 361 return test_parser.is_jstest() |
OLD | NEW |