| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import unittest | 29 import unittest |
| 30 | 30 |
| 31 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer | 31 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer |
| 32 from webkitpy.common.host_mock import MockHost | 32 from webkitpy.common.host_mock import MockHost |
| 33 from webkitpy.common.webkit_finder import WebKitFinder | 33 from webkitpy.common.blink_finder import BlinkFinder |
| 34 | 34 |
| 35 | 35 |
| 36 class BaselineOptimizerTest(unittest.TestCase): | 36 class BaselineOptimizerTest(unittest.TestCase): |
| 37 | 37 |
| 38 # Protected method _move_baselines is tested below - pylint: disable=protect
ed-access | 38 # Protected method _move_baselines is tested below - pylint: disable=protect
ed-access |
| 39 def test_move_baselines(self): | 39 def test_move_baselines(self): |
| 40 host = MockHost() | 40 host = MockHost() |
| 41 host.filesystem.write_text_file('/mock-checkout/third_party/WebKit/Layou
tTests/VirtualTestSuites', '[]') | 41 host.filesystem.write_text_file('/mock-checkout/third_party/WebKit/Layou
tTests/VirtualTestSuites', '[]') |
| 42 host.filesystem.write_binary_file( | 42 host.filesystem.write_binary_file( |
| 43 '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/another/
test-expected.txt', 'result A') | 43 '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/another/
test-expected.txt', 'result A') |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 self.assertEqual( | 83 self.assertEqual( |
| 84 host.filesystem.read_binary_file( | 84 host.filesystem.read_binary_file( |
| 85 '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expe
cted.txt'), | 85 '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expe
cted.txt'), |
| 86 'result A') | 86 'result A') |
| 87 | 87 |
| 88 def _assertOptimization(self, results_by_directory, expected_new_results_by_
directory, | 88 def _assertOptimization(self, results_by_directory, expected_new_results_by_
directory, |
| 89 baseline_dirname='', host=None): | 89 baseline_dirname='', host=None): |
| 90 if not host: | 90 if not host: |
| 91 host = MockHost() | 91 host = MockHost() |
| 92 fs = host.filesystem | 92 fs = host.filesystem |
| 93 webkit_base = WebKitFinder(fs).webkit_base() | 93 blink_base = BlinkFinder(fs).blink_base() |
| 94 baseline_name = 'mock-baseline-expected.txt' | 94 baseline_name = 'mock-baseline-expected.txt' |
| 95 fs.write_text_file(fs.join(webkit_base, 'LayoutTests', 'VirtualTestSuite
s'), | 95 fs.write_text_file(fs.join(blink_base, 'LayoutTests', 'VirtualTestSuites
'), |
| 96 '[{"prefix": "gpu", "base": "fast/canvas", "args": ["
--foo"]}]') | 96 '[{"prefix": "gpu", "base": "fast/canvas", "args": ["
--foo"]}]') |
| 97 | 97 |
| 98 for dirname, contents in results_by_directory.items(): | 98 for dirname, contents in results_by_directory.items(): |
| 99 path = fs.join(webkit_base, 'LayoutTests', dirname, baseline_name) | 99 path = fs.join(blink_base, 'LayoutTests', dirname, baseline_name) |
| 100 fs.write_binary_file(path, contents) | 100 fs.write_binary_file(path, contents) |
| 101 | 101 |
| 102 baseline_optimizer = BaselineOptimizer(host, host.port_factory.get( | 102 baseline_optimizer = BaselineOptimizer(host, host.port_factory.get( |
| 103 ), host.port_factory.all_port_names()) | 103 ), host.port_factory.all_port_names()) |
| 104 self.assertTrue(baseline_optimizer.optimize(fs.join(baseline_dirname, ba
seline_name))) | 104 self.assertTrue(baseline_optimizer.optimize(fs.join(baseline_dirname, ba
seline_name))) |
| 105 | 105 |
| 106 for dirname, contents in expected_new_results_by_directory.items(): | 106 for dirname, contents in expected_new_results_by_directory.items(): |
| 107 path = fs.join(webkit_base, 'LayoutTests', dirname, baseline_name) | 107 path = fs.join(blink_base, 'LayoutTests', dirname, baseline_name) |
| 108 if contents is not None: | 108 if contents is not None: |
| 109 self.assertEqual(fs.read_binary_file(path), contents) | 109 self.assertEqual(fs.read_binary_file(path), contents) |
| 110 | 110 |
| 111 def test_linux_redundant_with_win(self): | 111 def test_linux_redundant_with_win(self): |
| 112 self._assertOptimization( | 112 self._assertOptimization( |
| 113 { | 113 { |
| 114 'platform/win': '1', | 114 'platform/win': '1', |
| 115 'platform/linux': '1', | 115 'platform/linux': '1', |
| 116 }, | 116 }, |
| 117 { | 117 { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 self._assertOptimization( | 271 self._assertOptimization( |
| 272 { | 272 { |
| 273 'virtual/gpu/fast/canvas': '2', | 273 'virtual/gpu/fast/canvas': '2', |
| 274 'platform/mac/fast/canvas': '1', | 274 'platform/mac/fast/canvas': '1', |
| 275 }, | 275 }, |
| 276 { | 276 { |
| 277 'virtual/gpu/fast/canvas': '2', | 277 'virtual/gpu/fast/canvas': '2', |
| 278 'platform/mac/fast/canvas': '1', | 278 'platform/mac/fast/canvas': '1', |
| 279 }, | 279 }, |
| 280 baseline_dirname='virtual/gpu/fast/canvas') | 280 baseline_dirname='virtual/gpu/fast/canvas') |
| OLD | NEW |