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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py

Issue 2347643002: Refactor the way that SCM changes are tracked and aggregated in rebaseline.py. (Closed)
Patch Set: Refactor the way that SCM changes are tracked and aggregated. Created 4 years, 3 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
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 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 optparse 5 import optparse
6 import unittest 6 import unittest
7 7
8 from webkitpy.common.net.buildbot import Build 8 from webkitpy.common.net.buildbot import Build
9 from webkitpy.common.net.layouttestresults import LayoutTestResults 9 from webkitpy.common.net.layouttestresults import LayoutTestResults
10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2
11 from webkitpy.common.system.outputcapture import OutputCapture 11 from webkitpy.common.system.outputcapture import OutputCapture
12 from webkitpy.layout_tests.builder_list import BuilderList 12 from webkitpy.layout_tests.builder_list import BuilderList
13 from webkitpy.tool.commands.rebaseline import ( 13 from webkitpy.tool.commands.rebaseline import (
14 AbstractParallelRebaselineCommand, CopyExistingBaselinesInternal, 14 AbstractParallelRebaselineCommand, CopyExistingBaselinesInternal,
15 Rebaseline, RebaselineExpectations, RebaselineJson, RebaselineTest 15 Rebaseline, RebaselineExpectations, RebaselineJson, RebaselineTest, ChangeSe t
16 ) 16 )
17 from webkitpy.tool.mock_tool import MockWebKitPatch 17 from webkitpy.tool.mock_tool import MockWebKitPatch
18 18
19 19
20 # pylint: disable=protected-access 20 # pylint: disable=protected-access
21 class BaseTestCase(unittest.TestCase): 21 class BaseTestCase(unittest.TestCase):
22 MOCK_WEB_RESULT = 'MOCK Web result, convert 404 to None=True' 22 MOCK_WEB_RESULT = 'MOCK Web result, convert 404 to None=True'
23 WEB_PREFIX = 'https://storage.googleapis.com/chromium-layout-test-archives/M OCK_Mac10_11/results/layout-test-results' 23 WEB_PREFIX = 'https://storage.googleapis.com/chromium-layout-test-archives/M OCK_Mac10_11/results/layout-test-results'
24 24
25 command_constructor = None 25 command_constructor = None
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 "bug(z) [ Linux ] userscripts/another-test.html [ Failure ]\n")) 313 "bug(z) [ Linux ] userscripts/another-test.html [ Failure ]\n"))
314 self.command._rebaseline_test_and_update_expectations(self.options(resul ts_directory='/tmp')) 314 self.command._rebaseline_test_and_update_expectations(self.options(resul ts_directory='/tmp'))
315 self.assertItemsEqual(self.tool.web.urls_fetched, ['file:///tmp/userscri pts/another-test-actual.txt']) 315 self.assertItemsEqual(self.tool.web.urls_fetched, ['file:///tmp/userscri pts/another-test-actual.txt'])
316 316
317 def test_rebaseline_reftest(self): 317 def test_rebaseline_reftest(self):
318 self._write("userscripts/another-test.html", "test data") 318 self._write("userscripts/another-test.html", "test data")
319 self._write("userscripts/another-test-expected.html", "generic result") 319 self._write("userscripts/another-test-expected.html", "generic result")
320 OutputCapture().assert_outputs( 320 OutputCapture().assert_outputs(
321 self, self.command._rebaseline_test_and_update_expectations, args=[s elf.options(suffixes='png')], 321 self, self.command._rebaseline_test_and_update_expectations, args=[s elf.options(suffixes='png')],
322 expected_logs="Cannot rebaseline image result for reftest: userscrip ts/another-test.html\n") 322 expected_logs="Cannot rebaseline image result for reftest: userscrip ts/another-test.html\n")
323 self.assertDictEqual(self.command._scm_changes, {'add': [], 'remove-line s': [], "delete": []}) 323 self.assertDictEqual(self.command._scm_changes.to_dict(), {'add': [], 'r emove-lines': [], "delete": []})
324 324
325 def test_rebaseline_test_and_print_scm_changes(self): 325 def test_rebaseline_test_and_print_scm_changes(self):
326 self.command._print_scm_changes = True 326 self.command._print_scm_changes = True
327 self.command._scm_changes = {'add': [], 'delete': []} 327 self.command._scm_changes = ChangeSet()
328 self.tool._scm.exists = lambda x: False 328 self.tool._scm.exists = lambda x: False
329 329
330 self.command._rebaseline_test("MOCK Trusty", "userscripts/another-test.h tml", "txt", None) 330 self.command._rebaseline_test("MOCK Trusty", "userscripts/another-test.h tml", "txt", None)
331 331
332 self.assertDictEqual(self.command._scm_changes, { 332 self.assertDictEqual(
333 'add': ['/test.checkout/LayoutTests/platform/test-linux-trusty/users cripts/another-test-expected.txt'], 333 self.command._scm_changes.to_dict(),
334 'delete': [] 334 {
335 }) 335 'add': ['/test.checkout/LayoutTests/platform/test-linux-trusty/u serscripts/another-test-expected.txt'],
336 'delete': [],
337 'remove-lines': []
338 })
336 339
337 def test_rebaseline_test_internal_with_port_that_lacks_buildbot(self): 340 def test_rebaseline_test_internal_with_port_that_lacks_buildbot(self):
338 self.tool.executive = MockExecutive2() 341 self.tool.executive = MockExecutive2()
339 342
340 port = self.tool.port_factory.get('test-win-win7') 343 port = self.tool.port_factory.get('test-win-win7')
341 self._write(port._filesystem.join(port.layout_tests_dir(), 344 self._write(port._filesystem.join(port.layout_tests_dir(),
342 'platform/test-win-win10/failures/expe cted/image-expected.txt'), 'original win10 result') 345 'platform/test-win-win10/failures/expe cted/image-expected.txt'), 'original win10 result')
343 346
344 oc = OutputCapture() 347 oc = OutputCapture()
345 try: 348 try:
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 for cmd_line, cwd in commands: 927 for cmd_line, cwd in commands:
925 out = self.run_command(cmd_line, cwd=cwd) 928 out = self.run_command(cmd_line, cwd=cwd)
926 if 'rebaseline-test-internal' in cmd_line: 929 if 'rebaseline-test-internal' in cmd_line:
927 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "% s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6]) 930 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "% s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6])
928 command_outputs.append([0, out, '']) 931 command_outputs.append([0, out, ''])
929 932
930 new_calls = self.calls[num_previous_calls:] 933 new_calls = self.calls[num_previous_calls:]
931 self.calls = self.calls[:num_previous_calls] 934 self.calls = self.calls[:num_previous_calls]
932 self.calls.append(new_calls) 935 self.calls.append(new_calls)
933 return command_outputs 936 return command_outputs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698