| Index: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py
|
| index fae2c451d7a88d99ad62878307928154cb50455d..01dccecb13b97755635a590d22e007af509fd14d 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py
|
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py
|
| @@ -29,43 +29,15 @@
|
| import unittest
|
|
|
| from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer
|
| -from webkitpy.common.checkout.scm.scm_mock import MockSCM
|
| from webkitpy.common.host_mock import MockHost
|
| from webkitpy.common.webkit_finder import WebKitFinder
|
|
|
|
|
| -class ExcludingMockSCM(MockSCM):
|
| -
|
| - def __init__(self, exclusion_list, filesystem=None, executive=None):
|
| - MockSCM.__init__(self, filesystem, executive)
|
| - self._exclusion_list = exclusion_list
|
| -
|
| - def exists(self, path):
|
| - if path in self._exclusion_list:
|
| - return False
|
| - return MockSCM.exists(self, path)
|
| -
|
| - def delete(self, path):
|
| - return self.delete_list([path])
|
| -
|
| - def delete_list(self, paths):
|
| - for path in paths:
|
| - if path in self._exclusion_list:
|
| - raise Exception("File is not SCM managed: " + path)
|
| - return MockSCM.delete_list(self, paths)
|
| -
|
| - def move(self, origin, destination):
|
| - if origin in self._exclusion_list:
|
| - raise Exception("File is not SCM managed: " + origin)
|
| - return MockSCM.move(self, origin, destination)
|
| -
|
| -
|
| class BaselineOptimizerTest(unittest.TestCase):
|
|
|
| # Protected method _move_baselines is tested below - pylint: disable=protected-access
|
| def test_move_baselines(self):
|
| - host = MockHost(scm=ExcludingMockSCM(
|
| - ['/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/another/test-expected.txt']))
|
| + host = MockHost()
|
| host.filesystem.write_text_file('/mock-checkout/third_party/WebKit/LayoutTests/VirtualTestSuites', '[]')
|
| host.filesystem.write_binary_file(
|
| '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/another/test-expected.txt', 'result A')
|
| @@ -73,7 +45,7 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/another/test-expected.txt', 'result A')
|
| host.filesystem.write_binary_file('/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt', 'result B')
|
| baseline_optimizer = BaselineOptimizer(
|
| - host, host.port_factory.get(), host.port_factory.all_port_names(), skip_scm_commands=False)
|
| + host, host.port_factory.get(), host.port_factory.all_port_names())
|
| baseline_optimizer._move_baselines(
|
| 'another/test-expected.txt',
|
| {
|
| @@ -88,8 +60,7 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt'), 'result A')
|
|
|
| def test_move_baselines_skip_scm_commands(self):
|
| - host = MockHost(scm=ExcludingMockSCM(
|
| - ['/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/another/test-expected.txt']))
|
| + host = MockHost()
|
| host.filesystem.write_text_file('/mock-checkout/third_party/WebKit/LayoutTests/VirtualTestSuites', '[]')
|
| host.filesystem.write_binary_file(
|
| '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/another/test-expected.txt', 'result A')
|
| @@ -97,7 +68,7 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/another/test-expected.txt', 'result A')
|
| host.filesystem.write_binary_file('/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt', 'result B')
|
| baseline_optimizer = BaselineOptimizer(host, host.port_factory.get(
|
| - ), host.port_factory.all_port_names(), skip_scm_commands=True)
|
| + ), host.port_factory.all_port_names())
|
| baseline_optimizer._move_baselines(
|
| 'another/test-expected.txt',
|
| {
|
| @@ -114,21 +85,8 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt'),
|
| 'result A')
|
|
|
| - self.assertEqual(
|
| - baseline_optimizer._files_to_delete,
|
| - [
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/another/test-expected.txt',
|
| - ])
|
| -
|
| - self.assertEqual(
|
| - baseline_optimizer._files_to_add,
|
| - [
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/linux/another/test-expected.txt',
|
| - ])
|
| -
|
| def _assertOptimization(self, results_by_directory, expected_new_results_by_directory,
|
| - baseline_dirname='', expected_files_to_delete=None, host=None):
|
| + baseline_dirname='', host=None):
|
| if not host:
|
| host = MockHost()
|
| fs = host.filesystem
|
| @@ -142,25 +100,14 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| fs.write_binary_file(path, contents)
|
|
|
| baseline_optimizer = BaselineOptimizer(host, host.port_factory.get(
|
| - ), host.port_factory.all_port_names(), skip_scm_commands=expected_files_to_delete is not None)
|
| + ), host.port_factory.all_port_names())
|
| self.assertTrue(baseline_optimizer.optimize(fs.join(baseline_dirname, baseline_name)))
|
|
|
| for dirname, contents in expected_new_results_by_directory.items():
|
| path = fs.join(webkit_base, 'LayoutTests', dirname, baseline_name)
|
| - if contents is None:
|
| - self.assertTrue(not fs.exists(path) or path in baseline_optimizer._files_to_delete)
|
| - else:
|
| + if contents is not None:
|
| self.assertEqual(fs.read_binary_file(path), contents)
|
|
|
| - # Check that the files that were in the original set have been deleted where necessary.
|
| - for dirname in results_by_directory:
|
| - path = fs.join(webkit_base, 'LayoutTests', dirname, baseline_name)
|
| - if not dirname in expected_new_results_by_directory:
|
| - self.assertTrue(not fs.exists(path) or path in baseline_optimizer._files_to_delete)
|
| -
|
| - if expected_files_to_delete:
|
| - self.assertEqual(sorted(baseline_optimizer._files_to_delete), sorted(expected_files_to_delete))
|
| -
|
| def test_linux_redundant_with_win(self):
|
| self._assertOptimization(
|
| {
|
| @@ -304,12 +251,7 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| 'virtual/gpu/fast/canvas': None,
|
| 'fast/canvas': '2',
|
| },
|
| - baseline_dirname='virtual/gpu/fast/canvas',
|
| - expected_files_to_delete=[
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/virtual/gpu/fast/canvas/mock-baseline-expected.txt',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/fast/canvas/mock-baseline-expected.txt',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/fast/canvas/mock-baseline-expected.txt',
|
| - ])
|
| + baseline_dirname='virtual/gpu/fast/canvas')
|
|
|
| def test_virtual_root_redundant_with_ancestors_skip_scm_commands_with_file_not_in_scm(self):
|
| self._assertOptimization(
|
| @@ -323,12 +265,7 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| 'fast/canvas': '2',
|
| },
|
| baseline_dirname='virtual/gpu/fast/canvas',
|
| - expected_files_to_delete=[
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac/fast/canvas/mock-baseline-expected.txt',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/win/fast/canvas/mock-baseline-expected.txt',
|
| - ],
|
| - host=MockHost(scm=ExcludingMockSCM(
|
| - ['/mock-checkout/third_party/WebKit/LayoutTests/virtual/gpu/fast/canvas/mock-baseline-expected.txt'])))
|
| + host=MockHost())
|
|
|
| def test_virtual_root_not_redundant_with_ancestors(self):
|
| self._assertOptimization(
|
|
|