| 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.executive_mock import MockExecutive | |
| 14 from webkitpy.common.system.log_testing import LoggingTestCase | 13 from webkitpy.common.system.log_testing import LoggingTestCase |
| 15 from webkitpy.layout_tests.builder_list import BuilderList | 14 from webkitpy.layout_tests.builder_list import BuilderList |
| 16 from webkitpy.w3c.update_w3c_test_expectations import W3CExpectationsLineAdder,
MARKER_COMMENT | 15 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER
_COMMENT |
| 17 | 16 |
| 18 | 17 |
| 19 class UpdateW3CTestExpectationsTest(LoggingTestCase): | 18 class WPTExpectationsUpdaterTest(LoggingTestCase): |
| 20 | 19 |
| 21 def setUp(self): | 20 def setUp(self): |
| 22 super(UpdateW3CTestExpectationsTest, self).setUp() | 21 super(WPTExpectationsUpdaterTest, self).setUp() |
| 23 self.host = MockHost() | 22 self.host = MockHost() |
| 24 self.host.builders = BuilderList({ | 23 self.host.builders = BuilderList({ |
| 25 'mac': {'port_name': 'test-mac'}, | 24 'mac': {'port_name': 'test-mac'}, |
| 26 }) | 25 }) |
| 27 | 26 |
| 28 def test_get_failing_results_dict_only_passing_results(self): | 27 def test_get_failing_results_dict_only_passing_results(self): |
| 29 self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({ | 28 self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({ |
| 30 'tests': { | 29 'tests': { |
| 31 'x': { | 30 'x': { |
| 32 'passing-test.html': { | 31 'passing-test.html': { |
| 33 'expected': 'PASS', | 32 'expected': 'PASS', |
| 34 'actual': 'PASS', | 33 'actual': 'PASS', |
| 35 }, | 34 }, |
| 36 }, | 35 }, |
| 37 }, | 36 }, |
| 38 })) | 37 })) |
| 39 line_adder = W3CExpectationsLineAdder(self.host) | 38 updater = WPTExpectationsUpdater(self.host) |
| 40 self.assertEqual(line_adder.get_failing_results_dict(Build('mac', 123)),
{}) | 39 self.assertEqual(updater.get_failing_results_dict(Build('mac', 123)), {}
) |
| 41 | 40 |
| 42 def test_get_failing_results_dict_no_results(self): | 41 def test_get_failing_results_dict_no_results(self): |
| 43 self.host.buildbot = MockBuildBot() | 42 self.host.buildbot = MockBuildBot() |
| 44 self.host.buildbot.set_results(Build('mac', 123), None) | 43 self.host.buildbot.set_results(Build('mac', 123), None) |
| 45 line_adder = W3CExpectationsLineAdder(self.host) | 44 updater = WPTExpectationsUpdater(self.host) |
| 46 self.assertEqual(line_adder.get_failing_results_dict(Build('mac', 123)),
{}) | 45 self.assertEqual(updater.get_failing_results_dict(Build('mac', 123)), {}
) |
| 47 | 46 |
| 48 def test_get_failing_results_dict_some_failing_results(self): | 47 def test_get_failing_results_dict_some_failing_results(self): |
| 49 self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({ | 48 self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({ |
| 50 'tests': { | 49 'tests': { |
| 51 'x': { | 50 'x': { |
| 52 'failing-test.html': { | 51 'failing-test.html': { |
| 53 'expected': 'PASS', | 52 'expected': 'PASS', |
| 54 'actual': 'IMAGE', | 53 'actual': 'IMAGE', |
| 55 'is_unexpected': True, | 54 'is_unexpected': True, |
| 56 }, | 55 }, |
| 57 }, | 56 }, |
| 58 }, | 57 }, |
| 59 })) | 58 })) |
| 60 line_adder = W3CExpectationsLineAdder(self.host) | 59 updater = WPTExpectationsUpdater(self.host) |
| 61 self.assertEqual(line_adder.get_failing_results_dict(Build('mac', 123)),
{ | 60 self.assertEqual(updater.get_failing_results_dict(Build('mac', 123)), { |
| 62 'x/failing-test.html': { | 61 'x/failing-test.html': { |
| 63 'Mac': { | 62 'Mac': { |
| 64 'actual': 'IMAGE', | 63 'actual': 'IMAGE', |
| 65 'expected': 'PASS', | 64 'expected': 'PASS', |
| 66 'bug': 'crbug.com/626703', | 65 'bug': 'crbug.com/626703', |
| 67 }, | 66 }, |
| 68 }, | 67 }, |
| 69 }) | 68 }) |
| 70 | 69 |
| 71 def test_merge_same_valued_keys_all_match(self): | 70 def test_merge_same_valued_keys_all_match(self): |
| 72 line_adder = W3CExpectationsLineAdder(self.host) | 71 updater = WPTExpectationsUpdater(self.host) |
| 73 self.assertEqual( | 72 self.assertEqual( |
| 74 line_adder.merge_same_valued_keys({ | 73 updater.merge_same_valued_keys({ |
| 75 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 74 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 76 'two': {'expected': 'FAIL', 'actual': 'PASS'}, | 75 'two': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 77 }), | 76 }), |
| 78 {('two', 'one'): {'expected': 'FAIL', 'actual': 'PASS'}}) | 77 {('two', 'one'): {'expected': 'FAIL', 'actual': 'PASS'}}) |
| 79 | 78 |
| 80 def test_merge_same_valued_keys_one_mismatch(self): | 79 def test_merge_same_valued_keys_one_mismatch(self): |
| 81 line_adder = W3CExpectationsLineAdder(self.host) | 80 updater = WPTExpectationsUpdater(self.host) |
| 82 self.assertEqual( | 81 self.assertEqual( |
| 83 line_adder.merge_same_valued_keys({ | 82 updater.merge_same_valued_keys({ |
| 84 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 83 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 85 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 84 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
| 86 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 85 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 87 }), | 86 }), |
| 88 { | 87 { |
| 89 ('three', 'one'): {'expected': 'FAIL', 'actual': 'PASS'}, | 88 ('three', 'one'): {'expected': 'FAIL', 'actual': 'PASS'}, |
| 90 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 89 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
| 91 }) | 90 }) |
| 92 | 91 |
| 93 def test_get_expectations(self): | 92 def test_get_expectations(self): |
| 94 line_adder = W3CExpectationsLineAdder(self.host) | 93 updater = WPTExpectationsUpdater(self.host) |
| 95 self.assertEqual( | 94 self.assertEqual( |
| 96 line_adder.get_expectations({'expected': 'FAIL', 'actual': 'PASS'}), | 95 updater.get_expectations({'expected': 'FAIL', 'actual': 'PASS'}), |
| 97 {'Pass'}) | 96 {'Pass'}) |
| 98 self.assertEqual( | 97 self.assertEqual( |
| 99 line_adder.get_expectations({'expected': 'FAIL', 'actual': 'TIMEOUT'
}), | 98 updater.get_expectations({'expected': 'FAIL', 'actual': 'TIMEOUT'}), |
| 100 {'Timeout'}) | 99 {'Timeout'}) |
| 101 self.assertEqual( | 100 self.assertEqual( |
| 102 line_adder.get_expectations({'expected': 'TIMEOUT', 'actual': 'PASS'
}), | 101 updater.get_expectations({'expected': 'TIMEOUT', 'actual': 'PASS'}), |
| 103 {'Pass'}) | 102 {'Pass'}) |
| 104 self.assertEqual( | 103 self.assertEqual( |
| 105 line_adder.get_expectations({'expected': 'PASS', 'actual': 'TIMEOUT
CRASH FAIL'}), | 104 updater.get_expectations({'expected': 'PASS', 'actual': 'TIMEOUT CRA
SH FAIL'}), |
| 106 {'Crash', 'Failure', 'Timeout'}) | 105 {'Crash', 'Failure', 'Timeout'}) |
| 107 self.assertEqual( | 106 self.assertEqual( |
| 108 line_adder.get_expectations({'expected': 'SLOW CRASH FAIL TIMEOUT',
'actual': 'PASS'}), | 107 updater.get_expectations({'expected': 'SLOW CRASH FAIL TIMEOUT', 'ac
tual': 'PASS'}), |
| 109 {'Pass'}) | 108 {'Pass'}) |
| 110 | 109 |
| 111 def test_create_line_list_old_tests(self): | 110 def test_create_line_list_old_tests(self): |
| 112 # In this example, there are two failures that are not in w3c tests. | 111 # In this example, there are two failures that are not in w3c tests. |
| 113 line_adder = W3CExpectationsLineAdder(self.host) | 112 updater = WPTExpectationsUpdater(self.host) |
| 114 results = { | 113 results = { |
| 115 'fake/test/path.html': { | 114 'fake/test/path.html': { |
| 116 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 115 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, |
| 117 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 116 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, |
| 118 } | 117 } |
| 119 } | 118 } |
| 120 self.assertEqual(line_adder.create_line_list(results), []) | 119 self.assertEqual(updater.create_line_list(results), []) |
| 121 | 120 |
| 122 def test_create_line_list_new_tests(self): | 121 def test_create_line_list_new_tests(self): |
| 123 # In this example, there are unexpected non-fail results in w3c tests. | 122 # In this example, there are unexpected non-fail results in w3c tests. |
| 124 line_adder = W3CExpectationsLineAdder(self.host) | 123 updater = WPTExpectationsUpdater(self.host) |
| 125 results = { | 124 results = { |
| 126 'external/fake/test/path.html': { | 125 'external/fake/test/path.html': { |
| 127 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 126 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, |
| 128 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c
om/test'}, | 127 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c
om/test'}, |
| 129 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co
m/test'}, | 128 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co
m/test'}, |
| 130 } | 129 } |
| 131 } | 130 } |
| 132 self.assertEqual( | 131 self.assertEqual( |
| 133 line_adder.create_line_list(results), | 132 updater.create_line_list(results), |
| 134 [ | 133 [ |
| 135 'crbug.com/test [ three ] external/fake/test/path.html [ Pass ]'
, | 134 'crbug.com/test [ three ] external/fake/test/path.html [ Pass ]'
, |
| 136 'crbug.com/test [ two ] external/fake/test/path.html [ Timeout ]
', | 135 'crbug.com/test [ two ] external/fake/test/path.html [ Timeout ]
', |
| 137 'crbug.com/test [ one ] external/fake/test/path.html [ Pass ]', | 136 'crbug.com/test [ one ] external/fake/test/path.html [ Pass ]', |
| 138 ]) | 137 ]) |
| 139 | 138 |
| 140 def test_merge_dicts_with_conflict_raise_exception(self): | 139 def test_merge_dicts_with_conflict_raise_exception(self): |
| 141 line_adder = W3CExpectationsLineAdder(self.host) | 140 updater = WPTExpectationsUpdater(self.host) |
| 142 # Both dicts here have the key "one", and the value is not equal. | 141 # Both dicts here have the key "one", and the value is not equal. |
| 143 with self.assertRaises(ValueError): | 142 with self.assertRaises(ValueError): |
| 144 line_adder.merge_dicts( | 143 updater.merge_dicts( |
| 145 { | 144 { |
| 146 'external/fake/test/path.html': { | 145 'external/fake/test/path.html': { |
| 147 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 146 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 148 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 147 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
| 149 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 148 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 150 }, | 149 }, |
| 151 }, | 150 }, |
| 152 { | 151 { |
| 153 'external/fake/test/path.html': { | 152 'external/fake/test/path.html': { |
| 154 'one': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 153 'one': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
| 155 } | 154 } |
| 156 }) | 155 }) |
| 157 | 156 |
| 158 def test_merge_dicts_merges_second_dict_into_first(self): | 157 def test_merge_dicts_merges_second_dict_into_first(self): |
| 159 line_adder = W3CExpectationsLineAdder(self.host) | 158 updater = WPTExpectationsUpdater(self.host) |
| 160 one = { | 159 one = { |
| 161 'fake/test/path.html': { | 160 'fake/test/path.html': { |
| 162 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 161 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 163 'two': {'expected': 'FAIL', 'actual': 'PASS'}, | 162 'two': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 164 } | 163 } |
| 165 } | 164 } |
| 166 two = { | 165 two = { |
| 167 'external/fake/test/path.html': { | 166 'external/fake/test/path.html': { |
| 168 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 167 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 169 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 168 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
| 170 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 169 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 171 } | 170 } |
| 172 } | 171 } |
| 173 three = { | 172 three = { |
| 174 'external/fake/test/path.html': { | 173 'external/fake/test/path.html': { |
| 175 'four': {'expected': 'FAIL', 'actual': 'PASS'}, | 174 'four': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 176 } | 175 } |
| 177 } | 176 } |
| 178 | 177 |
| 179 output = line_adder.merge_dicts(one, three) | 178 output = updater.merge_dicts(one, three) |
| 180 self.assertEqual(output, one) | 179 self.assertEqual(output, one) |
| 181 output = line_adder.merge_dicts(two, three) | 180 output = updater.merge_dicts(two, three) |
| 182 self.assertEqual(output, two) | 181 self.assertEqual(output, two) |
| 183 | 182 |
| 184 def test_generate_results_dict(self): | 183 def test_generate_results_dict(self): |
| 185 line_adder = W3CExpectationsLineAdder(MockHost()) | 184 updater = WPTExpectationsUpdater(MockHost()) |
| 186 layout_test_list = [ | 185 layout_test_list = [ |
| 187 LayoutTestResult( | 186 LayoutTestResult( |
| 188 'test/name.html', { | 187 'test/name.html', { |
| 189 'expected': 'bar', | 188 'expected': 'bar', |
| 190 'actual': 'foo', | 189 'actual': 'foo', |
| 191 'is_unexpected': True, | 190 'is_unexpected': True, |
| 192 'has_stderr': True, | 191 'has_stderr': True, |
| 193 } | 192 } |
| 194 )] | 193 )] |
| 195 self.assertEqual(line_adder.generate_results_dict('dummy_platform', layo
ut_test_list), { | 194 self.assertEqual(updater.generate_results_dict('dummy_platform', layout_
test_list), { |
| 196 'test/name.html': { | 195 'test/name.html': { |
| 197 'dummy_platform': { | 196 'dummy_platform': { |
| 198 'expected': 'bar', | 197 'expected': 'bar', |
| 199 'actual': 'foo', | 198 'actual': 'foo', |
| 200 'bug': 'crbug.com/626703', | 199 'bug': 'crbug.com/626703', |
| 201 } | 200 } |
| 202 } | 201 } |
| 203 }) | 202 }) |
| 204 | 203 |
| 205 def test_write_to_test_expectations_with_marker_comment(self): | 204 def test_write_to_test_expectations_with_marker_comment(self): |
| 206 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 205 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 207 self.host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n' | 206 self.host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n' |
| 208 line_adder = W3CExpectationsLineAdder(self.host) | 207 updater = WPTExpectationsUpdater(self.host) |
| 209 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass
]'] | 208 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass
]'] |
| 210 line_adder.write_to_test_expectations(line_list) | 209 updater.write_to_test_expectations(line_list) |
| 211 value = line_adder.host.filesystem.read_text_file(expectations_path) | 210 value = updater.host.filesystem.read_text_file(expectations_path) |
| 212 self.assertMultiLineEqual( | 211 self.assertMultiLineEqual( |
| 213 value, | 212 value, |
| 214 (MARKER_COMMENT + '\n' | 213 (MARKER_COMMENT + '\n' |
| 215 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) | 214 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) |
| 216 | 215 |
| 217 def test_write_to_test_expectations_with_no_marker_comment(self): | 216 def test_write_to_test_expectations_with_no_marker_comment(self): |
| 218 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 217 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 219 self.host.filesystem.files[expectations_path] = 'crbug.com/111 [ FakePla
tform ]\n' | 218 self.host.filesystem.files[expectations_path] = 'crbug.com/111 [ FakePla
tform ]\n' |
| 220 line_adder = W3CExpectationsLineAdder(self.host) | 219 updater = WPTExpectationsUpdater(self.host) |
| 221 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass
]'] | 220 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass
]'] |
| 222 line_adder.write_to_test_expectations(line_list) | 221 updater.write_to_test_expectations(line_list) |
| 223 value = self.host.filesystem.read_text_file(expectations_path) | 222 value = self.host.filesystem.read_text_file(expectations_path) |
| 224 self.assertMultiLineEqual( | 223 self.assertMultiLineEqual( |
| 225 value, | 224 value, |
| 226 ('crbug.com/111 [ FakePlatform ]\n' | 225 ('crbug.com/111 [ FakePlatform ]\n' |
| 227 '\n' + MARKER_COMMENT + '\n' | 226 '\n' + MARKER_COMMENT + '\n' |
| 228 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]')) | 227 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]')) |
| 229 | 228 |
| 230 def test_write_to_test_expectations_skips_existing_lines(self): | 229 def test_write_to_test_expectations_skips_existing_lines(self): |
| 231 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 230 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 232 self.host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy
/me.html [ Failure ]\n' | 231 self.host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy
/me.html [ Failure ]\n' |
| 233 line_adder = W3CExpectationsLineAdder(self.host) | 232 updater = WPTExpectationsUpdater(self.host) |
| 234 line_list = [ | 233 line_list = [ |
| 235 'crbug.com/111 dont/copy/me.html [ Failure ]', | 234 'crbug.com/111 dont/copy/me.html [ Failure ]', |
| 236 'crbug.com/222 do/copy/me.html [ Failure ]' | 235 'crbug.com/222 do/copy/me.html [ Failure ]' |
| 237 ] | 236 ] |
| 238 line_adder.write_to_test_expectations(line_list) | 237 updater.write_to_test_expectations(line_list) |
| 239 value = self.host.filesystem.read_text_file(expectations_path) | 238 value = self.host.filesystem.read_text_file(expectations_path) |
| 240 self.assertEqual( | 239 self.assertEqual( |
| 241 value, | 240 value, |
| 242 ('crbug.com/111 dont/copy/me.html [ Failure ]\n' | 241 ('crbug.com/111 dont/copy/me.html [ Failure ]\n' |
| 243 '\n' + MARKER_COMMENT + '\n' | 242 '\n' + MARKER_COMMENT + '\n' |
| 244 'crbug.com/222 do/copy/me.html [ Failure ]')) | 243 'crbug.com/222 do/copy/me.html [ Failure ]')) |
| 245 | 244 |
| 246 def test_write_to_test_expectations_with_marker_and_no_lines(self): | 245 def test_write_to_test_expectations_with_marker_and_no_lines(self): |
| 247 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' | 246 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE
xpectations' |
| 248 self.host.filesystem.files[expectations_path] = ( | 247 self.host.filesystem.files[expectations_path] = ( |
| 249 MARKER_COMMENT + '\n' | 248 MARKER_COMMENT + '\n' |
| 250 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n') | 249 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n') |
| 251 line_adder = W3CExpectationsLineAdder(self.host) | 250 updater = WPTExpectationsUpdater(self.host) |
| 252 line_adder.write_to_test_expectations([]) | 251 updater.write_to_test_expectations([]) |
| 253 value = line_adder.host.filesystem.read_text_file(expectations_path) | 252 value = updater.host.filesystem.read_text_file(expectations_path) |
| 254 self.assertMultiLineEqual( | 253 self.assertMultiLineEqual( |
| 255 value, | 254 value, |
| 256 (MARKER_COMMENT + '\n' | 255 (MARKER_COMMENT + '\n' |
| 257 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) | 256 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) |
| 258 | 257 |
| 259 def test_is_js_test_true(self): | 258 def test_is_js_test_true(self): |
| 260 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/foo/bar.html'] = ( | 259 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/foo/bar.html'] = ( |
| 261 '<script src="/resources/testharness.js"></script>') | 260 '<script src="/resources/testharness.js"></script>') |
| 262 line_adder = W3CExpectationsLineAdder(self.host) | 261 updater = WPTExpectationsUpdater(self.host) |
| 263 self.assertTrue(line_adder.is_js_test('foo/bar.html')) | 262 self.assertTrue(updater.is_js_test('foo/bar.html')) |
| 264 | 263 |
| 265 def test_is_js_test_false(self): | 264 def test_is_js_test_false(self): |
| 266 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/foo/bar.html'] = ( | 265 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/foo/bar.html'] = ( |
| 267 '<script src="ref-test.html"></script>') | 266 '<script src="ref-test.html"></script>') |
| 268 line_adder = W3CExpectationsLineAdder(self.host) | 267 updater = WPTExpectationsUpdater(self.host) |
| 269 self.assertFalse(line_adder.is_js_test('foo/bar.html')) | 268 self.assertFalse(updater.is_js_test('foo/bar.html')) |
| 270 | 269 |
| 271 def test_is_js_test_non_existent_file(self): | 270 def test_is_js_test_non_existent_file(self): |
| 272 line_adder = W3CExpectationsLineAdder(self.host) | 271 updater = WPTExpectationsUpdater(self.host) |
| 273 self.assertFalse(line_adder.is_js_test('foo/bar.html')) | 272 self.assertFalse(updater.is_js_test('foo/bar.html')) |
| 274 | 273 |
| 275 def test_get_test_to_rebaseline_returns_only_tests_with_failures(self): | 274 def test_get_test_to_rebaseline_returns_only_tests_with_failures(self): |
| 276 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( | 275 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( |
| 277 '<script src="/resources/testharness.js"></script>') | 276 '<script src="/resources/testharness.js"></script>') |
| 278 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/other/test/path.html'] = ( | 277 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/other/test/path.html'] = ( |
| 279 '<script src="/resources/testharness.js"></script>') | 278 '<script src="/resources/testharness.js"></script>') |
| 280 line_adder = W3CExpectationsLineAdder(self.host) | 279 updater = WPTExpectationsUpdater(self.host) |
| 281 two = { | 280 two = { |
| 282 'external/fake/test/path.html': { | 281 'external/fake/test/path.html': { |
| 283 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 282 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 284 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 283 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
| 285 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 284 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
| 286 } | 285 } |
| 287 } | 286 } |
| 288 tests_to_rebaseline, _ = line_adder.get_tests_to_rebaseline(two) | 287 tests_to_rebaseline, _ = updater.get_tests_to_rebaseline(two) |
| 289 # The other test doesn't have an entry in the test results dict, so it i
s not listed as a test to rebaseline. | 288 # The other test doesn't have an entry in the test results dict, so it i
s not listed as a test to rebaseline. |
| 290 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) | 289 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) |
| 291 | 290 |
| 292 def test_get_test_to_rebaseline_returns_only_js_tests(self): | 291 def test_get_test_to_rebaseline_returns_only_js_tests(self): |
| 293 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( | 292 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( |
| 294 'this file does not look like a testharness JS test.') | 293 'this file does not look like a testharness JS test.') |
| 295 line_adder = W3CExpectationsLineAdder(self.host) | 294 updater = WPTExpectationsUpdater(self.host) |
| 296 two = { | 295 two = { |
| 297 'external/fake/test/path.html': { | 296 'external/fake/test/path.html': { |
| 298 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 297 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, |
| 299 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c
om/test'}, | 298 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c
om/test'}, |
| 300 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co
m/test'}, | 299 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co
m/test'}, |
| 301 } | 300 } |
| 302 } | 301 } |
| 303 tests_to_rebaseline, _ = line_adder.get_tests_to_rebaseline(two) | 302 tests_to_rebaseline, _ = updater.get_tests_to_rebaseline(two) |
| 304 self.assertEqual(tests_to_rebaseline, []) | 303 self.assertEqual(tests_to_rebaseline, []) |
| 305 | 304 |
| 306 def test_get_tests_to_rebaseline_returns_updated_dict(self): | 305 def test_get_tests_to_rebaseline_returns_updated_dict(self): |
| 307 test_results_dict = { | 306 test_results_dict = { |
| 308 'external/fake/test/path.html': { | 307 'external/fake/test/path.html': { |
| 309 'one': {'expected': 'PASS', 'actual': 'TEXT'}, | 308 'one': {'expected': 'PASS', 'actual': 'TEXT'}, |
| 310 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, | 309 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, |
| 311 }, | 310 }, |
| 312 } | 311 } |
| 313 test_results_dict_copy = copy.deepcopy(test_results_dict) | 312 test_results_dict_copy = copy.deepcopy(test_results_dict) |
| 314 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( | 313 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( |
| 315 '<script src="/resources/testharness.js"></script>') | 314 '<script src="/resources/testharness.js"></script>') |
| 316 line_adder = W3CExpectationsLineAdder(self.host) | 315 updater = WPTExpectationsUpdater(self.host) |
| 317 tests_to_rebaseline, modified_test_results = line_adder.get_tests_to_reb
aseline( | 316 tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebase
line( |
| 318 test_results_dict) | 317 test_results_dict) |
| 319 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) | 318 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) |
| 320 # The record for the builder with a timeout is kept, but not with a text
mismatch, | 319 # The record for the builder with a timeout is kept, but not with a text
mismatch, |
| 321 # since that should be covered by downloading a new baseline. | 320 # since that should be covered by downloading a new baseline. |
| 322 self.assertEqual(modified_test_results, { | 321 self.assertEqual(modified_test_results, { |
| 323 'external/fake/test/path.html': { | 322 'external/fake/test/path.html': { |
| 324 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, | 323 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, |
| 325 }, | 324 }, |
| 326 }) | 325 }) |
| 327 # The original dict isn't modified. | 326 # The original dict isn't modified. |
| 328 self.assertEqual(test_results_dict, test_results_dict_copy) | 327 self.assertEqual(test_results_dict, test_results_dict_copy) |
| 329 | 328 |
| 330 def test_get_tests_to_rebaseline_also_returns_slow_tests(self): | 329 def test_get_tests_to_rebaseline_also_returns_slow_tests(self): |
| 331 test_results_dict = { | 330 test_results_dict = { |
| 332 'external/fake/test/path.html': { | 331 'external/fake/test/path.html': { |
| 333 'one': {'expected': 'SLOW', 'actual': 'TEXT'}, | 332 'one': {'expected': 'SLOW', 'actual': 'TEXT'}, |
| 334 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, | 333 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, |
| 335 }, | 334 }, |
| 336 } | 335 } |
| 337 test_results_dict_copy = copy.deepcopy(test_results_dict) | 336 test_results_dict_copy = copy.deepcopy(test_results_dict) |
| 338 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( | 337 self.host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTest
s/external/fake/test/path.html'] = ( |
| 339 '<script src="/resources/testharness.js"></script>') | 338 '<script src="/resources/testharness.js"></script>') |
| 340 line_adder = W3CExpectationsLineAdder(self.host) | 339 updater = WPTExpectationsUpdater(self.host) |
| 341 tests_to_rebaseline, modified_test_results = line_adder.get_tests_to_reb
aseline( | 340 tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebase
line( |
| 342 test_results_dict) | 341 test_results_dict) |
| 343 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) | 342 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) |
| 344 # The record for the builder with a timeout is kept, but not with a text
mismatch, | 343 # The record for the builder with a timeout is kept, but not with a text
mismatch, |
| 345 # since that should be covered by downloading a new baseline. | 344 # since that should be covered by downloading a new baseline. |
| 346 self.assertEqual(modified_test_results, { | 345 self.assertEqual(modified_test_results, { |
| 347 'external/fake/test/path.html': { | 346 'external/fake/test/path.html': { |
| 348 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, | 347 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, |
| 349 }, | 348 }, |
| 350 }) | 349 }) |
| 351 # The original dict isn't modified. | 350 # The original dict isn't modified. |
| 352 self.assertEqual(test_results_dict, test_results_dict_copy) | 351 self.assertEqual(test_results_dict, test_results_dict_copy) |
| 353 | 352 |
| 354 def test_run_no_issue_number(self): | 353 def test_run_no_issue_number(self): |
| 355 line_adder = W3CExpectationsLineAdder(self.host) | 354 updater = WPTExpectationsUpdater(self.host) |
| 356 line_adder.get_issue_number = lambda: 'None' | 355 updater.get_issue_number = lambda: 'None' |
| 357 self.assertEqual(1, line_adder.run(args=[])) | 356 self.assertEqual(1, updater.run(args=[])) |
| 358 self.assertLog(['ERROR: No issue on current branch.\n']) | 357 self.assertLog(['ERROR: No issue on current branch.\n']) |
| 359 | 358 |
| 360 def test_run_no_try_results(self): | 359 def test_run_no_try_results(self): |
| 361 self.host.web = MockWeb(urls={ | 360 self.host.web = MockWeb(urls={ |
| 362 'https://codereview.chromium.org/api/11112222': json.dumps({ | 361 'https://codereview.chromium.org/api/11112222': json.dumps({ |
| 363 'patchsets': [1], | 362 'patchsets': [1], |
| 364 }), | 363 }), |
| 365 'https://codereview.chromium.org/api/11112222/1': json.dumps({ | 364 'https://codereview.chromium.org/api/11112222/1': json.dumps({ |
| 366 'try_job_results': [] | 365 'try_job_results': [] |
| 367 }) | 366 }) |
| 368 }) | 367 }) |
| 369 line_adder = W3CExpectationsLineAdder(self.host) | 368 updater = WPTExpectationsUpdater(self.host) |
| 370 line_adder.get_issue_number = lambda: '11112222' | 369 updater.get_issue_number = lambda: '11112222' |
| 371 line_adder.get_try_bots = lambda: ['test-builder-name'] | 370 updater.get_try_bots = lambda: ['test-builder-name'] |
| 372 self.assertEqual(1, line_adder.run(args=[])) | 371 self.assertEqual(1, updater.run(args=[])) |
| 373 self.assertEqual( | 372 self.assertEqual( |
| 374 self.host.web.urls_fetched, | 373 self.host.web.urls_fetched, |
| 375 [ | 374 [ |
| 376 'https://codereview.chromium.org/api/11112222', | 375 'https://codereview.chromium.org/api/11112222', |
| 377 'https://codereview.chromium.org/api/11112222/1' | 376 'https://codereview.chromium.org/api/11112222/1' |
| 378 ]) | 377 ]) |
| 379 self.assertLog(['ERROR: No try job information was collected.\n']) | 378 self.assertLog(['ERROR: No try job information was collected.\n']) |
| OLD | NEW |