| Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_expectations_updater_unittest.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_expectations_updater_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_expectations_updater_unittest.py
|
| index 72cd63a7022c6e12ce7b2400cc9587160565f85a..f1b5d0397c73f6670ededed653db15896ab4905c 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_expectations_updater_unittest.py
|
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_expectations_updater_unittest.py
|
| @@ -17,15 +17,22 @@ from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER
|
|
|
| class WPTExpectationsUpdaterTest(LoggingTestCase):
|
|
|
| - def setUp(self):
|
| + def mock_host(self):
|
| super(WPTExpectationsUpdaterTest, self).setUp()
|
| - self.host = MockHost()
|
| - self.host.builders = BuilderList({
|
| - 'mac': {'port_name': 'test-mac'},
|
| + host = MockHost()
|
| + host.builders = BuilderList({
|
| + 'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': ['Mac10.10', 'Release']},
|
| + 'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': ['Mac10.11', 'Release']},
|
| + 'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Trusty', 'Release']},
|
| + 'MOCK Win10': {'port_name': 'test-win-win10', 'specifiers': ['Win10', 'Release']},
|
| + 'MOCK Win7': {'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Release']},
|
| + 'MOCK Android': {'port_name': 'test-android', 'specifiers': ['Android', 'Release']},
|
| })
|
| + return host
|
|
|
| def test_get_failing_results_dict_only_passing_results(self):
|
| - self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({
|
| + host = self.mock_host()
|
| + host.buildbot.set_results(Build('MOCK Mac10.10', 123), LayoutTestResults({
|
| 'tests': {
|
| 'x': {
|
| 'passing-test.html': {
|
| @@ -35,17 +42,19 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| },
|
| },
|
| }))
|
| - updater = WPTExpectationsUpdater(self.host)
|
| - self.assertEqual(updater.get_failing_results_dict(Build('mac', 123)), {})
|
| + updater = WPTExpectationsUpdater(host)
|
| + self.assertEqual(updater.get_failing_results_dict(Build('MOCK Mac10.10', 123)), {})
|
|
|
| def test_get_failing_results_dict_no_results(self):
|
| - self.host.buildbot = MockBuildBot()
|
| - self.host.buildbot.set_results(Build('mac', 123), None)
|
| - updater = WPTExpectationsUpdater(self.host)
|
| - self.assertEqual(updater.get_failing_results_dict(Build('mac', 123)), {})
|
| + host = self.mock_host()
|
| + host.buildbot = MockBuildBot()
|
| + host.buildbot.set_results(Build('MOCK Mac10.10', 123), None)
|
| + updater = WPTExpectationsUpdater(host)
|
| + self.assertEqual(updater.get_failing_results_dict(Build('MOCK Mac10.10', 123)), {})
|
|
|
| def test_get_failing_results_dict_some_failing_results(self):
|
| - self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({
|
| + host = self.mock_host()
|
| + host.buildbot.set_results(Build('MOCK Mac10.10', 123), LayoutTestResults({
|
| 'tests': {
|
| 'x': {
|
| 'failing-test.html': {
|
| @@ -56,19 +65,22 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| },
|
| },
|
| }))
|
| - updater = WPTExpectationsUpdater(self.host)
|
| - self.assertEqual(updater.get_failing_results_dict(Build('mac', 123)), {
|
| - 'x/failing-test.html': {
|
| - 'Mac': {
|
| - 'actual': 'IMAGE',
|
| - 'expected': 'PASS',
|
| - 'bug': 'crbug.com/626703',
|
| + updater = WPTExpectationsUpdater(host)
|
| + results_dict = updater.get_failing_results_dict(Build('MOCK Mac10.10', 123))
|
| + self.assertEqual(
|
| + results_dict,
|
| + {
|
| + 'x/failing-test.html': {
|
| + 'test-mac-mac10.10': {
|
| + 'actual': 'IMAGE',
|
| + 'expected': 'PASS',
|
| + 'bug': 'crbug.com/626703',
|
| + },
|
| },
|
| - },
|
| - })
|
| + })
|
|
|
| def test_merge_same_valued_keys_all_match(self):
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| self.assertEqual(
|
| updater.merge_same_valued_keys({
|
| 'one': {'expected': 'FAIL', 'actual': 'PASS'},
|
| @@ -77,7 +89,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| {('two', 'one'): {'expected': 'FAIL', 'actual': 'PASS'}})
|
|
|
| def test_merge_same_valued_keys_one_mismatch(self):
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| self.assertEqual(
|
| updater.merge_same_valued_keys({
|
| 'one': {'expected': 'FAIL', 'actual': 'PASS'},
|
| @@ -90,7 +102,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| })
|
|
|
| def test_get_expectations(self):
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| self.assertEqual(
|
| updater.get_expectations({'expected': 'FAIL', 'actual': 'PASS'}),
|
| {'Pass'})
|
| @@ -109,7 +121,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
|
|
| def test_create_line_list_old_tests(self):
|
| # In this example, there are two failures that are not in w3c tests.
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| results = {
|
| 'fake/test/path.html': {
|
| 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/test'},
|
| @@ -120,7 +132,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
|
|
| def test_create_line_list_new_tests(self):
|
| # In this example, there are unexpected non-fail results in w3c tests.
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| results = {
|
| 'external/fake/test/path.html': {
|
| 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/test'},
|
| @@ -137,7 +149,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| ])
|
|
|
| def test_merge_dicts_with_conflict_raise_exception(self):
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| # Both dicts here have the key "one", and the value is not equal.
|
| with self.assertRaises(ValueError):
|
| updater.merge_dicts(
|
| @@ -155,7 +167,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| })
|
|
|
| def test_merge_dicts_merges_second_dict_into_first(self):
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| one = {
|
| 'fake/test/path.html': {
|
| 'one': {'expected': 'FAIL', 'actual': 'PASS'},
|
| @@ -181,7 +193,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| self.assertEqual(output, two)
|
|
|
| def test_generate_results_dict(self):
|
| - updater = WPTExpectationsUpdater(MockHost())
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| layout_test_list = [
|
| LayoutTestResult(
|
| 'test/name.html', {
|
| @@ -189,11 +201,11 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| 'actual': 'foo',
|
| 'is_unexpected': True,
|
| 'has_stderr': True,
|
| - }
|
| - )]
|
| - self.assertEqual(updater.generate_results_dict('dummy_platform', layout_test_list), {
|
| + })
|
| + ]
|
| + self.assertEqual(updater.generate_results_dict('test-mac-mac10.10', layout_test_list), {
|
| 'test/name.html': {
|
| - 'dummy_platform': {
|
| + 'test-mac-mac10.10': {
|
| 'expected': 'bar',
|
| 'actual': 'foo',
|
| 'bug': 'crbug.com/626703',
|
| @@ -202,9 +214,10 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| })
|
|
|
| def test_write_to_test_expectations_with_marker_comment(self):
|
| + host = self.mock_host()
|
| expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'
|
| - self.host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n'
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n'
|
| + updater = WPTExpectationsUpdater(host)
|
| line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]']
|
| updater.write_to_test_expectations(line_list)
|
| value = updater.host.filesystem.read_text_file(expectations_path)
|
| @@ -214,12 +227,13 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n'))
|
|
|
| def test_write_to_test_expectations_with_no_marker_comment(self):
|
| + host = self.mock_host()
|
| expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'
|
| - self.host.filesystem.files[expectations_path] = 'crbug.com/111 [ FakePlatform ]\n'
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + host.filesystem.files[expectations_path] = 'crbug.com/111 [ FakePlatform ]\n'
|
| + updater = WPTExpectationsUpdater(host)
|
| line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]']
|
| updater.write_to_test_expectations(line_list)
|
| - value = self.host.filesystem.read_text_file(expectations_path)
|
| + value = host.filesystem.read_text_file(expectations_path)
|
| self.assertMultiLineEqual(
|
| value,
|
| ('crbug.com/111 [ FakePlatform ]\n'
|
| @@ -227,15 +241,16 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]'))
|
|
|
| def test_write_to_test_expectations_skips_existing_lines(self):
|
| + host = self.mock_host()
|
| expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'
|
| - self.host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy/me.html [ Failure ]\n'
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy/me.html [ Failure ]\n'
|
| + updater = WPTExpectationsUpdater(host)
|
| line_list = [
|
| 'crbug.com/111 dont/copy/me.html [ Failure ]',
|
| 'crbug.com/222 do/copy/me.html [ Failure ]'
|
| ]
|
| updater.write_to_test_expectations(line_list)
|
| - value = self.host.filesystem.read_text_file(expectations_path)
|
| + value = host.filesystem.read_text_file(expectations_path)
|
| self.assertEqual(
|
| value,
|
| ('crbug.com/111 dont/copy/me.html [ Failure ]\n'
|
| @@ -243,11 +258,12 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| 'crbug.com/222 do/copy/me.html [ Failure ]'))
|
|
|
| def test_write_to_test_expectations_with_marker_and_no_lines(self):
|
| + host = self.mock_host()
|
| expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'
|
| - self.host.filesystem.files[expectations_path] = (
|
| + host.filesystem.files[expectations_path] = (
|
| MARKER_COMMENT + '\n'
|
| 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| updater.write_to_test_expectations([])
|
| value = updater.host.filesystem.read_text_file(expectations_path)
|
| self.assertMultiLineEqual(
|
| @@ -256,27 +272,30 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n'))
|
|
|
| def test_is_js_test_true(self):
|
| - self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo/bar.html'] = (
|
| + host = self.mock_host()
|
| + host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo/bar.html'] = (
|
| '<script src="/resources/testharness.js"></script>')
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| self.assertTrue(updater.is_js_test('foo/bar.html'))
|
|
|
| def test_is_js_test_false(self):
|
| - self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo/bar.html'] = (
|
| + host = self.mock_host()
|
| + host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo/bar.html'] = (
|
| '<script src="ref-test.html"></script>')
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| self.assertFalse(updater.is_js_test('foo/bar.html'))
|
|
|
| def test_is_js_test_non_existent_file(self):
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| self.assertFalse(updater.is_js_test('foo/bar.html'))
|
|
|
| def test_get_test_to_rebaseline_returns_only_tests_with_failures(self):
|
| - self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| + host = self.mock_host()
|
| + host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| '<script src="/resources/testharness.js"></script>')
|
| - self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/other/test/path.html'] = (
|
| + host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/other/test/path.html'] = (
|
| '<script src="/resources/testharness.js"></script>')
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| two = {
|
| 'external/fake/test/path.html': {
|
| 'one': {'expected': 'FAIL', 'actual': 'PASS'},
|
| @@ -289,9 +308,10 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html'])
|
|
|
| def test_get_test_to_rebaseline_returns_only_js_tests(self):
|
| - self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| + host = self.mock_host()
|
| + host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| 'this file does not look like a testharness JS test.')
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| two = {
|
| 'external/fake/test/path.html': {
|
| 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/test'},
|
| @@ -303,6 +323,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| self.assertEqual(tests_to_rebaseline, [])
|
|
|
| def test_get_tests_to_rebaseline_returns_updated_dict(self):
|
| + host = self.mock_host()
|
| test_results_dict = {
|
| 'external/fake/test/path.html': {
|
| 'one': {'expected': 'PASS', 'actual': 'TEXT'},
|
| @@ -310,9 +331,9 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| },
|
| }
|
| test_results_dict_copy = copy.deepcopy(test_results_dict)
|
| - self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| + host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| '<script src="/resources/testharness.js"></script>')
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebaseline(
|
| test_results_dict)
|
| self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html'])
|
| @@ -327,6 +348,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| self.assertEqual(test_results_dict, test_results_dict_copy)
|
|
|
| def test_get_tests_to_rebaseline_also_returns_slow_tests(self):
|
| + host = self.mock_host()
|
| test_results_dict = {
|
| 'external/fake/test/path.html': {
|
| 'one': {'expected': 'SLOW', 'actual': 'TEXT'},
|
| @@ -334,9 +356,9 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| },
|
| }
|
| test_results_dict_copy = copy.deepcopy(test_results_dict)
|
| - self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| + host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/external/fake/test/path.html'] = (
|
| '<script src="/resources/testharness.js"></script>')
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebaseline(
|
| test_results_dict)
|
| self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html'])
|
| @@ -351,13 +373,14 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| self.assertEqual(test_results_dict, test_results_dict_copy)
|
|
|
| def test_run_no_issue_number(self):
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(self.mock_host())
|
| updater.get_issue_number = lambda: 'None'
|
| self.assertEqual(1, updater.run(args=[]))
|
| self.assertLog(['ERROR: No issue on current branch.\n'])
|
|
|
| def test_run_no_try_results(self):
|
| - self.host.web = MockWeb(urls={
|
| + host = self.mock_host()
|
| + host.web = MockWeb(urls={
|
| 'https://codereview.chromium.org/api/11112222': json.dumps({
|
| 'patchsets': [1],
|
| }),
|
| @@ -365,12 +388,12 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
|
| 'try_job_results': []
|
| })
|
| })
|
| - updater = WPTExpectationsUpdater(self.host)
|
| + updater = WPTExpectationsUpdater(host)
|
| updater.get_issue_number = lambda: '11112222'
|
| updater.get_try_bots = lambda: ['test-builder-name']
|
| self.assertEqual(1, updater.run(args=[]))
|
| self.assertEqual(
|
| - self.host.web.urls_fetched,
|
| + host.web.urls_fetched,
|
| [
|
| 'https://codereview.chromium.org/api/11112222',
|
| 'https://codereview.chromium.org/api/11112222/1'
|
|
|