Changeset 77603 in webkit
- Timestamp:
- Feb 3, 2011 9:36:15 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r77595 r77603 1 2011-02-03 Hayato Ito <hayato@chromium.org> 2 3 Reviewed by Tony Chang. 4 5 [NRWT] Introduces Input/Output class used by base.Driver into port/base.py and 6 move _run_single_test() and _process_output() functions from 7 dump_render_tree_thread.py to a single_test_runner.py as an individual module. 8 9 This is clean up and acts as a preparation for elimination of test_types/* 10 classes. These classes will move to the single_test_runner module introduced 11 in this patch. 12 13 https://bugs.webkit.org/show_bug.cgi?id=53004 14 15 * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py: 16 * Scripts/webkitpy/layout_tests/layout_package/single_test_runner.py: Added. 17 * Scripts/webkitpy/layout_tests/layout_package/test_input.py: 18 * Scripts/webkitpy/layout_tests/layout_package/test_output.py: Removed. 19 * Scripts/webkitpy/layout_tests/port/base.py: 20 * Scripts/webkitpy/layout_tests/port/chromium.py: 21 * Scripts/webkitpy/layout_tests/port/dryrun.py: 22 * Scripts/webkitpy/layout_tests/port/test.py: 23 * Scripts/webkitpy/layout_tests/port/webkit.py: 24 * Scripts/webkitpy/layout_tests/test_types/image_diff.py: 25 * Scripts/webkitpy/layout_tests/test_types/test_type_base.py: 26 * Scripts/webkitpy/layout_tests/test_types/text_diff.py: 27 1 28 2011-02-03 Dirk Pranke <dpranke@chromium.org> 2 29 -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py
r76199 r77603 52 52 from webkitpy.layout_tests.test_types import text_diff 53 53 54 import single_test_runner 54 55 import test_failures 55 import test_output56 56 import test_results 57 57 58 58 _log = logging.getLogger("webkitpy.layout_tests.layout_package." 59 59 "dump_render_tree_thread") 60 61 62 def _expected_test_output(port, filename):63 """Returns an expected TestOutput object."""64 return test_output.TestOutput(port.expected_text(filename),65 port.expected_image(filename),66 port.expected_checksum(filename))67 68 def _process_output(port, options, test_input, test_types, test_args,69 test_output, worker_name):70 """Receives the output from a DumpRenderTree process, subjects it to a71 number of tests, and returns a list of failure types the test produced.72 73 Args:74 port: port-specific hooks75 options: command line options argument from optparse76 proc: an active DumpRenderTree process77 test_input: Object containing the test filename and timeout78 test_types: list of test types to subject the output to79 test_args: arguments to be passed to each test80 test_output: a TestOutput object containing the output of the test81 worker_name: worker name for logging82 83 Returns: a TestResult object84 """85 failures = []86 fs = port._filesystem87 88 if test_output.crash:89 failures.append(test_failures.FailureCrash())90 if test_output.timeout:91 failures.append(test_failures.FailureTimeout())92 93 test_name = port.relative_test_filename(test_input.filename)94 if test_output.crash:95 _log.debug("%s Stacktrace for %s:\n%s" % (worker_name, test_name,96 test_output.error))97 filename = fs.join(options.results_directory, test_name)98 filename = fs.splitext(filename)[0] + "-stack.txt"99 fs.maybe_make_directory(fs.dirname(filename))100 fs.write_text_file(filename, test_output.error)101 elif test_output.error:102 _log.debug("%s %s output stderr lines:\n%s" % (worker_name, test_name,103 test_output.error))104 105 expected_test_output = _expected_test_output(port, test_input.filename)106 107 # Check the output and save the results.108 start_time = time.time()109 time_for_diffs = {}110 for test_type in test_types:111 start_diff_time = time.time()112 new_failures = test_type.compare_output(port, test_input.filename,113 test_args, test_output,114 expected_test_output)115 # Don't add any more failures if we already have a crash, so we don't116 # double-report those tests. We do double-report for timeouts since117 # we still want to see the text and image output.118 if not test_output.crash:119 failures.extend(new_failures)120 time_for_diffs[test_type.__class__.__name__] = (121 time.time() - start_diff_time)122 123 total_time_for_all_diffs = time.time() - start_diff_time124 return test_results.TestResult(test_input.filename, failures, test_output.test_time,125 total_time_for_all_diffs, time_for_diffs)126 60 127 61 … … 143 77 def _should_fetch_expected_checksum(options): 144 78 return options.pixel_tests and not (options.new_baseline or options.reset_results) 145 146 147 def _run_single_test(port, options, test_input, test_types, test_args, driver, worker_name):148 # FIXME: Pull this into TestShellThread._run().149 150 # The image hash is used to avoid doing an image dump if the151 # checksums match, so it should be set to a blank value if we152 # are generating a new baseline. (Otherwise, an image from a153 # previous run will be copied into the baseline."""154 if _should_fetch_expected_checksum(options):155 test_input.image_hash = port.expected_checksum(test_input.filename)156 test_output = driver.run_test(test_input)157 return _process_output(port, options, test_input, test_types, test_args,158 test_output, worker_name)159 79 160 80 … … 194 114 self._driver = self._port.create_driver(self._worker_number) 195 115 self._driver.start() 196 self._test_result = _run_single_test(self._port, self._options, 197 self._test_input, self._test_types, 198 self._test_args, self._driver, 199 self._name) 116 self._test_result = single_test_runner.run_single_test( 117 self._port, self._options, self._test_input, self._driver, 118 self._name, self._test_types, self._test_args) 200 119 self._driver.stop() 201 120 … … 515 434 _pad_timeout(int(test_input.timeout))) 516 435 self._next_timeout = time.time() + thread_timeout 517 test_result = _run_single_test(self._port, self._options, test_input,518 self._test_types, self._test_args,519 self._driver, self._name)436 test_result = single_test_runner.run_single_test( 437 self._port, self._options, test_input, self._driver, self._name, 438 self._test_types, self._test_args) 520 439 self._test_results.append(test_result) 521 440 return test_result -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_input.py
r74525 r77603 42 42 self.filename = filename 43 43 self.timeout = timeout 44 # The image_hash is used to avoid doing an image dump if the45 # checksums match. The image_hash is set later, and only if it is needed46 # for the test.47 self.image_hash = None -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py
r77551 r77603 822 822 823 823 824 class DriverInput(object): 825 """Holds the input parameters for a driver.""" 826 827 def __init__(self, filename, timeout, image_hash): 828 """Initializes a DriverInput object. 829 830 Args: 831 filename: Full path to the test. 832 timeout: Timeout in msecs the driver should use while running the test 833 image_hash: A image checksum which is used to avoid doing an image dump if 834 the checksums match. 835 """ 836 self.filename = filename 837 self.timeout = timeout 838 self.image_hash = image_hash 839 840 841 class DriverOutput(object): 842 """Groups information about a output from driver for easy passing of data.""" 843 844 def __init__(self, text, image, image_hash, 845 crash=False, test_time=None, timeout=False, error=''): 846 """Initializes a TestOutput object. 847 848 Args: 849 text: a text output 850 image: an image output 851 image_hash: a string containing the checksum of the image 852 crash: a boolean indicating whether the driver crashed on the test 853 test_time: a time which the test has taken 854 timeout: a boolean indicating whehter the test timed out 855 error: any unexpected or additional (or error) text output 856 """ 857 self.text = text 858 self.image = image 859 self.image_hash = image_hash 860 self.crash = crash 861 self.test_time = test_time 862 self.timeout = timeout 863 self.error = error 864 865 824 866 class Driver: 825 867 """Abstract interface for the DumpRenderTree interface.""" … … 836 878 raise NotImplementedError('Driver.__init__') 837 879 838 def run_test(self, test_input):880 def run_test(self, driver_input): 839 881 """Run a single test and return the results. 840 882 … … 844 886 845 887 Args: 846 test_input: a TestInput object847 848 Returns a TestOutput object.888 driver_input: a DriverInput object 889 890 Returns a DriverOutput object. 849 891 """ 850 892 raise NotImplementedError('Driver.run_test') -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py
r77415 r77603 42 42 from webkitpy.common.system.path import cygpath 43 43 from webkitpy.layout_tests.layout_package import test_expectations 44 from webkitpy.layout_tests.layout_package import test_output45 44 46 45 import base … … 446 445 return self._output_image() 447 446 448 def run_test(self, test_input):447 def run_test(self, driver_input): 449 448 output = [] 450 449 error = [] … … 456 455 start_time = time.time() 457 456 458 uri = self._port.filename_to_uri( test_input.filename)459 cmd = self._test_shell_command(uri, test_input.timeout,460 test_input.image_hash)457 uri = self._port.filename_to_uri(driver_input.filename) 458 cmd = self._test_shell_command(uri, driver_input.timeout, 459 driver_input.image_hash) 461 460 (line, crash) = self._write_command_and_read_line(input=cmd) 462 461 … … 500 499 501 500 run_time = time.time() - start_time 502 return test_output.TestOutput(501 return base.DriverOutput( 503 502 ''.join(output), self._output_image_with_retry(), actual_checksum, 504 503 crash, run_time, timeout, ''.join(error)) -
trunk/Tools/Scripts/webkitpy/layout_tests/port/dryrun.py
r76982 r77603 50 50 import sys 51 51 import time 52 53 from webkitpy.layout_tests.layout_package import test_output54 52 55 53 import base … … 119 117 return None 120 118 121 def run_test(self, test_input):119 def run_test(self, driver_input): 122 120 start_time = time.time() 123 text_output = self._port.expected_text( test_input.filename)121 text_output = self._port.expected_text(driver_input.filename) 124 122 125 if test_input.image_hash is not None:126 image = self._port.expected_image( test_input.filename)127 hash = self._port.expected_checksum( test_input.filename)123 if driver_input.image_hash is not None: 124 image = self._port.expected_image(driver_input.filename) 125 hash = self._port.expected_checksum(driver_input.filename) 128 126 else: 129 127 image = None 130 128 hash = None 131 return test_output.TestOutput(text_output, image, hash, False,132 time.time() - start_time, False, None)129 return base.DriverOutput(text_output, image, hash, False, 130 time.time() - start_time, False, '') 133 131 134 132 def start(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py
r77550 r77603 35 35 from webkitpy.common.system import filesystem_mock 36 36 from webkitpy.tool import mocktool 37 38 from webkitpy.layout_tests.layout_package import test_output39 37 40 38 import base … … 385 383 if test.hang: 386 384 time.sleep((float(test_input.timeout) * 4) / 1000.0) 387 return test_output.TestOutput(test.actual_text, test.actual_image,388 389 390 385 return base.DriverOutput(test.actual_text, test.actual_image, 386 test.actual_checksum, test.crash, 387 time.time() - start_time, test.timeout, 388 test.error) 391 389 392 390 def start(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py
r77163 r77603 42 42 43 43 import webkitpy.common.system.ospath as ospath 44 import webkitpy.layout_tests.layout_package.test_output as test_output45 44 import webkitpy.layout_tests.port.base as base 46 45 import webkitpy.layout_tests.port.server_process as server_process … … 406 405 407 406 # FIXME: This function is huge. 408 def run_test(self, test_input):409 uri = self._port.filename_to_uri( test_input.filename)407 def run_test(self, driver_input): 408 uri = self._port.filename_to_uri(driver_input.filename) 410 409 if uri.startswith("file:///"): 411 410 command = uri[7:] … … 413 412 command = uri 414 413 415 if test_input.image_hash:416 command += "'" + test_input.image_hash414 if driver_input.image_hash: 415 command += "'" + driver_input.image_hash 417 416 command += "\n" 418 417 … … 425 424 image = str() 426 425 427 timeout = int( test_input.timeout) / 1000.0426 timeout = int(driver_input.timeout) / 1000.0 428 427 deadline = time.time() + timeout 429 428 line = self._server_process.read_line(timeout) … … 472 471 # this reset in. 473 472 self._server_process.error = "" 474 return test_output.TestOutput(output, image, actual_image_hash,475 476 477 478 473 return base.DriverOutput(output, image, actual_image_hash, 474 self._server_process.crashed, 475 time.time() - start_time, 476 self._server_process.timed_out, 477 error) 479 478 480 479 def stop(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
r76322 r77603 86 86 return port.diff_image(actual_image, expected_image, diff_filename) 87 87 88 def compare_output(self, port, filename, test_args, actual_ test_output,89 expected_ test_output):88 def compare_output(self, port, filename, test_args, actual_driver_output, 89 expected_driver_output): 90 90 """Implementation of CompareOutput that checks the output image and 91 91 checksum against the expected files from the LayoutTest directory. … … 94 94 95 95 # If we didn't produce a hash file, this test must be text-only. 96 if actual_ test_output.image_hash is None:96 if actual_driver_output.image_hash is None: 97 97 return failures 98 98 99 99 # If we're generating a new baseline, we pass. 100 100 if test_args.new_baseline or test_args.reset_results: 101 self._save_baseline_files(filename, actual_ test_output.image,102 actual_ test_output.image_hash,101 self._save_baseline_files(filename, actual_driver_output.image, 102 actual_driver_output.image_hash, 103 103 test_args.new_baseline) 104 104 return failures 105 105 106 if not expected_ test_output.image:106 if not expected_driver_output.image: 107 107 # Report a missing expected PNG file. 108 self._copy_image(filename, actual_ test_output.image, expected_image=None)109 self._copy_image_hash(filename, actual_ test_output.image_hash,110 expected_ test_output.image_hash)108 self._copy_image(filename, actual_driver_output.image, expected_image=None) 109 self._copy_image_hash(filename, actual_driver_output.image_hash, 110 expected_driver_output.image_hash) 111 111 failures.append(test_failures.FailureMissingImage()) 112 112 return failures 113 if not expected_ test_output.image_hash:113 if not expected_driver_output.image_hash: 114 114 # Report a missing expected checksum file. 115 self._copy_image(filename, actual_ test_output.image,116 expected_ test_output.image)117 self._copy_image_hash(filename, actual_ test_output.image_hash,115 self._copy_image(filename, actual_driver_output.image, 116 expected_driver_output.image) 117 self._copy_image_hash(filename, actual_driver_output.image_hash, 118 118 expected_image_hash=None) 119 119 failures.append(test_failures.FailureMissingImageHash()) 120 120 return failures 121 121 122 if actual_ test_output.image_hash == expected_test_output.image_hash:122 if actual_driver_output.image_hash == expected_driver_output.image_hash: 123 123 # Hash matched (no diff needed, okay to return). 124 124 return failures 125 125 126 self._copy_image(filename, actual_ test_output.image,127 expected_ test_output.image)128 self._copy_image_hash(filename, actual_ test_output.image_hash,129 expected_ test_output.image_hash)126 self._copy_image(filename, actual_driver_output.image, 127 expected_driver_output.image) 128 self._copy_image_hash(filename, actual_driver_output.image_hash, 129 expected_driver_output.image_hash) 130 130 131 131 # Even though we only use the result in one codepath below but we 132 132 # still need to call CreateImageDiff for other codepaths. 133 133 images_are_different = self._create_diff_image(port, filename, 134 actual_ test_output.image,135 expected_ test_output.image)134 actual_driver_output.image, 135 expected_driver_output.image) 136 136 if not images_are_different: 137 137 failures.append(test_failures.FailureImageHashIncorrect()) -
trunk/Tools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py
r76150 r77603 140 140 return fs.splitext(output_filename)[0] + modifier 141 141 142 def compare_output(self, port, filename, test_args, actual_ test_output,143 expected_ test_output):142 def compare_output(self, port, filename, test_args, actual_driver_output, 143 expected_driver_output): 144 144 """Method that compares the output from the test with the 145 145 expected value. … … 152 152 test_args: a TestArguments object holding optional additional 153 153 arguments 154 actual_ test_output: a TestOutput object which represents actual test154 actual_driver_output: a DriverOutput object which represents actual test 155 155 output 156 expected_ test_output: a TestOutput object which represents a expected157 test output156 expected_driver_output: a ExpectedDriverOutput object which represents a 157 expected test output 158 158 159 159 Return: -
trunk/Tools/Scripts/webkitpy/layout_tests/test_types/text_diff.py
r77410 r77603 54 54 return output.replace("\r\r\n", "\r\n").replace("\r\n", "\n") 55 55 56 def compare_output(self, port, filename, test_args, actual_ test_output,57 expected_ test_output):56 def compare_output(self, port, filename, test_args, actual_driver_output, 57 expected_driver_output): 58 58 """Implementation of CompareOutput that checks the output text against 59 59 the expected text from the LayoutTest directory.""" … … 65 65 # ever decode it inside run-webkit-tests. For some tests 66 66 # DumpRenderTree may not output utf-8 text (e.g. webarchives). 67 self._save_baseline_data(filename, actual_ test_output.text,67 self._save_baseline_data(filename, actual_driver_output.text, 68 68 ".txt", encoding=None, 69 69 generate_new_baseline=test_args.new_baseline) … … 71 71 72 72 # Normalize text to diff 73 actual_text = self._get_normalized_output_text(actual_ test_output.text)73 actual_text = self._get_normalized_output_text(actual_driver_output.text) 74 74 # Assuming expected_text is already normalized. 75 expected_text = expected_ test_output.text75 expected_text = expected_driver_output.text 76 76 77 77 # Write output files for new tests, too.
Note: See TracChangeset
for help on using the changeset viewer.