Changeset 96272 in webkit
- Timestamp:
- Sep 28, 2011 5:09:39 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r96270 r96272 1 2011-09-28 Dirk Pranke <dpranke@chromium.org> 2 3 Modify new-run-webkit-tests to return the percentage difference in image diffs where possible. 4 5 https://bugs.webkit.org/show_bug.cgi?id=67253 6 7 Reviewed by Eric Seidel. 8 9 * fast/harness/resources/results-test.js: 10 (mockExpectation): 11 (runDefaultSingleRowTest): 12 (): 13 * fast/harness/results.html: 14 1 15 2011-09-28 Chris Rogers <crogers@google.com> 2 16 -
trunk/LayoutTests/fast/harness/resources/results-test.js
r89873 r96272 35 35 } 36 36 37 function mockExpectation(expected, actual) 38 { 37 function mockExpectation(expected, actual, diff_percentage) 38 { 39 diff_percentage = (typeof(diff_percentage) == undefined) ? 0 : diff_percentage; 39 40 return { 40 41 expected: expected, 41 42 time_ms: 1, 42 43 actual: actual, 44 image_diff_percent: diff_percentage, 43 45 has_stderr: false 44 46 }; … … 84 86 } 85 87 86 function runDefaultSingleRowTest(test, expected, actual, isExpected, textResults, imageResults)87 { 88 results = mockResults(); 89 results.tests[test] = mockExpectation(expected, actual );88 function runDefaultSingleRowTest(test, expected, actual, diff_percentage, isExpected, textResults, imageResults) 89 { 90 results = mockResults(); 91 results.tests[test] = mockExpectation(expected, actual, diff_percentage); 90 92 runSingleRowTest(results, isExpected, textResults, imageResults); 91 93 } … … 246 248 }); 247 249 248 runDefaultSingleRowTest('bar-skip.html', 'TEXT', 'SKIP', true, '', '');249 runDefaultSingleRowTest('bar-flaky-fail.html', 'PASS FAIL', 'TEXT', true, 'expected actual diff ', '');250 runDefaultSingleRowTest('bar-flaky-fail-unexpected.html', 'PASS TEXT', 'IMAGE', false, '', 'images diff');251 runDefaultSingleRowTest('bar-audio.html', 'TEXT', 'AUDIO', false, 'expected audio actual audio ', '');252 runDefaultSingleRowTest('bar-image.html', 'TEXT', 'IMAGE', false, '', 'images diff');253 runDefaultSingleRowTest('bar-image-plus-text.html', 'TEXT', 'IMAGE+TEXT', false, 'expected actual diff ', 'images diff');254 255 results = mockResults(); 256 results.tests['bar-reftest.html'] = mockExpectation('PASS', 'IMAGE' );250 runDefaultSingleRowTest('bar-skip.html', 'TEXT', 'SKIP', 0, true, '', ''); 251 runDefaultSingleRowTest('bar-flaky-fail.html', 'PASS FAIL', 'TEXT', 0, true, 'expected actual diff ', ''); 252 runDefaultSingleRowTest('bar-flaky-fail-unexpected.html', 'PASS TEXT', 'IMAGE', 1, false, '', 'images diff (1%) '); 253 runDefaultSingleRowTest('bar-audio.html', 'TEXT', 'AUDIO', 0, false, 'expected audio actual audio ', ''); 254 runDefaultSingleRowTest('bar-image.html', 'TEXT', 'IMAGE', 1, false, '', 'images diff (1%) '); 255 runDefaultSingleRowTest('bar-image-plus-text.html', 'TEXT', 'IMAGE+TEXT', 1, false, 'expected actual diff ', 'images diff (1%) '); 256 257 results = mockResults(); 258 results.tests['bar-reftest.html'] = mockExpectation('PASS', 'IMAGE', 1); 257 259 results.tests['bar-reftest.html'].is_reftest = true; 258 runSingleRowTest(results, false, '', 'ref html images diff ');260 runSingleRowTest(results, false, '', 'ref html images diff (1%) '); 259 261 260 262 results = mockResults(); … … 411 413 412 414 results = mockResults(); 413 results.tests['bar.html'] = mockExpectation('PASS', 'IMAGE' );414 runTest(results, function() { 415 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'images diff ');415 results.tests['bar.html'] = mockExpectation('PASS', 'IMAGE', 1); 416 runTest(results, function() { 417 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'images diff (1%) '); 416 418 417 419 document.getElementById('toggle-images').checked = false; … … 419 421 updateTogglingImages(); 420 422 // FIXME: We get extra spaces in the DOM every time we enable/disable image toggling. 421 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'expected actual diff ');423 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'expected actual diff (1%) '); 422 424 423 425 document.getElementById('toggle-images').checked = true; 424 426 updateTogglingImages(); 425 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == ' images diff ');426 }); 427 428 results = mockResults(); 429 results.tests['reading-options-from-localstorage.html'] = mockExpectation('IMAGE+TEXT', 'IMAGE+TEXT' );427 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == ' images diff (1%) '); 428 }); 429 430 results = mockResults(); 431 results.tests['reading-options-from-localstorage.html'] = mockExpectation('IMAGE+TEXT', 'IMAGE+TEXT', 1); 430 432 runTest(results, function() { 431 433 assertTrue(window.getComputedStyle(document.querySelector('tbody'), null)['display'] != 'none'); 432 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'expected actual diff ');434 assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'expected actual diff (1%) '); 433 435 }, '{"toggle-images":false,"unexpected-results":false}'); 434 436 -
trunk/LayoutTests/fast/harness/results.html
r94212 r96272 546 546 } 547 547 548 // FIXME: old-run-webkit-tests shows the diff percentage as the text contents of the "diff" link.549 row += resultLink(test_prefix, '-diff.png', 'diff ');548 var diff = testObject.image_diff_percent; 549 row += resultLink(test_prefix, '-diff.png', 'diff (' + diff + '%)'); 550 550 } 551 551 } -
trunk/Tools/ChangeLog
r96268 r96272 1 2011-09-28 Dirk Pranke <dpranke@chromium.org> 2 3 Modify new-run-webkit-tests to return the percentage difference in image diffs where possible. 4 5 https://bugs.webkit.org/show_bug.cgi?id=67253 6 7 Reviewed by Eric Seidel. 8 9 Nearly all of the work in this was done by Simon Fraser; I'm 10 just repackaging it and cleaning it up a bit. This change 11 modifies port.diff_image() to return a tuple of (pass/fail, 12 %age), adds the value to the FailureImageHashMismatch, and 13 writes the value into the full_results.json files to be 14 displayed in the results page. 15 16 * Scripts/webkitpy/layout_tests/controllers/manager.py: 17 * Scripts/webkitpy/layout_tests/controllers/single_test_runner.py: 18 * Scripts/webkitpy/layout_tests/layout_package/test_result_writer.py: 19 * Scripts/webkitpy/layout_tests/models/test_failures.py: 20 * Scripts/webkitpy/layout_tests/port/base.py: 21 * Scripts/webkitpy/layout_tests/port/chromium.py: 22 * Scripts/webkitpy/layout_tests/port/chromium_unittest.py: 23 * Scripts/webkitpy/layout_tests/port/port_testcase.py: 24 * Scripts/webkitpy/layout_tests/port/test.py: 25 * Scripts/webkitpy/layout_tests/port/webkit.py: 26 * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py: 27 1 28 2011-09-25 Kentaro Hara <haraken@chromium.org> 2 29 -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
r95441 r96272 171 171 if 'is_reftest' in result.failures: 172 172 test_dict['is_reftest'] = True 173 if type(f) is test_failures.FailureImageHashMismatch: 174 test_dict['image_diff_percent'] = f.diff_percent 173 175 174 176 if test_failures.FailureReftestMismatchDidNotOccur in failure_types: -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py
r90532 r96272 277 277 failures.append(test_failures.FailureMissingImageHash()) 278 278 elif driver_output.image_hash != expected_driver_output.image_hash: 279 driver_output.image_diff = self._port.diff_image(driver_output.image, expected_driver_output.image) 279 diff_result = self._port.diff_image(driver_output.image, expected_driver_output.image) 280 driver_output.image_diff = diff_result[0] 280 281 if driver_output.image_diff: 281 failures.append(test_failures.FailureImageHashMismatch( ))282 failures.append(test_failures.FailureImageHashMismatch(diff_result[1])) 282 283 return failures 283 284 -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_result_writer.py
r90532 r96272 71 71 writer.write_image_files(driver_output.image, expected_driver_output.image) 72 72 # FIXME: This work should be done earlier in the pipeline (e.g., when we compare images for non-ref tests). 73 image_diff = port.diff_image(driver_output.image, expected_driver_output.image) 73 image_diff = port.diff_image(driver_output.image, expected_driver_output.image)[0] 74 74 if image_diff: 75 75 writer.write_image_diff_files(image_diff) -
trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py
r90532 r96272 168 168 class FailureImageHashMismatch(TestFailure): 169 169 """Image hashes didn't match.""" 170 def __init__(self, diff_percent=0): 171 self.diff_percent = diff_percent 170 172 171 173 @staticmethod -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py
r93166 r96272 258 258 259 259 def diff_image(self, expected_contents, actual_contents, tolerance=0): 260 """Compare two images and return a n image diff.260 """Compare two images and return a tuple of an image diff, and a percentage difference (0-100). 261 261 262 262 |tolerance| should be a percentage value (0.0 - 100.0). -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py
r95875 r96272 169 169 # If only one of them exists, return that one. 170 170 if not actual_contents and not expected_contents: 171 return None171 return (None, 0) 172 172 if not actual_contents: 173 return expected_contents173 return (expected_contents, 0) 174 174 if not expected_contents: 175 return actual_contents175 return (actual_contents, 0) 176 176 177 177 tempdir = self._filesystem.mkdtemp() … … 214 214 result = self._filesystem.read_binary_file(native_diff_filename) 215 215 self._filesystem.rmtree(str(tempdir)) 216 return result216 return (result, 0) # FIXME: how to get % diff? 217 217 218 218 def path_from_chromium_base(self, *comps): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py
r94219 r96272 263 263 # Images are different. 264 264 port._executive = executive_mock.MockExecutive2(run_command_fn=mock_run_command) 265 self.assertEquals(mock_image_diff, port.diff_image("EXPECTED", "ACTUAL") )265 self.assertEquals(mock_image_diff, port.diff_image("EXPECTED", "ACTUAL")[0]) 266 266 267 267 # Images are the same. 268 268 port._executive = executive_mock.MockExecutive2(exit_code=0) 269 self.assertEquals(None, port.diff_image("EXPECTED", "ACTUAL") )269 self.assertEquals(None, port.diff_image("EXPECTED", "ACTUAL")[0]) 270 270 271 271 # There was some error running image_diff. -
trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py
r93176 r96272 227 227 tmpfd.close() 228 228 229 self.assertFalse(port.diff_image(contents1, contents1) )230 self.assertTrue(port.diff_image(contents1, contents2) )231 232 self.assertTrue(port.diff_image(contents1, contents2, tmpfile) )229 self.assertFalse(port.diff_image(contents1, contents1)[0]) 230 self.assertTrue(port.diff_image(contents1, contents2)[0]) 231 232 self.assertTrue(port.diff_image(contents1, contents2, tmpfile)[0]) 233 233 234 234 port._filesystem.remove(tmpfile) … … 238 238 if not port: 239 239 return 240 self.assertFalse(port.diff_image(None, None) )241 self.assertFalse(port.diff_image(None, '') )242 self.assertFalse(port.diff_image('', None) )243 self.assertFalse(port.diff_image('', '') )240 self.assertFalse(port.diff_image(None, None)[0]) 241 self.assertFalse(port.diff_image(None, '')[0]) 242 self.assertFalse(port.diff_image('', None)[0]) 243 self.assertFalse(port.diff_image('', '')[0]) 244 244 245 245 def test_diff_image__missing_actual(self): … … 247 247 if not port: 248 248 return 249 self.assertTrue(port.diff_image(None, 'foo') )250 self.assertTrue(port.diff_image('', 'foo') )249 self.assertTrue(port.diff_image(None, 'foo')[0]) 250 self.assertTrue(port.diff_image('', 'foo')[0]) 251 251 252 252 def test_diff_image__missing_expected(self): … … 254 254 if not port: 255 255 return 256 self.assertTrue(port.diff_image('foo', None) )257 self.assertTrue(port.diff_image('foo', '') )256 self.assertTrue(port.diff_image('foo', None)[0]) 257 self.assertTrue(port.diff_image('foo', '')[0]) 258 258 259 259 def test_check_build(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py
r94316 r96272 326 326 diffed = actual_contents != expected_contents 327 327 if diffed: 328 return "< %s\n---\n> %s\n" % (expected_contents, actual_contents)329 return None328 return ["< %s\n---\n> %s\n" % (expected_contents, actual_contents), 1] 329 return (None, 0) 330 330 331 331 def layout_tests_dir(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py
r95911 r96272 152 152 # FIXME: need unit tests for this. 153 153 if not actual_contents and not expected_contents: 154 return None154 return (None, 0) 155 155 if not actual_contents or not expected_contents: 156 156 # FIXME: It's not clear what we should return in this case. 157 157 # Maybe we should throw an exception? 158 return True158 return (True, 0) 159 159 160 160 process = self._start_image_diff_process(expected_contents, actual_contents) … … 181 181 deadline = time.time() + timeout 182 182 output = sp.read_line(timeout) 183 output_image = "" 184 diff_percent = 0 183 185 while not sp.timed_out and not sp.crashed and output: 184 186 if output.startswith('Content-Length'): … … 186 188 content_length = int(m.group(1)) 187 189 timeout = deadline - time.time() 188 output = sp.read(timeout, content_length) 190 output_image = sp.read(timeout, content_length) 191 output = sp.read_line(timeout) 189 192 break 190 193 elif output.startswith('diff'): … … 202 205 m = re.match('diff: (.+)% (passed|failed)', output) 203 206 if m.group(2) == 'passed': 204 return None 205 return output 207 return [None, 0] 208 diff_percent = float(m.group(1)) 209 return (output_image, diff_percent) 206 210 207 211 def default_results_directory(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py
r95441 r96272 50 50 multiprocessing = None 51 51 52 try: 53 import json 54 except ImportError: 55 # python 2.5 compatibility 56 import webkitpy.thirdparty.simplejson as json 57 52 58 # FIXME: remove this when we fix test-webkitpy to work properly on cygwin 53 59 # (bug 63846). … … 581 587 def diff_image(self, expected_contents, actual_contents): 582 588 self.tolerance_used_for_diff_image = self._options.tolerance 583 return True589 return (True, 1) 584 590 585 591 def get_port_for_run(args): … … 675 681 MainTest = skip_if(MainTest, sys.platform == 'cygwin' and compare_version(sys, '2.6')[0] < 0, 'new-run-webkit-tests tests hang on Cygwin Python 2.5.2') 676 682 683 684 class EndToEndTest(unittest.TestCase): 685 def parse_full_results(self, full_results_text): 686 json_to_eval = full_results_text.replace("ADD_RESULTS(", "").replace(");", "") 687 compressed_results = json.loads(json_to_eval) 688 return compressed_results 689 690 def test_end_to_end(self): 691 fs = unit_test_filesystem() 692 res, out, err, user = logging_run(record_results=True, tests_included=True, filesystem=fs) 693 694 # Six tests should fail, so the return code should be 6. 695 self.assertEquals(res, 6) 696 results = self.parse_full_results(fs.files['/tmp/layout-test-results/full_results.json']) 697 698 # Check to ensure we're passing back image diff %age correctly. 699 self.assertEquals(results['tests']['failures']['expected']['image.html']['image_diff_percent'], 1) 700 701 # Check that we attempted to display the results page in a browser. 702 self.assertTrue(user.opened_urls) 677 703 678 704 class RebaselineTest(unittest.TestCase): -
trunk/Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests.py
r94031 r96272 515 515 516 516 if is_image: 517 return self._port.diff_image(output1, output2) 517 return self._port.diff_image(output1, output2)[0] 518 518 519 519 return self._port.compare_text(output1, output2) … … 600 600 old_output = self._filesystem.read_binary_file(old_file) 601 601 new_output = self._filesystem.read_binary_file(new_file) 602 image_diff = self._port.diff_image(old_output, new_output) 602 image_diff = self._port.diff_image(old_output, new_output)[0] 603 603 self._filesystem.write_binary_file(diff_file, image_diff) 604 604
Note: See TracChangeset
for help on using the changeset viewer.