| 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 4535316c2a0a2c312697e65dde96a3202ce990a5..9810f24ee3e3528b37e594029e947d3911f013a7 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")
|
| @@ -46,10 +53,14 @@ def main(host, bot_test_expectations_factory, argv):
|
|
|
| remove_flakes_o_matic = RemoveFlakesOMatic(host,
|
| port,
|
| - bot_test_expectations_factory)
|
| + bot_test_expectations_factory,
|
| + webbrowser)
|
|
|
| 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
|
| @@ -57,11 +68,13 @@ def main(host, bot_test_expectations_factory, argv):
|
|
|
| class RemoveFlakesOMatic(object):
|
|
|
| - def __init__(self, host, port, bot_test_expectations_factory):
|
| + def __init__(self, host, port, bot_test_expectations_factory, browser):
|
| self._host = host
|
| self._port = port
|
| self._expectations_factory = bot_test_expectations_factory
|
| self._builder_results_by_path = {}
|
| + self._browser = browser
|
| + self._expectations_to_remove_list = None
|
|
|
| def _can_delete_line(self, test_expectation_line):
|
| """Returns whether a given line in the expectations can be removed.
|
| @@ -255,6 +268,25 @@ class RemoveFlakesOMatic(object):
|
| removed_index -= 1
|
| expectations.pop(removed_index)
|
|
|
| + def _expectations_to_remove(self):
|
| + """Computes and returns the expectation lines that should be removed.
|
| +
|
| + returns a list of TestExpectationLines that can be removed from the test expectations
|
| + file. The result is memoized so that subsequent calls will not recompute the result.
|
| + """
|
| + if self._expectations_to_remove_list is not None:
|
| + return self._expectations_to_remove_list
|
| +
|
| + self._builder_results_by_path = self._get_builder_results_by_path()
|
| + self._expectations_to_remove_list = []
|
| + test_expectations = TestExpectations(self._port, include_overrides=False).expectations()
|
| +
|
| + for expectation in test_expectations:
|
| + if self._can_delete_line(expectation):
|
| + self._expectations_to_remove_list.append(expectation)
|
| +
|
| + return self._expectations_to_remove_list
|
| +
|
| def get_updated_test_expectations(self):
|
| """Filters out passing lines from TestExpectations file.
|
|
|
| @@ -266,16 +298,8 @@ class RemoveFlakesOMatic(object):
|
| A TestExpectations object with the passing lines filtered out.
|
| """
|
|
|
| - 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 +310,19 @@ 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.
|
| + """
|
| + 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)
|
| + self._browser.open(url)
|
| +
|
| def write_test_expectations(self, test_expectations, test_expectations_file):
|
| """Writes the given TestExpectations object to the filesystem.
|
|
|
|
|