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

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

Issue 2128233003: Split out optimize-baselines command from rebaseline.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 from webkitpy.common.system.outputcapture import OutputCapture
6 from webkitpy.tool.commands.optimize_baselines import OptimizeBaselines
7 from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase
8 from webkitpy.tool.mock_tool import MockOptions
9
10
11 class TestOptimizeBaselines(BaseTestCase):
12 command_constructor = OptimizeBaselines
13
14 def _write_test_file(self, port, path, contents):
15 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path)
16 self.tool.filesystem.write_text_file(abs_path, contents)
17
18 def setUp(self):
19 super(TestOptimizeBaselines, self).setUp()
20
21 def test_modify_scm(self):
22 test_port = self.tool.port_factory.get('test')
23 self._write_test_file(test_port, 'another/test.html', "Dummy test conten ts")
24 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes t-expected.txt', "result A")
25 self._write_test_file(test_port, 'another/test-expected.txt', "result A" )
26
27 OutputCapture().assert_outputs(self, self.command.execute, args=[
28 MockOptions(suffixes='txt', no_modify_scm=False, platform='test-mac- mac10.10'),
29 ['another/test.html'],
30 self.tool,
31 ], expected_stdout='{"add": [], "remove-lines": [], "delete": []}\n')
32
33 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
34 test_port.layout_tests_dir(), 'platform/test-mac-mac10.10/another/te st-expected.txt')))
35 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
36 test_port.layout_tests_dir(), 'another/test-expected.txt')))
37
38 def test_no_modify_scm(self):
39 test_port = self.tool.port_factory.get('test')
40 self._write_test_file(test_port, 'another/test.html', "Dummy test conten ts")
41 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes t-expected.txt', "result A")
42 self._write_test_file(test_port, 'another/test-expected.txt', "result A" )
43
44 OutputCapture().assert_outputs(self, self.command.execute, args=[
45 MockOptions(suffixes='txt', no_modify_scm=True, platform='test-mac-m ac10.10'),
46 ['another/test.html'],
47 self.tool,
48 ], expected_stdout='{"add": [], "remove-lines": [], "delete": ["/test.ch eckout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.txt"]}\n')
49
50 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
51 test_port.layout_tests_dir(), 'platform/mac/another/test-expected.tx t')))
52 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
53 test_port.layout_tests_dir(), 'another/test-expected.txt')))
54
55 def test_optimize_all_suffixes_by_default(self):
56 test_port = self.tool.port_factory.get('test')
57 self._write_test_file(test_port, 'another/test.html', "Dummy test conten ts")
58 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes t-expected.txt', "result A")
59 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes t-expected.png', "result A png")
60 self._write_test_file(test_port, 'another/test-expected.txt', "result A" )
61 self._write_test_file(test_port, 'another/test-expected.png', "result A png")
62
63 try:
64 oc = OutputCapture()
65 oc.capture_output()
66 self.command.execute(MockOptions(suffixes='txt,wav,png', no_modify_s cm=True, platform='test-mac-mac10.10'),
67 ['another/test.html'],
68 self.tool)
69 finally:
70 out, _, _ = oc.restore_output()
71
72 self.assertEquals(out, '{"add": [], "remove-lines": [], "delete": ["/tes t.checkout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.txt", "/ test.checkout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.png"] }\n')
73 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
74 test_port.layout_tests_dir(), 'platform/mac/another/test-expected.tx t')))
75 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
76 test_port.layout_tests_dir(), 'platform/mac/another/test-expected.pn g')))
77 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
78 test_port.layout_tests_dir(), 'another/test-expected.txt')))
79 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
80 test_port.layout_tests_dir(), 'another/test-expected.png')))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698