Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/update_test_expectations.py

Issue 2119303003: Create the harness and shell of update_test_expectations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@updateTestExpectations1
Patch Set: Addressed Quinten's comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Updates TestExpectations based on results in builder bots.
6
7 Scans the TestExpectations file and uses results from actual builder bots runs
8 to remove tests that are marked as flaky but don't fail in the specified way.
9
10 E.g. If a test has this expectation:
11 bug(test) fast/test.html [ Failure Pass ]
12
13 And all the runs on builders have passed the line will be removed.
14
15 Additionally, the runs don't all have to be Passing to remove the line;
16 as long as the non-Passing results are of a type not specified in the
17 expectation this line will be removed. For example, if this is the
18 expectation:
19
20 bug(test) fast/test.html [ Crash Pass ]
21
22 But the results on the builders show only Passes and Timeouts, the line
23 will be removed since there's no Crash results.
24 """
25
26 import argparse
27 import logging
28
29 from webkitpy.layout_tests.models.test_expectations import TestExpectations
30
31 _log = logging.getLogger(__name__)
32
33
34 def main(host, bot_test_expectations_factory, argv):
35 parser = argparse.ArgumentParser(epilog=__doc__, formatter_class=argparse.Ra wTextHelpFormatter)
36 parser.parse_args(argv)
37
38 port = host.port_factory.get()
39
40 logging.basicConfig(level=logging.INFO, format="%(message)s")
41
42 expectations_file = port.path_to_generic_test_expectations_file()
43 if not host.filesystem.isfile(expectations_file):
44 _log.warn("Didn't find generic expectations file at: " + expectations_fi le)
45 return 1
46
47 remove_flakes_o_matic = RemoveFlakesOMatic(host,
48 port,
49 bot_test_expectations_factory)
50
51 test_expectations = remove_flakes_o_matic.get_updated_test_expectations()
52
53 remove_flakes_o_matic.write_test_expectations(test_expectations,
54 expectations_file)
55 return 0
56
57
58 class RemoveFlakesOMatic(object):
59 def __init__(self, host, port, bot_test_expectations_factory):
60 self._host = host
61 self._port = port
62 self._expectations_factory = bot_test_expectations_factory
63 self.builder_results_by_path = {}
64
65 def get_updated_test_expectations(self):
66 """Filters out passing lines from TestExpectations file.
67
68 Reads the current TestExpectations file and, using results from the
69 build bots, removes lines that are passing. That is, removes lines that
70 were not needed to keep the bots green.
71
72 Returns:
73 A TestExpectations object with the passing lines filtered out.
74 """
75 test_expectations = TestExpectations(self._port, include_overrides=False ).expectations()
76 # TODO: Filter the expectations based on results.
77 return test_expectations
78
79 def write_test_expectations(self, test_expectations, test_expectations_file) :
80 """Writes the given TestExpectations object to the filesystem.
81
82 Args:
83 test_expectations: The TestExpectations object to write.
84 test_expectations_file: The full file path of the Blink
85 TestExpectations file. This file will be overwritten.
86 """
87 self._host.filesystem.write_text_file(
88 test_expectations_file,
89 TestExpectations.list_to_string(test_expectations, reconstitute_only _these=[]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698