| 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 20 matching lines...) Expand all Loading... |
| 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.webkit_finder import WebKitFinder |
| 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 webkit_base = WebKitFinder(fs).webkit_base() | 41 layout_tests_dir = WebKitFinder(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(webkit_base, 'LayoutTests', '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(webkit_base, 'LayoutTests', dirname, ba
seline_name), 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))) |
| 52 | 52 |
| 53 for dirname, contents in directory_to_new_results.items(): | 53 for dirname, contents in directory_to_new_results.items(): |
| 54 path = fs.join(webkit_base, 'LayoutTests', dirname, baseline_name) | 54 path = fs.join(layout_tests_dir, dirname, baseline_name) |
| 55 if contents is not None: | 55 if contents is not None: |
| 56 self.assertEqual(fs.read_binary_file(path), contents) | 56 self.assertEqual(fs.read_binary_file(path), contents) |
| 57 | 57 |
| 58 def test_linux_redundant_with_win(self): | 58 def test_linux_redundant_with_win(self): |
| 59 self._assert_optimization( | 59 self._assert_optimization( |
| 60 { | 60 { |
| 61 'platform/win': '1', | 61 'platform/win': '1', |
| 62 'platform/linux': '1', | 62 'platform/linux': '1', |
| 63 }, | 63 }, |
| 64 { | 64 { |
| (...skipping 177 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 |