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

Side by Side Diff: Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py

Issue 312103005: Minor cleanups to flakytests.py (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add newline at end of FlakyTests Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import flakytests
6
7 from webkitpy.common.checkout.scm.scm_mock import MockSCM
5 from webkitpy.tool.commands.commandtest import CommandsTest 8 from webkitpy.tool.commands.commandtest import CommandsTest
6 from webkitpy.tool.mocktool import MockTool, MockOptions 9 from webkitpy.tool.mocktool import MockTool, MockOptions
7 10
8 import flakytests
9
10 11
11 class FakeBotTestExpectations(object): 12 class FakeBotTestExpectations(object):
12 def expectation_lines(self, only_ignore_very_flaky=False): 13 def expectation_lines(self, only_ignore_very_flaky=False):
13 return [] 14 return []
14 15
15 16
16 class FakeBotTestExpectationsFactory(object): 17 class FakeBotTestExpectationsFactory(object):
17 def expectations_for_port(self, port_name): 18 def expectations_for_port(self, port_name):
18 return FakeBotTestExpectations() 19 return FakeBotTestExpectations()
19 20
20 21
22 class ChangedExpectationsMockSCM(MockSCM):
23 def changed_files(self):
24 return ['LayoutTests/FlakyTests']
25
26
21 class FlakyTestsTest(CommandsTest): 27 class FlakyTestsTest(CommandsTest):
22 def test_simple(self): 28 def test_simple(self):
23 command = flakytests.FlakyTests() 29 command = flakytests.FlakyTests()
24 factory = FakeBotTestExpectationsFactory() 30 factory = FakeBotTestExpectationsFactory()
25 lines = command._collect_expectation_lines(['foo'], factory) 31 lines = command._collect_expectation_lines(['foo'], factory)
26 self.assertEqual(lines, []) 32 self.assertEqual(lines, [])
27 33
28 def test_integration(self): 34 def test_integration(self):
29 command = flakytests.FlakyTests() 35 command = flakytests.FlakyTests()
36 tool = MockTool()
30 command.expectations_factory = FakeBotTestExpectationsFactory 37 command.expectations_factory = FakeBotTestExpectationsFactory
31 options = MockOptions(upload=True) 38 options = MockOptions(upload=True)
32 expected_stdout = """Updated /mock-checkout/third_party/WebKit/LayoutTes ts/FlakyTests 39 expected_stdout = """Updated /mock-checkout/third_party/WebKit/LayoutTes ts/FlakyTests
33 LayoutTests/FlakyTests is not changed, not uploading. 40 LayoutTests/FlakyTests is not changed, not uploading.
34 """ 41 """
35 self.assert_execute_outputs(command, options=options, expected_stdout=ex pected_stdout) 42 self.assert_execute_outputs(command, options=options, tool=tool, expecte d_stdout=expected_stdout)
43
44 expected_flaky_tests_content = '''# This file is generated by webkit-pat ch update-flaky-tests from the flakiness dashboard data.
45 # Manual changes will be overwritten.
46
47
48 '''
49 port = tool.port_factory.get()
50 self.assertEqual(tool.filesystem.read_text_file(tool.filesystem.join(por t.layout_tests_dir(), 'FlakyTests')), expected_flaky_tests_content)
51
52 def test_integration_uploads(self):
53 command = flakytests.FlakyTests()
54 tool = MockTool()
55 tool.scm = ChangedExpectationsMockSCM
56 command.expectations_factory = FakeBotTestExpectationsFactory
57 options = MockOptions(upload=True, reviewers='foo@chromium.org')
58 expected_stdout = """Updated /mock-checkout/third_party/WebKit/LayoutTes ts/FlakyTests
59 """
60 self.assert_execute_outputs(command, options=options, tool=tool, expecte d_stdout=expected_stdout)
61 self.assertEqual(tool.executive.calls,
62 [
63 ['git', 'commit', '-m', '''Update FlakyTests to match current fl akiness dashboard results
64
65 Automatically generated using:
66 webkit-patch update-flaky-tests
67
68 R=foo@chromium.org
69 ''', '/mock-checkout/third_party/WebKit/LayoutTests/FlakyTests'],
70 ['git', 'cl', 'upload', '--send-mail', '-f', '--cc', 'ojan@chrom ium.org,dpranke@chromium.org,eseidel@chromium.org'],
71 ])
72
73 expected_flaky_tests_content = '''# This file is generated by webkit-pat ch update-flaky-tests from the flakiness dashboard data.
74 # Manual changes will be overwritten.
75
76
77 '''
78 port = tool.port_factory.get()
79 self.assertEqual(tool.filesystem.read_text_file(tool.filesystem.join(por t.layout_tests_dir(), 'FlakyTests')), expected_flaky_tests_content)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698