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

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: Create the harness and shell of update_test_expectations 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
qyearsley 2016/07/06 23:18:04 Nit: This blank line could be removed.
bokan 2016/07/07 22:08:32 Done.
25 """
26
27 import argparse
28 import logging
29
30 from webkitpy.layout_tests.models.test_expectations import TestExpectations
31
32 _log = logging.getLogger(__name__)
33
34
35 def main(host, bot_test_expectations_factory, argv):
36 parser = argparse.ArgumentParser(epilog=__doc__, formatter_class=argparse.Ra wTextHelpFormatter)
37 parser.parse_args(argv)
qyearsley 2016/07/06 23:18:04 What args will this take? Later will you want to c
bokan 2016/07/07 22:08:31 None at the moment, I added this to get --help, bu
38
39 port = host.port_factory.get()
40
41 logging.basicConfig(level=logging.INFO, format="%(message)s")
42
43 expectations_file = port.path_to_generic_test_expectations_file()
44 if not host.filesystem.isfile(expectations_file):
45 _log.warn("Didn't find generic expectations file at: " + expectations_fi le)
46 return None
qyearsley 2016/07/06 23:18:04 Nit, also could just `return` instead of `return N
bokan 2016/07/07 22:08:31 Done, used #1
47
48 remove_flakes_o_matic = RemoveFlakesOMatic(host,
49 port,
50 bot_test_expectations_factory)
51
52 test_expectations = remove_flakes_o_matic.get_updated_test_expectations()
53
54 remove_flakes_o_matic.write_test_expectations(test_expectations,
55 expectations_file)
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 TestExpectatoins file and, using results from the
Dirk Pranke 2016/07/06 21:51:44 Typo: "TestExpectations".
bokan 2016/07/07 22:08:31 Done.
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: A TestExpectations object with the passing lines filtered out.
qyearsley 2016/07/06 23:18:04 Nit: this could be formatted as: Returns:
bokan 2016/07/07 22:08:31 Done.
73 """
74 test_expectations = TestExpectations(self._port, include_overrides=False ).expectations()
75 # TODO: Filter the expectations based on results.
76 return test_expectations
77
78 def write_test_expectations(self, test_expectations, test_expectations_file) :
79 """Writes the given TestExpectations object to the filesystem.
80
81 Args:
82 test_expectatoins: The TestExpectations object to write.
Dirk Pranke 2016/07/06 21:51:44 ditto.
bokan 2016/07/07 22:08:31 Done.
83 test_expectations_file: The full file path of the Blink
84 TestExpectations file. This file will be overwritten.
85 """
86 self._host.filesystem.write_text_file(
87 test_expectations_file,
88 TestExpectations.list_to_string(test_expectations, reconstitute_only _these=[]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698