| 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.baseline_optimizer import BaselineOptimizer | 31 from webkitpy.common.checkout.baseline_optimizer 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.path_finder import PathFinder |
| 34 | 34 |
| 35 | 35 |
| 36 class BaselineOptimizerTest(unittest.TestCase): | 36 class BaselineOptimizerTest(unittest.TestCase): |
| 37 | 37 |
| 38 def _assert_optimization(self, results_by_directory, directory_to_new_result
s, baseline_dirname='', host=None): | 38 def _assert_optimization(self, results_by_directory, directory_to_new_result
s, baseline_dirname='', host=None): |
| 39 host = host or MockHost() | 39 host = host or MockHost() |
| 40 fs = host.filesystem | 40 fs = host.filesystem |
| 41 layout_tests_dir = WebKitFinder(fs).layout_tests_dir() | 41 layout_tests_dir = PathFinder(fs).layout_tests_dir() |
| 42 baseline_name = 'mock-baseline-expected.txt' | 42 baseline_name = 'mock-baseline-expected.txt' |
| 43 fs.write_text_file( | 43 fs.write_text_file( |
| 44 fs.join(layout_tests_dir, 'VirtualTestSuites'), | 44 fs.join(layout_tests_dir, 'VirtualTestSuites'), |
| 45 '[{"prefix": "gpu", "base": "fast/canvas", "args": ["--foo"]}]') | 45 '[{"prefix": "gpu", "base": "fast/canvas", "args": ["--foo"]}]') |
| 46 | 46 |
| 47 for dirname, contents in results_by_directory.items(): | 47 for dirname, contents in results_by_directory.items(): |
| 48 fs.write_binary_file(fs.join(layout_tests_dir, dirname, baseline_nam
e), contents) | 48 fs.write_binary_file(fs.join(layout_tests_dir, dirname, baseline_nam
e), contents) |
| 49 | 49 |
| 50 baseline_optimizer = BaselineOptimizer(host, host.port_factory.get(), ho
st.port_factory.all_port_names()) | 50 baseline_optimizer = BaselineOptimizer(host, host.port_factory.get(), ho
st.port_factory.all_port_names()) |
| 51 self.assertTrue(baseline_optimizer.optimize(fs.join(baseline_dirname, ba
seline_name))) | 51 self.assertTrue(baseline_optimizer.optimize(fs.join(baseline_dirname, ba
seline_name))) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb', | 242 '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb', |
| 243 }, | 243 }, |
| 244 { | 244 { |
| 245 '/mock-checkout/third_party/WebKit/LayoutTests/platform/linux':
'bbb', | 245 '/mock-checkout/third_party/WebKit/LayoutTests/platform/linux':
'bbb', |
| 246 '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa', | 246 '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa', |
| 247 }) | 247 }) |
| 248 self.assertEqual( | 248 self.assertEqual( |
| 249 host.filesystem.read_binary_file( | 249 host.filesystem.read_binary_file( |
| 250 '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expe
cted.txt'), | 250 '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expe
cted.txt'), |
| 251 'result A') | 251 'result A') |
| OLD | NEW |