| 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 optparse | 5 import optparse |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from webkitpy.common.net.buildbot import Build | 8 from webkitpy.common.net.buildbot import Build |
| 9 from webkitpy.common.net.layouttestresults import LayoutTestResults | 9 from webkitpy.common.net.layouttestresults import LayoutTestResults |
| 10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 | 10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 new_expectations = self._read(self.mac_expectations_path) | 274 new_expectations = self._read(self.mac_expectations_path) |
| 275 self.assertMultiLineEqual( | 275 self.assertMultiLineEqual( |
| 276 new_expectations, | 276 new_expectations, |
| 277 ("Bug(B) [ Mac Linux Win7 Debug ] fast/dom/Window/window-postmessage
-clone-really-deep-array.html [ Pass ]\n" | 277 ("Bug(B) [ Mac Linux Win7 Debug ] fast/dom/Window/window-postmessage
-clone-really-deep-array.html [ Pass ]\n" |
| 278 "Bug(A) [ Debug ] : fast/css/large-list-of-rules-crash.html [ Failu
re ]\n")) | 278 "Bug(A) [ Debug ] : fast/css/large-list-of-rules-crash.html [ Failu
re ]\n")) |
| 279 | 279 |
| 280 def test_rebaseline_test(self): | 280 def test_rebaseline_test(self): |
| 281 self.command._rebaseline_test("MOCK Trusty", "userscripts/another-test.h
tml", "txt", self.WEB_PREFIX) | 281 self.command._rebaseline_test("MOCK Trusty", "userscripts/another-test.h
tml", "txt", self.WEB_PREFIX) |
| 282 self.assertItemsEqual(self.tool.web.urls_fetched, [self.WEB_PREFIX + '/u
serscripts/another-test-actual.txt']) | 282 self.assertItemsEqual(self.tool.web.urls_fetched, [self.WEB_PREFIX + '/u
serscripts/another-test-actual.txt']) |
| 283 | 283 |
| 284 def test_rebaseline_all_pass_testharness_result_removes_baseline(self): | |
| 285 self.tool.web.urls = { | |
| 286 ('https://storage.googleapis.com/chromium-layout-test-archives' | |
| 287 '/MOCK_Win7/results/layout-test-results/failures/unexpected' | |
| 288 '/text-actual.txt'): 'This is a testharness.js-based test.\n PASS:
foo \n Harness: the test ran to completion.' | |
| 289 } | |
| 290 self._write( | |
| 291 '/test.checkout/LayoutTests/platform/test-win-win7/failures/unexpect
ed/text-expected.txt', | |
| 292 'original baseline') | |
| 293 oc = OutputCapture() | |
| 294 oc.capture_output() | |
| 295 self.command.execute(self.options(builder='MOCK Win7', test="failures/un
expected/text.html"), [], self.tool) | |
| 296 out, _, _ = oc.restore_output() | |
| 297 self.assertEqual('{"remove-lines": [{"test": "failures/unexpected/text.h
tml", "builder": "MOCK Win7"}]}\n', out) | |
| 298 self.assertFalse(self.tool.filesystem.exists( | |
| 299 '/test.checkout/LayoutTests/platform/test-win-win7/failures/unexpect
ed/text-expected.txt')) | |
| 300 | |
| 301 def test_rebaseline_test_non_all_pass_testharness_result(self): | |
| 302 self.tool.web.urls = { | |
| 303 ('https://storage.googleapis.com/chromium-layout-test-archives/MOCK_
Win7' | |
| 304 '/results/layout-test-results/failures/unexpected/text-actual.txt')
: | |
| 305 ('This is some other baseline content, not an all-pass testharness.j
s result.')} | |
| 306 self._write( | |
| 307 '/test.checkout/LayoutTests/platform/test-win-win7/failures/unexpect
ed/text-expected.txt', | |
| 308 'original baseline') | |
| 309 oc = OutputCapture() | |
| 310 oc.capture_output() | |
| 311 self.command.execute(self.options(builder='MOCK Win7', test="failures/un
expected/text.html"), [], self.tool) | |
| 312 out, _, _ = oc.restore_output() | |
| 313 self.assertEqual('{"remove-lines": [{"test": "failures/unexpected/text.h
tml", "builder": "MOCK Win7"}]}\n', out) | |
| 314 self.assertTrue(self.tool.filesystem.exists( | |
| 315 '/test.checkout/LayoutTests/platform/test-win-win7/failures/unexpect
ed/text-expected.txt')) | |
| 316 | |
| 317 def test_rebaseline_test_with_results_directory(self): | 284 def test_rebaseline_test_with_results_directory(self): |
| 318 self._write("userscripts/another-test.html", "test data") | 285 self._write("userscripts/another-test.html", "test data") |
| 319 self._write( | 286 self._write( |
| 320 self.mac_expectations_path, | 287 self.mac_expectations_path, |
| 321 ("Bug(x) [ Mac ] userscripts/another-test.html [ Failure ]\n" | 288 ("Bug(x) [ Mac ] userscripts/another-test.html [ Failure ]\n" |
| 322 "bug(z) [ Linux ] userscripts/another-test.html [ Failure ]\n")) | 289 "bug(z) [ Linux ] userscripts/another-test.html [ Failure ]\n")) |
| 323 self.command._rebaseline_test_and_update_expectations(self.options(resul
ts_directory='/tmp')) | 290 self.command._rebaseline_test_and_update_expectations(self.options(resul
ts_directory='/tmp')) |
| 324 self.assertItemsEqual(self.tool.web.urls_fetched, ['file:///tmp/userscri
pts/another-test-actual.txt']) | 291 self.assertItemsEqual(self.tool.web.urls_fetched, ['file:///tmp/userscri
pts/another-test-actual.txt']) |
| 325 | 292 |
| 326 def test_rebaseline_reftest(self): | 293 def test_rebaseline_reftest(self): |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 336 |
| 370 | 337 |
| 371 class TestAbstractParallelRebaselineCommand(BaseTestCase): | 338 class TestAbstractParallelRebaselineCommand(BaseTestCase): |
| 372 command_constructor = AbstractParallelRebaselineCommand | 339 command_constructor = AbstractParallelRebaselineCommand |
| 373 | 340 |
| 374 def test_builders_to_fetch_from(self): | 341 def test_builders_to_fetch_from(self): |
| 375 builders_to_fetch = self.command._builders_to_fetch_from( | 342 builders_to_fetch = self.command._builders_to_fetch_from( |
| 376 ["MOCK Win10", "MOCK Win7 (dbg)(1)", "MOCK Win7 (dbg)(2)", "MOCK Win
7"]) | 343 ["MOCK Win10", "MOCK Win7 (dbg)(1)", "MOCK Win7 (dbg)(2)", "MOCK Win
7"]) |
| 377 self.assertEqual(builders_to_fetch, ["MOCK Win7", "MOCK Win10"]) | 344 self.assertEqual(builders_to_fetch, ["MOCK Win7", "MOCK Win10"]) |
| 378 | 345 |
| 346 def test_all_baseline_paths(self): |
| 347 test_prefix_list = { |
| 348 'passes/text.html': { |
| 349 Build('MOCK Win7'): ('txt', 'png'), |
| 350 Build('MOCK Win10'): ('txt',), |
| 351 } |
| 352 } |
| 353 # pylint: disable=protected-access |
| 354 baseline_paths = self.command._all_baseline_paths(test_prefix_list) |
| 355 self.assertEqual(baseline_paths, [ |
| 356 '/test.checkout/LayoutTests/passes/text-expected.png', |
| 357 '/test.checkout/LayoutTests/passes/text-expected.txt', |
| 358 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.txt', |
| 359 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.png', |
| 360 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.txt', |
| 361 ]) |
| 362 |
| 363 def test_remove_all_pass_testharness_baselines(self): |
| 364 self.tool.filesystem.write_text_file( |
| 365 '/test.checkout/LayoutTests/passes/text-expected.txt', |
| 366 ('This is a testharness.js-based test.\n' |
| 367 'PASS: foo\n' |
| 368 'Harness: the test ran to completion.\n')) |
| 369 test_prefix_list = { |
| 370 'passes/text.html': { |
| 371 Build('MOCK Win7'): ('txt', 'png'), |
| 372 Build('MOCK Win10'): ('txt',), |
| 373 } |
| 374 } |
| 375 self.command._remove_all_pass_testharness_baselines(test_prefix_list) |
| 376 self.assertFalse(self.tool.filesystem.exists( |
| 377 '/test.checkout/LayoutTests/passes/text-expected.txt')) |
| 378 |
| 379 | 379 |
| 380 class TestRebaselineJson(BaseTestCase): | 380 class TestRebaselineJson(BaseTestCase): |
| 381 command_constructor = RebaselineJson | 381 command_constructor = RebaselineJson |
| 382 | 382 |
| 383 def setUp(self): | 383 def setUp(self): |
| 384 super(TestRebaselineJson, self).setUp() | 384 super(TestRebaselineJson, self).setUp() |
| 385 self.tool.executive = MockExecutive2() | 385 self.tool.executive = MockExecutive2() |
| 386 | 386 |
| 387 def tearDown(self): | 387 def tearDown(self): |
| 388 super(TestRebaselineJson, self).tearDown() | 388 super(TestRebaselineJson, self).tearDown() |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 for cmd_line, cwd in commands: | 927 for cmd_line, cwd in commands: |
| 928 out = self.run_command(cmd_line, cwd=cwd) | 928 out = self.run_command(cmd_line, cwd=cwd) |
| 929 if 'rebaseline-test-internal' in cmd_line: | 929 if 'rebaseline-test-internal' in cmd_line: |
| 930 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) | 930 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) |
| 931 command_outputs.append([0, out, '']) | 931 command_outputs.append([0, out, '']) |
| 932 | 932 |
| 933 new_calls = self.calls[num_previous_calls:] | 933 new_calls = self.calls[num_previous_calls:] |
| 934 self.calls = self.calls[:num_previous_calls] | 934 self.calls = self.calls[:num_previous_calls] |
| 935 self.calls.append(new_calls) | 935 self.calls.append(new_calls) |
| 936 return command_outputs | 936 return command_outputs |
| OLD | NEW |