import threading
import time
+
+from webkitpy.layout_tests.test_types import image_diff
+from webkitpy.layout_tests.test_types import test_type_base
+from webkitpy.layout_tests.test_types import text_diff
+
import test_failures
import test_output
import test_results
port.expected_checksum(filename))
def _process_output(port, options, test_input, test_types, test_args,
- test_output):
+ test_output, worker_name):
"""Receives the output from a DumpRenderTree process, subjects it to a
number of tests, and returns a list of failure types the test produced.
test_types: list of test types to subject the output to
test_args: arguments to be passed to each test
test_output: a TestOutput object containing the output of the test
+ worker_name: worker name for logging
Returns: a TestResult object
"""
if test_output.timeout:
failures.append(test_failures.FailureTimeout())
+ test_name = port.relative_test_filename(test_input.filename)
if test_output.crash:
- _log.debug("Stacktrace for %s:\n%s" % (test_input.filename,
- test_output.error))
- # Strip off "file://" since RelativeTestFilename expects
- # filesystem paths.
- filename = os.path.join(options.results_directory,
- port.relative_test_filename(
- test_input.filename))
+ _log.debug("%s Stacktrace for %s:\n%s" % (worker_name, test_name,
+ test_output.error))
+ filename = os.path.join(options.results_directory, test_name)
filename = os.path.splitext(filename)[0] + "-stack.txt"
port.maybe_make_directory(os.path.split(filename)[0])
with codecs.open(filename, "wb", "utf-8") as file:
file.write(test_output.error)
elif test_output.error:
- _log.debug("Previous test output stderr lines:\n%s" % test_output.error)
+ _log.debug("%s %s output stderr lines:\n%s" % (worker_name, test_name,
+ test_output.error))
expected_test_output = _expected_test_output(port, test_input.filename)
return options.pixel_tests and not (options.new_baseline or options.reset_results)
-def _run_single_test(port, options, test_input, test_types, test_args, driver):
+def _run_single_test(port, options, test_input, test_types, test_args, driver, worker_name):
# FIXME: Pull this into TestShellThread._run().
# The image hash is used to avoid doing an image dump if the
uri = port.filename_to_uri(test_input.filename)
test_output = driver.run_test(uri, test_input.timeout, image_hash_to_driver)
return _process_output(port, options, test_input, test_types, test_args,
- test_output)
+ test_output, worker_name)
class SingleTestThread(threading.Thread):
"""Thread wrapper for running a single test file."""
- def __init__(self, port, options, test_input, test_types, test_args):
+ def __init__(self, port, options, worker_number, worker_name,
+ test_input, test_types, test_args):
"""
Args:
port: object implementing port-specific hooks
options: command line argument object from optparse
+ worker_number: worker number for tests
+ (FIXME: this should be passed to port.create_driver()).
+ worker_name: for logging
test_input: Object containing the test filename and timeout
test_types: A list of TestType objects to run the test output
against.
self._test_types = test_types
self._test_args = test_args
self._driver = None
+ self._worker_number = worker_number
+ self._name = worker_name
def run(self):
self._covered_run()
self._driver.start()
self._test_result = _run_single_test(self._port, self._options,
self._test_input, self._test_types,
- self._test_args, self._driver)
+ self._test_args, self._driver,
+ self._name)
self._driver.stop()
def get_test_result(self):
class TestShellThread(WatchableThread):
- def __init__(self, port, options, filename_list_queue, result_queue,
- test_types, test_args):
+ def __init__(self, port, options, worker_number,
+ filename_list_queue, result_queue):
"""Initialize all the local state for this DumpRenderTree thread.
Args:
port: interface to port-specific hooks
options: command line options argument from optparse
+ worker_number: identifier for a particular worker thread.
filename_list_queue: A thread safe Queue class that contains lists
of tuples of (filename, uri) pairs.
result_queue: A thread safe Queue class that will contain
serialized TestResult objects.
- test_types: A list of TestType objects to run the test output
- against.
- test_args: A TestArguments object to pass to each TestType.
"""
WatchableThread.__init__(self)
self._port = port
self._options = options
+ self._worker_number = worker_number
+ self._name = 'worker-%d' % worker_number
self._filename_list_queue = filename_list_queue
self._result_queue = result_queue
self._filename_list = []
- self._test_types = test_types
- self._test_args = test_args
self._driver = None
self._test_group_timing_stats = {}
self._test_results = []
self._http_lock_wait_begin = 0
self._http_lock_wait_end = 0
+ self._test_types = []
+ 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
# Number of tests in self._current_group.
# 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.png_path = None
+ if self._options.pixel_tests:
+ png_path = os.path.join(self._options.results_directory,
+ "png_result%s.png" %
+ self._worker_number)
+ test_args.png_path = png_path
+ 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:
+ classes.append(image_diff.ImageDiff)
+ return classes
+
def get_test_group_timing_stats(self):
"""Returns a dictionary mapping test group to a tuple of
(number of tests in that group, time to run the tests)"""
"""
worker = SingleTestThread(self._port,
self._options,
+ self._worker_number,
+ self._name,
test_input,
self._test_types,
self._test_args)
self._next_timeout = time.time() + thread_timeout
test_result = _run_single_test(self._port, self._options, test_input,
self._test_types, self._test_args,
- self._driver)
+ self._driver, self._name)
self._test_results.append(test_result)
return test_result
from layout_package import test_failures
from layout_package import test_results
from layout_package import test_results_uploader
-from test_types import image_diff
-from test_types import text_diff
-from test_types import test_type_base
from webkitpy.common.system import user
from webkitpy.thirdparty import simplejson
# self._websocket_secure_server = websocket_server.PyWebSocket(
# options.results_directory, use_tls=True, port=9323)
- # a list of TestType objects
- self._test_types = [text_diff.TestTextDiff]
- if options.pixel_tests:
- self._test_types.append(image_diff.ImageDiff)
-
# a set of test files, and the same tests as a list
self._test_files = set()
self._test_files_list = None
filename_queue.put(item)
return filename_queue
- def _get_test_args(self, index):
- """Returns the tuple of arguments for tests and for DumpRenderTree."""
- test_args = test_type_base.TestArguments()
- test_args.png_path = None
- if self._options.pixel_tests:
- png_path = os.path.join(self._options.results_directory,
- "png_result%s.png" % index)
- test_args.png_path = png_path
- test_args.new_baseline = self._options.new_baseline
- test_args.reset_results = self._options.reset_results
-
- return test_args
-
def _contains_tests(self, subdir):
for test_file in self._test_files:
if test_file.find(subdir) >= 0:
# Instantiate TestShellThreads and start them.
threads = []
- for i in xrange(int(self._options.child_processes)):
- # Create separate TestTypes instances for each thread.
- test_types = []
- for test_type in self._test_types:
- test_types.append(test_type(self._port,
- self._options.results_directory))
-
- test_args = self._get_test_args(i)
+ for worker_number in xrange(int(self._options.child_processes)):
thread = dump_render_tree_thread.TestShellThread(self._port,
- self._options, filename_queue, self._result_queue,
- test_types, test_args)
+ self._options, worker_number,
+ filename_queue, self._result_queue)
if self._is_single_threaded():
thread.run_in_main_thread(self, result_summary)
else: