Exemple #1
0
 def update_test_expectations(self, deleted_tests, renamed_tests):
     """Updates the TestExpectations file entries for tests that have been deleted or renamed."""
     port = self.host.port_factory.get()
     test_expectations = TestExpectations(port, include_overrides=False)
     # Tests for which files don't exist aren't stored in TestExpectationsModel,
     # so methods like TestExpectations.remove_expectation_line don't work; instead
     # we can run through the TestExpectationLine objects that were parsed.
     # FIXME: This won't work for removed or renamed directories with test expectations
     # that are directories rather than individual tests.
     new_lines = []
     changed_lines = []
     for expectation_line in test_expectations.expectations():
         if expectation_line.name in deleted_tests:
             continue
         if expectation_line.name in renamed_tests:
             expectation_line.name = renamed_tests[expectation_line.name]
             # Upon parsing the file, a "path does not exist" warning is expected
             # to be there for tests that have been renamed, and if there are warnings,
             # then the original string is used. If the warnings are reset, then the
             # expectation line is re-serialized when output.
             expectation_line.warnings = []
             changed_lines.append(expectation_line)
         new_lines.append(expectation_line)
     self.host.filesystem.write_text_file(
         port.path_to_generic_test_expectations_file(),
         TestExpectations.list_to_string(
             new_lines, reconstitute_only_these=changed_lines))