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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/optimize_baselines_unittest.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/optimize_baselines_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/optimize_baselines_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..9242a8b277d60d1b6eec3b2e8bb5a09f5f3e625a
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/optimize_baselines_unittest.py
@@ -0,0 +1,80 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from webkitpy.common.system.outputcapture import OutputCapture
+from webkitpy.tool.commands.optimize_baselines import OptimizeBaselines
+from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase
+from webkitpy.tool.mock_tool import MockOptions
+
+
+class TestOptimizeBaselines(BaseTestCase):
+ command_constructor = OptimizeBaselines
+
+ def _write_test_file(self, port, path, contents):
+ abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path)
+ self.tool.filesystem.write_text_file(abs_path, contents)
+
+ def setUp(self):
+ super(TestOptimizeBaselines, self).setUp()
+
+ def test_modify_scm(self):
+ test_port = self.tool.port_factory.get('test')
+ self._write_test_file(test_port, 'another/test.html', "Dummy test contents")
+ self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/test-expected.txt', "result A")
+ self._write_test_file(test_port, 'another/test-expected.txt', "result A")
+
+ OutputCapture().assert_outputs(self, self.command.execute, args=[
+ MockOptions(suffixes='txt', no_modify_scm=False, platform='test-mac-mac10.10'),
+ ['another/test.html'],
+ self.tool,
+ ], expected_stdout='{"add": [], "remove-lines": [], "delete": []}\n')
+
+ self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'platform/test-mac-mac10.10/another/test-expected.txt')))
+ self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'another/test-expected.txt')))
+
+ def test_no_modify_scm(self):
+ test_port = self.tool.port_factory.get('test')
+ self._write_test_file(test_port, 'another/test.html', "Dummy test contents")
+ self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/test-expected.txt', "result A")
+ self._write_test_file(test_port, 'another/test-expected.txt', "result A")
+
+ OutputCapture().assert_outputs(self, self.command.execute, args=[
+ MockOptions(suffixes='txt', no_modify_scm=True, platform='test-mac-mac10.10'),
+ ['another/test.html'],
+ self.tool,
+ ], expected_stdout='{"add": [], "remove-lines": [], "delete": ["/test.checkout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.txt"]}\n')
+
+ self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'platform/mac/another/test-expected.txt')))
+ self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'another/test-expected.txt')))
+
+ def test_optimize_all_suffixes_by_default(self):
+ test_port = self.tool.port_factory.get('test')
+ self._write_test_file(test_port, 'another/test.html', "Dummy test contents")
+ self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/test-expected.txt', "result A")
+ self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/test-expected.png', "result A png")
+ self._write_test_file(test_port, 'another/test-expected.txt', "result A")
+ self._write_test_file(test_port, 'another/test-expected.png', "result A png")
+
+ try:
+ oc = OutputCapture()
+ oc.capture_output()
+ self.command.execute(MockOptions(suffixes='txt,wav,png', no_modify_scm=True, platform='test-mac-mac10.10'),
+ ['another/test.html'],
+ self.tool)
+ finally:
+ out, _, _ = oc.restore_output()
+
+ self.assertEquals(out, '{"add": [], "remove-lines": [], "delete": ["/test.checkout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.txt", "/test.checkout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.png"]}\n')
+ self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'platform/mac/another/test-expected.txt')))
+ self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'platform/mac/another/test-expected.png')))
+ self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'another/test-expected.txt')))
+ self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join(
+ test_port.layout_tests_dir(), 'another/test-expected.png')))

Powered by Google App Engine
This is Rietveld 408576698