OLD | NEW |
---|---|
1 # Copyright (c) 2011 Google Inc. All rights reserved. | 1 # Copyright (c) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 14 matching lines...) Expand all Loading... | |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand | 29 from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand |
30 from webkitpy.layout_tests.layout_package.bot_test_expectations import BotTestEx pectationsFactory | 30 from webkitpy.layout_tests.layout_package.bot_test_expectations import BotTestEx pectationsFactory |
31 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser , TestExpectationsModel, TestExpectations | 31 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser , TestExpectationsModel, TestExpectations |
32 | 32 |
33 | 33 |
34 class FlakyTests(AbstractDeclarativeCommand): | 34 class FlakyTests(AbstractDeclarativeCommand): |
35 name = "flaky-tests" | 35 name = "update-flaky-tests" |
36 help_text = "Generate FlakyTests file from the flakiness dashboard" | 36 help_text = "Update FlakyTests file from the flakiness dashboard" |
37 show_in_main_help = True | 37 show_in_main_help = True |
38 | 38 |
39 def execute(self, options, args, tool): | 39 def execute(self, options, args, tool): |
40 port = tool.port_factory.get() | 40 port = tool.port_factory.get() |
41 full_port_name = port.determine_full_port_name(tool, options, port.port_ name) | 41 current_expectations = TestExpectations(port, include_overrides=False, m odel_all_expectations=True) |
42 expectations = BotTestExpectationsFactory().expectations_for_port(full_p ort_name) | 42 model = TestExpectationsModel() |
43 print TestExpectations.list_to_string(expectations.expectation_lines()) | 43 for port_name in tool.port_factory.all_port_names(): |
44 expectations = BotTestExpectationsFactory().expectations_for_port(po rt_name) | |
45 for line in expectations.expectation_lines(only_ignore_very_flaky=Tr ue): | |
46 model.add_expectation_line(line) | |
47 # FIXME: We need an official API to get all the test names or all test l ines. | |
48 lines = model._test_to_expectation_line.values() | |
49 lines.sort(key=lambda line: line.path) | |
50 # This is a hack, but prevents duplicates with existing TestExpectations | |
51 # (which would cause lint-test-expectations to fail). A better solution | |
52 # would be to update 'current_expectations' with the new data and | |
53 # write out the whole TestExpectations file. | |
54 # lines = filter(lambda line: not current_expectations.model().has_test( line.name), lines) | |
ojan
2014/05/29 21:53:03
Why leave in this comment + the commented out code
| |
55 # Skip any tests which are mentioned in the dashboard but not in our che ckout: | |
56 fs = tool.filesystem | |
57 lines = filter(lambda line: fs.exists(fs.join(port.layout_tests_dir(), l ine.path)), lines) | |
58 flaky_tests_path = fs.join(port.layout_tests_dir(), 'FlakyTests') | |
59 with open(flaky_tests_path, 'w') as flake_file: | |
60 flake_file.write(TestExpectations.list_to_string(lines)) | |
OLD | NEW |