| 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 95cbc97ef2903bd820fd2450cd7777fc80b3457d..33e33128763249be34ddb90a43a671835981da0a 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
|
| @@ -51,12 +51,12 @@ class ExcludingMockSCM(MockSCM):
|
| def delete_list(self, paths):
|
| for path in paths:
|
| if path in self._exclusion_list:
|
| - raise Exception('File is not SCM managed: ' + path)
|
| + 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)
|
| + raise Exception("File is not SCM managed: " + origin)
|
| return MockSCM.move(self, origin, destination)
|
|
|
|
|
| @@ -73,16 +73,13 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| 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)
|
| - baseline_optimizer.move_baselines(
|
| - 'another/test-expected.txt',
|
| - {
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/win': 'aaa',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac': 'aaa',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb',
|
| - },
|
| - {
|
| - '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa',
|
| - })
|
| + baseline_optimizer._move_baselines('another/test-expected.txt', {
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/win': 'aaa',
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac': 'aaa',
|
| + '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb',
|
| + }, {
|
| + '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa',
|
| + })
|
| self.assertEqual(host.filesystem.read_binary_file(
|
| '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt'), 'result A')
|
|
|
| @@ -97,31 +94,28 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| 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)
|
| - baseline_optimizer.move_baselines(
|
| - 'another/test-expected.txt',
|
| - {
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/win': 'aaa',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac': 'aaa',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb',
|
| - },
|
| - {
|
| - '/mock-checkout/third_party/WebKit/LayoutTests/platform/linux': 'bbb',
|
| - '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa',
|
| - })
|
| + baseline_optimizer._move_baselines('another/test-expected.txt', {
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/win': 'aaa',
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/mac': 'aaa',
|
| + '/mock-checkout/third_party/WebKit/LayoutTests': 'bbb',
|
| + }, {
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/linux': 'bbb',
|
| + '/mock-checkout/third_party/WebKit/LayoutTests': 'aaa',
|
| + })
|
| self.assertEqual(host.filesystem.read_binary_file(
|
| '/mock-checkout/third_party/WebKit/LayoutTests/another/test-expected.txt'), 'result A')
|
|
|
| - self.assertEqual(baseline_optimizer.files_to_delete, [
|
| + 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, [
|
| + 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 _assert_optimization(self, dir_to_results, dir_to_expected_new_results,
|
| - baseline_dirname='', expected_files_to_delete=None, host=None):
|
| + def _assertOptimization(self, results_by_directory, expected_new_results_by_directory,
|
| + baseline_dirname='', expected_files_to_delete=None, host=None):
|
| if not host:
|
| host = MockHost()
|
| fs = host.filesystem
|
| @@ -130,7 +124,7 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| fs.write_text_file(fs.join(webkit_base, 'LayoutTests', 'VirtualTestSuites'),
|
| '[{"prefix": "gpu", "base": "fast/canvas", "args": ["--foo"]}]')
|
|
|
| - for dirname, contents in dir_to_results.items():
|
| + for dirname, contents in results_by_directory.items():
|
| path = fs.join(webkit_base, 'LayoutTests', dirname, baseline_name)
|
| fs.write_binary_file(path, contents)
|
|
|
| @@ -138,200 +132,167 @@ class BaselineOptimizerTest(unittest.TestCase):
|
| ), host.port_factory.all_port_names(), skip_scm_commands=expected_files_to_delete is not None)
|
| self.assertTrue(baseline_optimizer.optimize(fs.join(baseline_dirname, baseline_name)))
|
|
|
| - for dirname, contents in dir_to_expected_new_results.items():
|
| + 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)
|
| + self.assertTrue(not fs.exists(path) or path in baseline_optimizer._files_to_delete)
|
| else:
|
| 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 dir_to_results:
|
| + for dirname in results_by_directory:
|
| path = fs.join(webkit_base, 'LayoutTests', dirname, baseline_name)
|
| - if dirname not in dir_to_expected_new_results:
|
| - self.assertTrue(not fs.exists(path) or path in baseline_optimizer.files_to_delete)
|
| + 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))
|
| + self.assertEqual(sorted(baseline_optimizer._files_to_delete), sorted(expected_files_to_delete))
|
|
|
| def test_linux_redundant_with_win(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/win': '1',
|
| - 'platform/linux': '1',
|
| - },
|
| - {
|
| - 'platform/win': '1',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/win': '1',
|
| + 'platform/linux': '1',
|
| + }, {
|
| + 'platform/win': '1',
|
| + })
|
|
|
| def test_covers_mac_win_linux(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/win': '1',
|
| - 'platform/linux': '1',
|
| - '': None,
|
| - },
|
| - {
|
| - '': '1',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac': '1',
|
| + 'platform/win': '1',
|
| + 'platform/linux': '1',
|
| + '': None,
|
| + }, {
|
| + '': '1',
|
| + })
|
|
|
| def test_overwrites_root(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/win': '1',
|
| - 'platform/linux': '1',
|
| - '': '2',
|
| - },
|
| - {
|
| - '': '1',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac': '1',
|
| + 'platform/win': '1',
|
| + 'platform/linux': '1',
|
| + '': '2',
|
| + }, {
|
| + '': '1',
|
| + })
|
|
|
| def test_no_new_common_directory(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/linux': '1',
|
| - '': '2',
|
| - },
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/linux': '1',
|
| - '': '2',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac': '1',
|
| + 'platform/linux': '1',
|
| + '': '2',
|
| + }, {
|
| + 'platform/mac': '1',
|
| + 'platform/linux': '1',
|
| + '': '2',
|
| + })
|
|
|
| def test_local_optimization(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/linux': '1',
|
| - 'platform/linux-precise': '1',
|
| - },
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/linux': '1',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac': '1',
|
| + 'platform/linux': '1',
|
| + 'platform/linux-precise': '1',
|
| + }, {
|
| + 'platform/mac': '1',
|
| + 'platform/linux': '1',
|
| + })
|
|
|
| def test_local_optimization_skipping_a_port_in_the_middle(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac-snowleopard': '1',
|
| - 'platform/win': '1',
|
| - 'platform/linux': '1',
|
| - 'platform/linux-precise': '1',
|
| - },
|
| - {
|
| - 'platform/mac-snowleopard': '1',
|
| - 'platform/win': '1',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac-snowleopard': '1',
|
| + 'platform/win': '1',
|
| + 'platform/linux': '1',
|
| + 'platform/linux-precise': '1',
|
| + }, {
|
| + 'platform/mac-snowleopard': '1',
|
| + 'platform/win': '1',
|
| + })
|
|
|
| def test_baseline_redundant_with_root(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/win': '2',
|
| - '': '2',
|
| - },
|
| - {
|
| - 'platform/mac': '1',
|
| - '': '2',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac': '1',
|
| + 'platform/win': '2',
|
| + '': '2',
|
| + }, {
|
| + 'platform/mac': '1',
|
| + '': '2',
|
| + })
|
|
|
| def test_root_baseline_unused(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/win': '2',
|
| - '': '3',
|
| - },
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/win': '2',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac': '1',
|
| + 'platform/win': '2',
|
| + '': '3',
|
| + }, {
|
| + 'platform/mac': '1',
|
| + 'platform/win': '2',
|
| + })
|
|
|
| def test_root_baseline_unused_and_non_existant(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/win': '2',
|
| - },
|
| - {
|
| - 'platform/mac': '1',
|
| - 'platform/win': '2',
|
| - })
|
| + self._assertOptimization({
|
| + 'platform/mac': '1',
|
| + 'platform/win': '2',
|
| + }, {
|
| + 'platform/mac': '1',
|
| + 'platform/win': '2',
|
| + })
|
|
|
| def test_virtual_root_redundant_with_actual_root(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'virtual/gpu/fast/canvas': '2',
|
| - 'fast/canvas': '2',
|
| - },
|
| - {
|
| - 'virtual/gpu/fast/canvas': None,
|
| - 'fast/canvas': '2',
|
| - },
|
| - baseline_dirname='virtual/gpu/fast/canvas')
|
| + self._assertOptimization({
|
| + 'virtual/gpu/fast/canvas': '2',
|
| + 'fast/canvas': '2',
|
| + }, {
|
| + 'virtual/gpu/fast/canvas': None,
|
| + 'fast/canvas': '2',
|
| + }, baseline_dirname='virtual/gpu/fast/canvas')
|
|
|
| def test_virtual_root_redundant_with_ancestors(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'virtual/gpu/fast/canvas': '2',
|
| - 'platform/mac/fast/canvas': '2',
|
| - 'platform/win/fast/canvas': '2',
|
| - },
|
| - {
|
| - 'virtual/gpu/fast/canvas': None,
|
| - 'fast/canvas': '2',
|
| - },
|
| - baseline_dirname='virtual/gpu/fast/canvas')
|
| + self._assertOptimization({
|
| + 'virtual/gpu/fast/canvas': '2',
|
| + 'platform/mac/fast/canvas': '2',
|
| + 'platform/win/fast/canvas': '2',
|
| + }, {
|
| + 'virtual/gpu/fast/canvas': None,
|
| + 'fast/canvas': '2',
|
| + }, baseline_dirname='virtual/gpu/fast/canvas')
|
|
|
| def test_virtual_root_redundant_with_ancestors_skip_scm_commands(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'virtual/gpu/fast/canvas': '2',
|
| - 'platform/mac/fast/canvas': '2',
|
| - 'platform/win/fast/canvas': '2',
|
| - },
|
| - {
|
| - 'virtual/gpu/fast/canvas': None,
|
| - 'fast/canvas': '2',
|
| - },
|
| + self._assertOptimization({
|
| + 'virtual/gpu/fast/canvas': '2',
|
| + 'platform/mac/fast/canvas': '2',
|
| + 'platform/win/fast/canvas': '2',
|
| + }, {
|
| + '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',
|
| - ])
|
| + '/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',
|
| + ])
|
|
|
| def test_virtual_root_redundant_with_ancestors_skip_scm_commands_with_file_not_in_scm(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'virtual/gpu/fast/canvas': '2',
|
| - 'platform/mac/fast/canvas': '2',
|
| - 'platform/win/fast/canvas': '2',
|
| - },
|
| - {
|
| - 'virtual/gpu/fast/canvas': None,
|
| - 'fast/canvas': '2',
|
| - },
|
| + self._assertOptimization({
|
| + 'virtual/gpu/fast/canvas': '2',
|
| + 'platform/mac/fast/canvas': '2',
|
| + 'platform/win/fast/canvas': '2',
|
| + }, {
|
| + 'virtual/gpu/fast/canvas': None,
|
| + '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'
|
| - ])))
|
| + '/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'])))
|
|
|
| def test_virtual_root_not_redundant_with_ancestors(self):
|
| - self._assert_optimization(
|
| - {
|
| - 'virtual/gpu/fast/canvas': '2',
|
| - 'platform/mac/fast/canvas': '1',
|
| - },
|
| - {
|
| - 'virtual/gpu/fast/canvas': '2',
|
| - 'platform/mac/fast/canvas': '1',
|
| - },
|
| - baseline_dirname='virtual/gpu/fast/canvas')
|
| + self._assertOptimization({
|
| + 'virtual/gpu/fast/canvas': '2',
|
| + 'platform/mac/fast/canvas': '1',
|
| + }, {
|
| + 'virtual/gpu/fast/canvas': '2',
|
| + 'platform/mac/fast/canvas': '1',
|
| + }, baseline_dirname='virtual/gpu/fast/canvas')
|
|
|