Chromium Code Reviews| Index: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_test_expectations.py |
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_test_expectations.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_test_expectations.py |
| index 442c851d781ecab4c2c2122283b54620d8a6ebcd..3ba0bb760c12eedf381edfdb87b22452ac55007c 100644 |
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_test_expectations.py |
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_test_expectations.py |
| @@ -25,8 +25,10 @@ will be removed since there's no Crash results. |
| import argparse |
| import logging |
| +import webbrowser |
| from webkitpy.layout_tests.models.test_expectations import TestExpectations |
| +from webkitpy.tool.commands.flaky_tests import FlakyTests |
| _log = logging.getLogger(__name__) |
| @@ -34,6 +36,11 @@ _log = logging.getLogger(__name__) |
| def main(host, bot_test_expectations_factory, argv): |
| parser = argparse.ArgumentParser(epilog=__doc__, formatter_class=argparse.RawTextHelpFormatter) |
| parser.add_argument('--verbose', '-v', action='store_true', default=False, help='enable more verbose logging') |
| + parser.add_argument('--show-results', |
| + '-s', |
| + action='store_true', |
| + default=False, |
| + help='Open results dashboard for all removed lines') |
| args = parser.parse_args(argv) |
| logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO, format="%(levelname)s: %(message)s") |
| @@ -50,6 +57,9 @@ def main(host, bot_test_expectations_factory, argv): |
| test_expectations = remove_flakes_o_matic.get_updated_test_expectations() |
| + if args.show_results: |
| + remove_flakes_o_matic.show_removed_results() |
| + |
| remove_flakes_o_matic.write_test_expectations(test_expectations, |
| expectations_file) |
| return 0 |
| @@ -62,6 +72,7 @@ class RemoveFlakesOMatic(object): |
| self._port = port |
| self._expectations_factory = bot_test_expectations_factory |
| self._builder_results_by_path = {} |
| + self._expectations_to_remove = None |
| def _can_delete_line(self, test_expectation_line): |
| """Returns whether a given line in the expectations can be removed. |
| @@ -255,6 +266,25 @@ class RemoveFlakesOMatic(object): |
| removed_index -= 1 |
| expectations.pop(removed_index) |
| + def _ensure_expectations_to_remove(self): |
| + """Ensures the _expectations_to_remove member is filled in. |
| + |
| + This member starts uninitialized. Several public methods need this member to be filled in to |
| + operate but we don't want to build it multiple times and using the constructor would make |
| + testing inconvenient. Instead, each calls this method which early-outs if the work has |
| + already been done. |
| + """ |
| + if self._expectations_to_remove is not None: |
| + return |
|
qyearsley
2016/10/05 21:06:08
Another possible approach to consider here may be
bokan
2016/10/05 22:35:24
Done.
|
| + |
| + self._builder_results_by_path = self._get_builder_results_by_path() |
| + self._expectations_to_remove = [] |
| + test_expectations = TestExpectations(self._port, include_overrides=False).expectations() |
| + |
| + for expectation in test_expectations: |
| + if self._can_delete_line(expectation): |
| + self._expectations_to_remove.append(expectation) |
| + |
| def get_updated_test_expectations(self): |
| """Filters out passing lines from TestExpectations file. |
| @@ -265,17 +295,10 @@ class RemoveFlakesOMatic(object): |
| Returns: |
| A TestExpectations object with the passing lines filtered out. |
| """ |
| + self._ensure_expectations_to_remove() |
| - self._builder_results_by_path = self._get_builder_results_by_path() |
| - |
| - expectations_to_remove = [] |
| test_expectations = TestExpectations(self._port, include_overrides=False).expectations() |
| - |
| - for expectation in test_expectations: |
| - if self._can_delete_line(expectation): |
| - expectations_to_remove.append(expectation) |
| - |
| - for expectation in expectations_to_remove: |
| + for expectation in self._expectations_to_remove: |
| index = test_expectations.index(expectation) |
| test_expectations.remove(expectation) |
| @@ -286,6 +309,20 @@ class RemoveFlakesOMatic(object): |
| return test_expectations |
| + def show_removed_results(self): |
| + """Opens removed lines in the results dashboard. |
| + |
| + Opens the results dashboard in the browser, showing all the tests for lines that the script |
| + removed from the TestExpectations file and allowing the user to manually confirm the |
| + results. |
| + """ |
| + self._ensure_expectations_to_remove() |
| + removed_test_names = ','.join(x.name for x in self._expectations_to_remove) |
| + url = FlakyTests.FLAKINESS_DASHBOARD_URL % removed_test_names |
| + |
| + _log.info('Opening results dashboard: ' + url) |
| + webbrowser.open(url) |
| + |
| def write_test_expectations(self, test_expectations, test_expectations_file): |
| """Writes the given TestExpectations object to the filesystem. |