+2011-02-03 Hayato Ito <hayato@chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ [NRWT] Remove TestArgs class, which is wrongly used.
+
+ https://bugs.webkit.org/show_bug.cgi?id=53063
+
+ * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
+ * Scripts/webkitpy/layout_tests/layout_package/single_test_runner.py:
+ * Scripts/webkitpy/layout_tests/test_types/image_diff.py:
+ * Scripts/webkitpy/layout_tests/test_types/test_type_base.py:
+ * Scripts/webkitpy/layout_tests/test_types/test_type_base_unittest.py:
+ * Scripts/webkitpy/layout_tests/test_types/text_diff.py:
+
2011-02-03 Andrew Wason <rectalogic@rectalogic.com>
Reviewed by Kenneth Russell.
"""Thread wrapper for running a single test file."""
def __init__(self, port, options, worker_number, worker_name,
- test_input, test_types, test_args):
+ test_input, test_types):
"""
Args:
port: object implementing port-specific hooks
test_input: Object containing the test filename and timeout
test_types: A list of TestType objects to run the test output
against.
- test_args: A TestArguments object to pass to each TestType.
"""
threading.Thread.__init__(self)
self._options = options
self._test_input = test_input
self._test_types = test_types
- self._test_args = test_args
self._driver = None
self._worker_number = worker_number
self._name = worker_name
self._driver.start()
self._test_result = single_test_runner.run_single_test(
self._port, self._options, self._test_input, self._driver,
- self._name, self._test_types, self._test_args)
+ self._name, self._test_type)
self._driver.stop()
def get_test_result(self):
for cls in self._get_test_type_classes():
self._test_types.append(cls(self._port,
self._options.results_directory))
- self._test_args = self._get_test_args(worker_number)
# Current group of tests we're running.
self._current_group = None
# Time at which we started running tests from self._current_group.
self._current_group_start_time = None
- def _get_test_args(self, worker_number):
- """Returns the tuple of arguments for tests and for DumpRenderTree."""
- test_args = test_type_base.TestArguments()
- test_args.new_baseline = self._options.new_baseline
- test_args.reset_results = self._options.reset_results
-
- return test_args
-
def _get_test_type_classes(self):
classes = [text_diff.TestTextDiff]
if self._options.pixel_tests:
self._worker_number,
self._name,
test_input,
- self._test_types,
- self._test_args)
+ self._test_types)
worker.start()
self._next_timeout = time.time() + thread_timeout
test_result = single_test_runner.run_single_test(
self._port, self._options, test_input, self._driver, self._name,
- self._test_types, self._test_args)
+ self._test_types)
self._test_results.append(test_result)
return test_result
_log = logging.getLogger(__name__)
-def run_single_test(port, options, test_input, driver, worker_name, test_types, test_args):
+def run_single_test(port, options, test_input, driver, worker_name, test_types):
# FIXME: Pull this into TestShellThread._run().
- runner = SingleTestRunner(options, port, driver, test_input, worker_name, test_types, test_args)
+ runner = SingleTestRunner(options, port, driver, test_input, worker_name, test_types)
return runner.run()
class SingleTestRunner:
- def __init__(self, options, port, driver, test_input, worker_name, test_types, test_args):
+ def __init__(self, options, port, driver, test_input, worker_name, test_types):
self._options = options
self._port = port
self._driver = driver
self._timeout = test_input.timeout
self._worker_name = worker_name
self._test_types = test_types
- self._test_args = test_args
self._testname = port.relative_test_filename(test_input.filename)
def _expected_driver_output(self):
time_for_diffs = {}
for test_type in self._test_types:
start_diff_time = time.time()
- new_failures = test_type.compare_output(self._port, self._filename,
- self._test_args, driver_output,
- expected_driver_output)
+ new_failures = test_type.compare_output(
+ self._port, self._filename, self._options, driver_output,
+ expected_driver_output)
# Don't add any more failures if we already have a crash, so we don't
# double-report those tests. We do double-report for timeouts since
# we still want to see the text and image output.
self.FILENAME_SUFFIX_COMPARE)
return port.diff_image(actual_image, expected_image, diff_filename)
- def compare_output(self, port, filename, test_args, actual_driver_output,
+ def compare_output(self, port, filename, options, actual_driver_output,
expected_driver_output):
"""Implementation of CompareOutput that checks the output image and
checksum against the expected files from the LayoutTest directory.
return failures
# If we're generating a new baseline, we pass.
- if test_args.new_baseline or test_args.reset_results:
+ if options.new_baseline or options.reset_results:
self._save_baseline_files(filename, actual_driver_output.image,
actual_driver_output.image_hash,
- test_args.new_baseline)
+ options.new_baseline)
return failures
if not expected_driver_output.image:
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Defines the interface TestTypeBase which other test types inherit from.
-
-Also defines the TestArguments "struct" to pass them additional arguments.
"""
import cgi
_log = logging.getLogger("webkitpy.layout_tests.test_types.test_type_base")
-class TestArguments(object):
- """Struct-like wrapper for additional arguments needed by
- specific tests."""
- # Whether to save new baseline results.
- new_baseline = False
-
- # Path to the actual PNG file generated by pixel tests
- png_path = None
-
- # Value of checksum generated by pixel tests.
- hash = None
-
- # Whether to use wdiff to generate by-word diffs.
- wdiff = False
-
# Python bug workaround. See the wdiff code in WriteOutputFiles for an
# explanation.
_wdiff_available = True
self._port.relative_test_filename(filename))
return fs.splitext(output_filename)[0] + modifier
- def compare_output(self, port, filename, test_args, actual_driver_output,
+ def compare_output(self, port, filename, options, actual_driver_output,
expected_driver_output):
"""Method that compares the output from the test with the
expected value.
Args:
port: object implementing port-specific information and methods
filename: absolute filename to test file
- test_args: a TestArguments object holding optional additional
- arguments
+ options: command line argument object from optparse
actual_driver_output: a DriverOutput object which represents actual test
output
expected_driver_output: a ExpectedDriverOutput object which represents a
test_type = test_type_base.TestTypeBase(None, None)
self.assertRaises(NotImplementedError, test_type.compare_output,
None, "foo.txt", '',
- test_type_base.TestArguments(), 'Debug')
+ {}, 'Debug')
if __name__ == '__main__':
# the normalized text expectation files.
return output.replace("\r\r\n", "\r\n").replace("\r\n", "\n")
- def compare_output(self, port, filename, test_args, actual_driver_output,
+ def compare_output(self, port, filename, options, actual_driver_output,
expected_driver_output):
"""Implementation of CompareOutput that checks the output text against
the expected text from the LayoutTest directory."""
failures = []
# If we're generating a new baseline, we pass.
- if test_args.new_baseline or test_args.reset_results:
+ if options.new_baseline or options.reset_results:
# Although all DumpRenderTree output should be utf-8, we do not
# ever decode it inside run-webkit-tests. For some tests
# DumpRenderTree may not output utf-8 text (e.g. webarchives).
self._save_baseline_data(filename, actual_driver_output.text,
".txt", encoding=None,
- generate_new_baseline=test_args.new_baseline)
+ generate_new_baseline=options.new_baseline)
return failures
# Normalize text to diff