| 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 copy | 6 import copy |
| 7 | 7 |
| 8 from webkitpy.common.host_mock import MockHost | 8 from webkitpy.common.host_mock import MockHost |
| 9 from webkitpy.common.net.buildbot import Build | 9 from webkitpy.common.net.buildbot import Build |
| 10 from webkitpy.common.net.buildbot_mock import MockBuildBot | 10 from webkitpy.common.net.buildbot_mock import MockBuildBot |
| 11 from webkitpy.common.net.layout_test_results import LayoutTestResult, LayoutTest
Results | 11 from webkitpy.common.net.layout_test_results import LayoutTestResult, LayoutTest
Results |
| 12 from webkitpy.common.net.web_mock import MockWeb | 12 from webkitpy.common.net.web_mock import MockWeb |
| 13 from webkitpy.common.system.log_testing import LoggingTestCase | 13 from webkitpy.common.system.log_testing import LoggingTestCase |
| 14 from webkitpy.layout_tests.builder_list import BuilderList | 14 from webkitpy.layout_tests.builder_list import BuilderList |
| 15 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER
_COMMENT | 15 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER
_COMMENT |
| 16 | 16 |
| 17 | 17 |
| 18 class WPTExpectationsUpdaterTest(LoggingTestCase): | 18 class WPTExpectationsUpdaterTest(LoggingTestCase): |
| 19 | 19 |
| 20 def mock_host(self): | 20 def mock_host(self): |
| 21 super(WPTExpectationsUpdaterTest, self).setUp() | 21 super(WPTExpectationsUpdaterTest, self).setUp() |
| 22 host = MockHost() | 22 host = MockHost() |
| 23 host.builders = BuilderList({ | 23 host.builders = BuilderList({ |
| 24 'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': ['
Mac10.10', 'Release']}, | 24 'MOCK Try Mac10.10': { |
| 25 'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': ['
Mac10.11', 'Release']}, | 25 'port_name': 'test-mac-mac10.10', |
| 26 'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Tr
usty', 'Release']}, | 26 'specifiers': ['Mac10.10', 'Release'], |
| 27 'MOCK Win10': {'port_name': 'test-win-win10', 'specifiers': ['Win10'
, 'Release']}, | 27 'is_try_builder': True, |
| 28 'MOCK Win7': {'port_name': 'test-win-win7', 'specifiers': ['Win7', '
Release']}, | 28 }, |
| 29 'MOCK Android': {'port_name': 'test-android', 'specifiers': ['Androi
d', 'Release']}, | 29 'MOCK Try Mac10.11': { |
| 30 'port_name': 'test-mac-mac10.11', |
| 31 'specifiers': ['Mac10.11', 'Release'], |
| 32 'is_try_builder': True, |
| 33 }, |
| 34 'MOCK Try Trusty': { |
| 35 'port_name': 'test-linux-trusty', |
| 36 'specifiers': ['Trusty', 'Release'], |
| 37 'is_try_builder': True, |
| 38 }, |
| 39 'MOCK Try Win10': { |
| 40 'port_name': 'test-win-win10', |
| 41 'specifiers': ['Win10', 'Release'], |
| 42 'is_try_builder': True, |
| 43 }, |
| 44 'MOCK Try Win7': { |
| 45 'port_name': 'test-win-win7', |
| 46 'specifiers': ['Win7', 'Release'], |
| 47 'is_try_builder': True, |
| 48 }, |
| 30 }) | 49 }) |
| 31 return host | 50 return host |
| 32 | 51 |
| 33 def test_get_failing_results_dict_only_passing_results(self): | 52 def test_get_failing_results_dict_only_passing_results(self): |
| 34 host = self.mock_host() | 53 host = self.mock_host() |
| 35 host.buildbot.set_results(Build('MOCK Mac10.10', 123), LayoutTestResults
({ | 54 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), LayoutTestRes
ults({ |
| 36 'tests': { | 55 'tests': { |
| 37 'x': { | 56 'x': { |
| 38 'passing-test.html': { | 57 'passing-test.html': { |
| 39 'expected': 'PASS', | 58 'expected': 'PASS', |
| 40 'actual': 'PASS', | 59 'actual': 'PASS', |
| 41 }, | 60 }, |
| 42 }, | 61 }, |
| 43 }, | 62 }, |
| 44 })) | 63 })) |
| 45 updater = WPTExpectationsUpdater(host) | 64 updater = WPTExpectationsUpdater(host) |
| 46 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Mac10.10',
123)), {}) | 65 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Try Mac10.
10', 123)), {}) |
| 47 | 66 |
| 48 def test_get_failing_results_dict_no_results(self): | 67 def test_get_failing_results_dict_no_results(self): |
| 49 host = self.mock_host() | 68 host = self.mock_host() |
| 50 host.buildbot = MockBuildBot() | 69 host.buildbot = MockBuildBot() |
| 51 host.buildbot.set_results(Build('MOCK Mac10.10', 123), None) | 70 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), None) |
| 52 updater = WPTExpectationsUpdater(host) | 71 updater = WPTExpectationsUpdater(host) |
| 53 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Mac10.10',
123)), {}) | 72 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Try Mac10.
10', 123)), {}) |
| 54 | 73 |
| 55 def test_get_failing_results_dict_some_failing_results(self): | 74 def test_get_failing_results_dict_some_failing_results(self): |
| 56 host = self.mock_host() | 75 host = self.mock_host() |
| 57 host.buildbot.set_results(Build('MOCK Mac10.10', 123), LayoutTestResults
({ | 76 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), LayoutTestRes
ults({ |
| 58 'tests': { | 77 'tests': { |
| 59 'x': { | 78 'x': { |
| 60 'failing-test.html': { | 79 'failing-test.html': { |
| 61 'expected': 'PASS', | 80 'expected': 'PASS', |
| 62 'actual': 'IMAGE', | 81 'actual': 'IMAGE', |
| 63 'is_unexpected': True, | 82 'is_unexpected': True, |
| 64 }, | 83 }, |
| 65 }, | 84 }, |
| 66 }, | 85 }, |
| 67 })) | 86 })) |
| 68 updater = WPTExpectationsUpdater(host) | 87 updater = WPTExpectationsUpdater(host) |
| 69 results_dict = updater.get_failing_results_dict(Build('MOCK Mac10.10', 1
23)) | 88 results_dict = updater.get_failing_results_dict(Build('MOCK Try Mac10.10
', 123)) |
| 70 self.assertEqual( | 89 self.assertEqual( |
| 71 results_dict, | 90 results_dict, |
| 72 { | 91 { |
| 73 'x/failing-test.html': { | 92 'x/failing-test.html': { |
| 74 'test-mac-mac10.10': { | 93 'test-mac-mac10.10': { |
| 75 'actual': 'IMAGE', | 94 'actual': 'IMAGE', |
| 76 'expected': 'PASS', | 95 'expected': 'PASS', |
| 77 'bug': 'crbug.com/626703', | 96 'bug': 'crbug.com/626703', |
| 78 }, | 97 }, |
| 79 }, | 98 }, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 147 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, |
| 129 } | 148 } |
| 130 } | 149 } |
| 131 self.assertEqual(updater.create_line_list(results), []) | 150 self.assertEqual(updater.create_line_list(results), []) |
| 132 | 151 |
| 133 def test_create_line_list_new_tests(self): | 152 def test_create_line_list_new_tests(self): |
| 134 # In this example, there are unexpected non-fail results in w3c tests. | 153 # In this example, there are unexpected non-fail results in w3c tests. |
| 135 updater = WPTExpectationsUpdater(self.mock_host()) | 154 updater = WPTExpectationsUpdater(self.mock_host()) |
| 136 results = { | 155 results = { |
| 137 'external/fake/test/path.html': { | 156 'external/fake/test/path.html': { |
| 138 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 157 'test-linux-trusty': {'expected': 'FAIL', 'actual': 'PASS', 'bug
': 'crbug.com/test'}, |
| 139 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c
om/test'}, | 158 'test-mac-mac10.10': {'expected': 'FAIL', 'actual': 'PASS', 'bug
': 'crbug.com/test'}, |
| 140 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co
m/test'}, | 159 'test-mac-mac10.11': {'expected': 'FAIL', 'actual': 'TIMEOUT', '
bug': 'crbug.com/test'}, |
| 141 } | 160 } |
| 142 } | 161 } |
| 143 self.assertEqual( | 162 self.assertEqual( |
| 144 updater.create_line_list(results), | 163 updater.create_line_list(results), |
| 145 [ | 164 [ |
| 146 'crbug.com/test [ three ] external/fake/test/path.html [ Pass ]'
, | 165 'crbug.com/test [ Linux ] external/fake/test/path.html [ Pass ]'
, |
| 147 'crbug.com/test [ two ] external/fake/test/path.html [ Timeout ]
', | 166 'crbug.com/test [ Mac10.10 ] external/fake/test/path.html [ Pass
]', |
| 148 'crbug.com/test [ one ] external/fake/test/path.html [ Pass ]', | 167 'crbug.com/test [ Mac10.11 ] external/fake/test/path.html [ Time
out ]', |
| 149 ]) | 168 ]) |
| 150 | 169 |
| 170 def test_specifier_part(self): |
| 171 updater = WPTExpectationsUpdater(self.mock_host()) |
| 172 self.assertEqual(updater.specifier_part(['test-mac-mac10.10'], 'x/y.html
'), '[ Mac10.10 ]') |
| 173 |
| 174 def test_skipped_specifiers_when_test_is_wontfix(self): |
| 175 host = self.mock_host() |
| 176 expectations_path = '/test.checkout/LayoutTests/NeverFixTests' |
| 177 host.filesystem.files[expectations_path] = 'crbug.com/111 [ Trusty ] ext
ernal/wpt/test.html [ WontFix ]\n' |
| 178 host.filesystem.files['/test.checkout/LayoutTests/external/wpt/test.html
'] = '' |
| 179 updater = WPTExpectationsUpdater(host) |
| 180 self.assertEqual(updater.skipped_specifiers('external/wpt/test.html'), [
'Trusty']) |
| 181 |
| 182 def test_simplify_specifiers(self): |
| 183 macros = { |
| 184 'mac': ['Mac10.10', 'mac10.11'], |
| 185 'win': ['Win7', 'win10'], |
| 186 'linux': ['Trusty'], |
| 187 } |
| 188 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['mac10.10',
'mac10.11'], macros), ['Mac']) |
| 189 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['Mac10.10',
'Mac10.11', 'Trusty'], macros), ['Linux', 'Mac']) |
| 190 self.assertEqual( |
| 191 WPTExpectationsUpdater.simplify_specifiers(['Mac10.10', 'Mac10.11',
'Trusty', 'Win7', 'Win10'], macros), []) |
| 192 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['a', 'b', '
c'], {}), ['A', 'B', 'C']) |
| 193 |
| 151 def test_merge_dicts_with_conflict_raise_exception(self): | 194 def test_merge_dicts_with_conflict_raise_exception(self): |
| 152 updater = WPTExpectationsUpdater(self.mock_host()) | 195 updater = WPTExpectationsUpdater(self.mock_host()) |
| 153 # Both dicts here have the key "one", and the value is not equal. | 196 # Both dicts here have the key "one", and the value is not equal. |
| 154 with self.assertRaises(ValueError): | 197 with self.assertRaises(ValueError): |
| 155 updater.merge_dicts( | 198 updater.merge_dicts( |
| 156 { | 199 { |
| 157 'external/fake/test/path.html': { | 200 'external/fake/test/path.html': { |
| 158 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 201 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 159 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 202 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
| 160 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 203 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 'bug': 'crbug.com/626703', | 254 'bug': 'crbug.com/626703', |
| 212 } | 255 } |
| 213 } | 256 } |
| 214 }) | 257 }) |
| 215 | 258 |
| 216 def test_write_to_test_expectations_with_marker_comment(self): | 259 def test_write_to_test_expectations_with_marker_comment(self): |
| 217 host = self.mock_host() | 260 host = self.mock_host() |
| 218 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 261 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 219 host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n' | 262 host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n' |
| 220 updater = WPTExpectationsUpdater(host) | 263 updater = WPTExpectationsUpdater(host) |
| 221 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass
]'] | 264 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]'] |
| 222 updater.write_to_test_expectations(line_list) | 265 updater.write_to_test_expectations(line_list) |
| 223 value = updater.host.filesystem.read_text_file(expectations_path) | 266 value = updater.host.filesystem.read_text_file(expectations_path) |
| 224 self.assertMultiLineEqual( | 267 self.assertMultiLineEqual( |
| 225 value, | 268 value, |
| 226 (MARKER_COMMENT + '\n' | 269 (MARKER_COMMENT + '\n' |
| 227 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) | 270 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n')) |
| 228 | 271 |
| 229 def test_write_to_test_expectations_with_no_marker_comment(self): | 272 def test_write_to_test_expectations_with_no_marker_comment(self): |
| 230 host = self.mock_host() | 273 host = self.mock_host() |
| 231 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 274 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 232 host.filesystem.files[expectations_path] = 'crbug.com/111 [ FakePlatform
]\n' | 275 host.filesystem.files[expectations_path] = 'crbug.com/111 [ Trusty ]\n' |
| 233 updater = WPTExpectationsUpdater(host) | 276 updater = WPTExpectationsUpdater(host) |
| 234 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass
]'] | 277 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]'] |
| 235 updater.write_to_test_expectations(line_list) | 278 updater.write_to_test_expectations(line_list) |
| 236 value = host.filesystem.read_text_file(expectations_path) | 279 value = host.filesystem.read_text_file(expectations_path) |
| 237 self.assertMultiLineEqual( | 280 self.assertMultiLineEqual( |
| 238 value, | 281 value, |
| 239 ('crbug.com/111 [ FakePlatform ]\n' | 282 ('crbug.com/111 [ Trusty ]\n' |
| 240 '\n' + MARKER_COMMENT + '\n' | 283 '\n' + MARKER_COMMENT + '\n' |
| 241 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]')) | 284 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]')) |
| 242 | 285 |
| 243 def test_write_to_test_expectations_skips_existing_lines(self): | 286 def test_write_to_test_expectations_skips_existing_lines(self): |
| 244 host = self.mock_host() | 287 host = self.mock_host() |
| 245 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 288 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 246 host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy/me.h
tml [ Failure ]\n' | 289 host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy/me.h
tml [ Failure ]\n' |
| 247 updater = WPTExpectationsUpdater(host) | 290 updater = WPTExpectationsUpdater(host) |
| 248 line_list = [ | 291 line_list = [ |
| 249 'crbug.com/111 dont/copy/me.html [ Failure ]', | 292 'crbug.com/111 dont/copy/me.html [ Failure ]', |
| 250 'crbug.com/222 do/copy/me.html [ Failure ]' | 293 'crbug.com/222 do/copy/me.html [ Failure ]' |
| 251 ] | 294 ] |
| 252 updater.write_to_test_expectations(line_list) | 295 updater.write_to_test_expectations(line_list) |
| 253 value = host.filesystem.read_text_file(expectations_path) | 296 value = host.filesystem.read_text_file(expectations_path) |
| 254 self.assertEqual( | 297 self.assertEqual( |
| 255 value, | 298 value, |
| 256 ('crbug.com/111 dont/copy/me.html [ Failure ]\n' | 299 ('crbug.com/111 dont/copy/me.html [ Failure ]\n' |
| 257 '\n' + MARKER_COMMENT + '\n' | 300 '\n' + MARKER_COMMENT + '\n' |
| 258 'crbug.com/222 do/copy/me.html [ Failure ]')) | 301 'crbug.com/222 do/copy/me.html [ Failure ]')) |
| 259 | 302 |
| 260 def test_write_to_test_expectations_with_marker_and_no_lines(self): | 303 def test_write_to_test_expectations_with_marker_and_no_lines(self): |
| 261 host = self.mock_host() | 304 host = self.mock_host() |
| 262 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 305 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 263 host.filesystem.files[expectations_path] = ( | 306 host.filesystem.files[expectations_path] = ( |
| 264 MARKER_COMMENT + '\n' | 307 MARKER_COMMENT + '\n' |
| 265 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n') | 308 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n') |
| 266 updater = WPTExpectationsUpdater(host) | 309 updater = WPTExpectationsUpdater(host) |
| 267 updater.write_to_test_expectations([]) | 310 updater.write_to_test_expectations([]) |
| 268 value = updater.host.filesystem.read_text_file(expectations_path) | 311 value = updater.host.filesystem.read_text_file(expectations_path) |
| 269 self.assertMultiLineEqual( | 312 self.assertMultiLineEqual( |
| 270 value, | 313 value, |
| 271 (MARKER_COMMENT + '\n' | 314 (MARKER_COMMENT + '\n' |
| 272 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) | 315 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n')) |
| 273 | 316 |
| 274 def test_is_js_test_true(self): | 317 def test_is_js_test_true(self): |
| 275 host = self.mock_host() | 318 host = self.mock_host() |
| 276 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo
/bar.html'] = ( | 319 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo
/bar.html'] = ( |
| 277 '<script src="/resources/testharness.js"></script>') | 320 '<script src="/resources/testharness.js"></script>') |
| 278 updater = WPTExpectationsUpdater(host) | 321 updater = WPTExpectationsUpdater(host) |
| 279 self.assertTrue(updater.is_js_test('foo/bar.html')) | 322 self.assertTrue(updater.is_js_test('foo/bar.html')) |
| 280 | 323 |
| 281 def test_is_js_test_false(self): | 324 def test_is_js_test_false(self): |
| 282 host = self.mock_host() | 325 host = self.mock_host() |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 updater.get_issue_number = lambda: '11112222' | 435 updater.get_issue_number = lambda: '11112222' |
| 393 updater.get_try_bots = lambda: ['test-builder-name'] | 436 updater.get_try_bots = lambda: ['test-builder-name'] |
| 394 self.assertEqual(1, updater.run(args=[])) | 437 self.assertEqual(1, updater.run(args=[])) |
| 395 self.assertEqual( | 438 self.assertEqual( |
| 396 host.web.urls_fetched, | 439 host.web.urls_fetched, |
| 397 [ | 440 [ |
| 398 'https://codereview.chromium.org/api/11112222', | 441 'https://codereview.chromium.org/api/11112222', |
| 399 'https://codereview.chromium.org/api/11112222/1' | 442 'https://codereview.chromium.org/api/11112222/1' |
| 400 ]) | 443 ]) |
| 401 self.assertLog(['ERROR: No try job information was collected.\n']) | 444 self.assertLog(['ERROR: No try job information was collected.\n']) |
| OLD | NEW |