| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import optparse | 6 import optparse |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 from webkitpy.common.net.buildbot import Build | 9 from webkitpy.common.net.buildbot import Build |
| 10 from webkitpy.common.net.layout_test_results import LayoutTestResults | 10 from webkitpy.common.net.layout_test_results import LayoutTestResults |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 '--suffixes', 'txt,png', | 521 '--suffixes', 'txt,png', |
| 522 '--port-name', 'test-win-win7', | 522 '--port-name', 'test-win-win7', |
| 523 ]], | 523 ]], |
| 524 [[ | 524 [[ |
| 525 'python', 'echo', 'rebaseline-test-internal', | 525 'python', 'echo', 'rebaseline-test-internal', |
| 526 '--verbose', | 526 '--verbose', |
| 527 '--test', 'userscripts/first-test.html', | 527 '--test', 'userscripts/first-test.html', |
| 528 '--suffixes', 'txt,png', | 528 '--suffixes', 'txt,png', |
| 529 '--port-name', 'test-win-win7', | 529 '--port-name', 'test-win-win7', |
| 530 '--builder', 'MOCK Win7', | 530 '--builder', 'MOCK Win7', |
| 531 '--results-directory', '/tmp']] | 531 '--results-directory', '/tmp', |
| 532 ]], |
| 532 ]) | 533 ]) |
| 533 | 534 |
| 534 def test_unstaged_baselines(self): | 535 def test_unstaged_baselines(self): |
| 535 git = self.tool.git() | 536 git = self.tool.git() |
| 536 git.unstaged_changes = lambda: { | 537 git.unstaged_changes = lambda: { |
| 537 'third_party/WebKit/LayoutTests/x/foo-expected.txt': 'M', | 538 'third_party/WebKit/LayoutTests/x/foo-expected.txt': 'M', |
| 538 'third_party/WebKit/LayoutTests/x/foo-expected.something': '?', | 539 'third_party/WebKit/LayoutTests/x/foo-expected.something': '?', |
| 539 'third_party/WebKit/LayoutTests/x/foo-expected.png': '?', | 540 'third_party/WebKit/LayoutTests/x/foo-expected.png': '?', |
| 540 'third_party/WebKit/LayoutTests/x/foo.html': 'M', | 541 'third_party/WebKit/LayoutTests/x/foo.html': 'M', |
| 541 'docs/something.md': '?', | 542 'docs/something.md': '?', |
| 542 } | 543 } |
| 543 self.assertEqual( | 544 self.assertEqual( |
| 544 self.command.unstaged_baselines(), | 545 self.command.unstaged_baselines(), |
| 545 [ | 546 [ |
| 546 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.pn
g', | 547 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.pn
g', |
| 547 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.tx
t', | 548 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.tx
t', |
| 548 ]) | 549 ]) |
| 549 | 550 |
| 551 def test_rebaseline_with_different_port_name(self): |
| 552 self._setup_mock_build_data() |
| 553 self._write('userscripts/first-test.html', 'Dummy test contents') |
| 554 test_baseline_set = TestBaselineSet(self.tool) |
| 555 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Win7'),
'test-win-win10') |
| 556 self.command.rebaseline(self.options(), test_baseline_set) |
| 557 |
| 558 self.assertEqual( |
| 559 self.tool.executive.calls, |
| 560 [ |
| 561 [[ |
| 562 'python', 'echo', 'copy-existing-baselines-internal', |
| 563 '--verbose', |
| 564 '--test', 'userscripts/first-test.html', |
| 565 '--suffixes', 'txt,png', |
| 566 '--port-name', 'test-win-win10', |
| 567 |
| 568 ]], |
| 569 [[ |
| 570 'python', 'echo', 'rebaseline-test-internal', |
| 571 '--verbose', |
| 572 '--test', 'userscripts/first-test.html', |
| 573 '--suffixes', 'txt,png', |
| 574 '--port-name', 'test-win-win10', |
| 575 '--builder', 'MOCK Win7', |
| 576 ]], |
| 577 [[ |
| 578 'python', 'echo', 'optimize-baselines', |
| 579 '--verbose', |
| 580 '--suffixes', 'txt,png', |
| 581 'userscripts/first-test.html', |
| 582 ]] |
| 583 ]) |
| 584 |
| 550 | 585 |
| 551 class TestRebaselineUpdatesExpectationsFiles(BaseTestCase): | 586 class TestRebaselineUpdatesExpectationsFiles(BaseTestCase): |
| 552 """Tests for the logic related to updating the test expectations file.""" | 587 """Tests for the logic related to updating the test expectations file.""" |
| 553 command_constructor = Rebaseline | 588 command_constructor = Rebaseline |
| 554 | 589 |
| 555 def setUp(self): | 590 def setUp(self): |
| 556 super(TestRebaselineUpdatesExpectationsFiles, self).setUp() | 591 super(TestRebaselineUpdatesExpectationsFiles, self).setUp() |
| 557 self.tool.executive = MockExecutive() | 592 self.tool.executive = MockExecutive() |
| 558 | 593 |
| 559 def mock_run_command(*args, **kwargs): # pylint: disable=unused-argumen
t | 594 def mock_run_command(*args, **kwargs): # pylint: disable=unused-argumen
t |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 }) | 1161 }) |
| 1127 self.host = host | 1162 self.host = host |
| 1128 | 1163 |
| 1129 def test_add_and_iter_tests(self): | 1164 def test_add_and_iter_tests(self): |
| 1130 test_baseline_set = TestBaselineSet(host=self.host) | 1165 test_baseline_set = TestBaselineSet(host=self.host) |
| 1131 test_baseline_set.add('a', Build('MOCK Trusty')) | 1166 test_baseline_set.add('a', Build('MOCK Trusty')) |
| 1132 test_baseline_set.add('a/z.html', Build('MOCK Win10')) | 1167 test_baseline_set.add('a/z.html', Build('MOCK Win10')) |
| 1133 self.assertEqual( | 1168 self.assertEqual( |
| 1134 list(test_baseline_set), | 1169 list(test_baseline_set), |
| 1135 [ | 1170 [ |
| 1136 ('a/x.html', Build(builder_name='MOCK Trusty')), | 1171 ('a/x.html', Build(builder_name='MOCK Trusty'), 'test-linux-trus
ty'), |
| 1137 ('a/y.html', Build(builder_name='MOCK Trusty')), | 1172 ('a/y.html', Build(builder_name='MOCK Trusty'), 'test-linux-trus
ty'), |
| 1138 ('a/z.html', Build(builder_name='MOCK Trusty')), | 1173 ('a/z.html', Build(builder_name='MOCK Trusty'), 'test-linux-trus
ty'), |
| 1139 ('a/z.html', Build(builder_name='MOCK Win10')), | 1174 ('a/z.html', Build(builder_name='MOCK Win10'), 'test-win-win10')
, |
| 1140 ]) | 1175 ]) |
| 1141 | 1176 |
| 1142 def test_str_empty(self): | 1177 def test_str_empty(self): |
| 1143 test_baseline_set = TestBaselineSet(host=self.host) | 1178 test_baseline_set = TestBaselineSet(host=self.host) |
| 1144 self.assertEqual(str(test_baseline_set), '<Empty TestBaselineSet>') | 1179 self.assertEqual(str(test_baseline_set), '<Empty TestBaselineSet>') |
| 1145 | 1180 |
| 1146 def test_str_basic(self): | 1181 def test_str_basic(self): |
| 1147 test_baseline_set = TestBaselineSet(host=self.host) | 1182 test_baseline_set = TestBaselineSet(host=self.host) |
| 1148 test_baseline_set.add('a/x.html', Build('MOCK Mac10.12')) | 1183 test_baseline_set.add('a/x.html', Build('MOCK Mac10.12')) |
| 1149 test_baseline_set.add('a/x.html', Build('MOCK Win10')) | 1184 test_baseline_set.add('a/x.html', Build('MOCK Win10')) |
| 1150 self.assertEqual( | 1185 self.assertEqual( |
| 1151 str(test_baseline_set), | 1186 str(test_baseline_set), |
| 1152 ('<TestBaselineSet with:\n' | 1187 ('<TestBaselineSet with:\n' |
| 1153 ' a/x.html: Build(builder_name=\'MOCK Mac10.12\', build_number=Non
e)\n' | 1188 ' a/x.html: Build(builder_name=\'MOCK Mac10.12\', build_number=Non
e), test-mac-mac10.12\n' |
| 1154 ' a/x.html: Build(builder_name=\'MOCK Win10\', build_number=None)>
')) | 1189 ' a/x.html: Build(builder_name=\'MOCK Win10\', build_number=None),
test-win-win10>')) |
| OLD | NEW |