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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py

Issue 1939843002: Replace webkitpy standalone builders functions with instantiable class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved builders out of port, updated comment Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py
index 77268e8b280fdb59013f463261fee9f255084120..c251b78f1c1e8faa94fcc9ced17152abf766fe62 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py
@@ -6,11 +6,21 @@ import flakytests
from webkitpy.common.checkout.scm.scm_mock import MockSCM
from webkitpy.layout_tests.layout_package import bot_test_expectations
-from webkitpy.layout_tests.port import builders
+from webkitpy.layout_tests.builders import Builders
from webkitpy.tool.commands.commandtest import CommandsTest
from webkitpy.tool.mocktool import MockTool, MockOptions
+class FakeBuilders(Builders):
+
+ def __init__(self):
+ super(FakeBuilders, self).__init__()
+ self._exact_matches = {
+ "foo-builder": {"port_name": "dummy-port", "specifiers": ['Linux', 'Release']},
+ "bar-builder": {"port_name": "dummy-port", "specifiers": ['Mac', 'Debug']},
+ }
+
+
class FakeBotTestExpectations(object):
def expectation_lines(self, only_ignore_very_flaky=False):
@@ -22,13 +32,16 @@ class FakeBotTestExpectationsFactory(object):
"N": "NO DATA", "P": "PASS", "T": "TIMEOUT", "Y": "NOTRUN", "X": "SKIP",
"Z": "IMAGE+TEXT", "K": "LEAK"}
+ def __init__(self, builders):
+ self.builders = builders
+
def _expectations_from_test_data(self, builder, test_data):
test_data[bot_test_expectations.ResultsJSON.FAILURE_MAP_KEY] = self.FAILURE_MAP
json_dict = {
builder: test_data,
}
results = bot_test_expectations.ResultsJSON(builder, json_dict)
- return bot_test_expectations.BotTestExpectations(results, builders._exact_matches[builder]["specifiers"])
+ return bot_test_expectations.BotTestExpectations(results, self.builders, self.builders._exact_matches[builder]["specifiers"])
def expectations_for_builder(self, builder):
if builder == 'foo-builder':
@@ -52,25 +65,17 @@ class FlakyTestsTest(CommandsTest):
def test_merge_lines(self):
command = flakytests.FlakyTests()
- factory = FakeBotTestExpectationsFactory()
-
- old_builders = builders._exact_matches
- builders._exact_matches = {
- "foo-builder": {"port_name": "dummy-port", "specifiers": ['Linux', 'Release']},
- "bar-builder": {"port_name": "dummy-port", "specifiers": ['Mac', 'Debug']},
- }
+ factory = FakeBotTestExpectationsFactory(FakeBuilders())
- try:
- lines = command._collect_expectation_lines(['foo-builder', 'bar-builder'], factory)
- self.assertEqual(len(lines), 1)
- self.assertEqual(lines[0].expectations, ['TEXT', 'TIMEOUT', 'PASS'])
- self.assertEqual(lines[0].specifiers, ['Mac', 'Linux'])
- finally:
- builders._exact_matches = old_builders
+ lines = command._collect_expectation_lines(['foo-builder', 'bar-builder'], factory)
+ self.assertEqual(len(lines), 1)
+ self.assertEqual(lines[0].expectations, ['TEXT', 'TIMEOUT', 'PASS'])
+ self.assertEqual(lines[0].specifiers, ['Mac', 'Linux'])
def test_integration(self):
command = flakytests.FlakyTests()
tool = MockTool()
+ tool.builders = FakeBuilders()
command.expectations_factory = FakeBotTestExpectationsFactory
options = MockOptions(upload=True)
expected_stdout = flakytests.FlakyTests.OUTPUT % (

Powered by Google App Engine
This is Rietveld 408576698