2010-11-19 Hayato Ito <hayato@chromium.org>
authorhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2010 21:00:41 +0000 (21:00 +0000)
committerhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2010 21:00:41 +0000 (21:00 +0000)
        Reviewed by Shinichiro Hamaji.

        Simplify Driver.run_test() so that it takes only one parameter, TestInput.

        https://bugs.webkit.org/show_bug.cgi?id=49812

        * Scripts/webkitpy/layout_tests/driver_test.py:
        * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
        * Scripts/webkitpy/layout_tests/port/base.py:
        * Scripts/webkitpy/layout_tests/port/base_unittest.py:
        * Scripts/webkitpy/layout_tests/port/chromium.py:
        * Scripts/webkitpy/layout_tests/port/dryrun.py:
        * Scripts/webkitpy/layout_tests/port/test.py:
        * Scripts/webkitpy/layout_tests/port/webkit.py:
        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/layout_tests/driver_test.py [deleted file]
WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py
WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
WebKitTools/Scripts/webkitpy/layout_tests/port/base_unittest.py
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py
WebKitTools/Scripts/webkitpy/layout_tests/port/dryrun.py
WebKitTools/Scripts/webkitpy/layout_tests/port/test.py
WebKitTools/Scripts/webkitpy/layout_tests/port/webkit.py
WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py

index c62ca2d3594eca92abd194104429dc14caa6509b..bf2e4d06895b1623f080bd1f383716cf67a5cd35 100644 (file)
@@ -1,3 +1,22 @@
+2010-11-19  Hayato Ito  <hayato@chromium.org>
+
+        Reviewed by Shinichiro Hamaji.
+
+        Simplify Driver.run_test() so that it takes only one parameter, TestInput.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49812
+
+        * Scripts/webkitpy/layout_tests/driver_test.py:
+        * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        * Scripts/webkitpy/layout_tests/port/base_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/chromium.py:
+        * Scripts/webkitpy/layout_tests/port/dryrun.py:
+        * Scripts/webkitpy/layout_tests/port/test.py:
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
+
 2010-11-22  Hayato Ito  <hayato@chromium.org>
 
         Reviewed by Tony Chang.
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/driver_test.py b/WebKitTools/Scripts/webkitpy/layout_tests/driver_test.py
deleted file mode 100644 (file)
index 633dfe8..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#
-# FIXME: this is a poor attempt at a unit tests driver. We should replace
-# this with something that actually uses a unit testing framework or
-# at least produces output that could be useful.
-
-"""Simple test client for the port/Driver interface."""
-
-import os
-import optparse
-import port
-
-
-def run_tests(port, options, tests):
-    # |image_path| is a path to the image capture from the driver.
-    image_path = 'image_result.png'
-    driver = port.create_driver(image_path, None)
-    driver.start()
-    for t in tests:
-        uri = port.filename_to_uri(os.path.join(port.layout_tests_dir(), t))
-        print "uri: " + uri
-        crash, timeout, checksum, output, err = \
-            driver.run_test(uri, int(options.timeout), None)
-        print "crash:         " + str(crash)
-        print "timeout:       " + str(timeout)
-        print "checksum:      " + str(checksum)
-        print 'stdout: """'
-        print ''.join(output)
-        print '"""'
-        print 'stderr: """'
-        print ''.join(err)
-        print '"""'
-        print
-    driver.stop()
-
-
-if __name__ == '__main__':
-    # FIXME: configuration_options belong in a shared location.
-    configuration_options = [
-        optparse.make_option('--debug', action='store_const', const='Debug', dest="configuration", help='Set the configuration to Debug'),
-        optparse.make_option('--release', action='store_const', const='Release', dest="configuration", help='Set the configuration to Release'),
-    ]
-    misc_options = [
-        optparse.make_option('-p', '--platform', action='store', default='mac', help='Platform to test (e.g., "mac", "chromium-mac", etc.'),
-        optparse.make_option('--timeout', action='store', default='2000', help='test timeout in milliseconds (2000 by default)'),
-        optparse.make_option('--wrapper', action='store'),
-        optparse.make_option('--no-pixel-tests', action='store_true', default=False, help='disable pixel-to-pixel PNG comparisons'),
-    ]
-    option_list = configuration_options + misc_options
-    optparser = optparse.OptionParser(option_list=option_list)
-    options, args = optparser.parse_args()
-    p = port.get(options.platform, options)
-    run_tests(p, options, args)
index af15a82efbe059a841e293fcc5b8f4a80b81e2c4..1bac7ef18e3e2ea7a6dcf5fa37402678e7ae2a2b 100644 (file)
@@ -155,11 +155,8 @@ def _run_single_test(port, options, test_input, test_types, test_args, driver, w
     # are generating a new baseline.  (Otherwise, an image from a
     # previous run will be copied into the baseline."""
     if _should_fetch_expected_checksum(options):
-        image_hash_to_driver = port.expected_checksum(test_input.filename)
-    else:
-        image_hash_to_driver = None
-    uri = port.filename_to_uri(test_input.filename)
-    test_output = driver.run_test(uri, test_input.timeout, image_hash_to_driver)
+        test_input.image_hash = port.expected_checksum(test_input.filename)
+    test_output = driver.run_test(test_input)
     return _process_output(port, options, test_input, test_types, test_args,
                            test_output, worker_name)
 
index 632806fb2ce30f53893d48e7850bc0fb8874c390..3fb0d8ec7677fc53bdaad1cf314e376a82bef4f2 100644 (file)
@@ -820,17 +820,15 @@ class Driver:
         """
         raise NotImplementedError('Driver.__init__')
 
-    def run_test(self, uri, timeout, checksum):
+    def run_test(self, test_input):
         """Run a single test and return the results.
 
         Note that it is okay if a test times out or crashes and leaves
         the driver in an indeterminate state. The upper layers of the program
         are responsible for cleaning up and ensuring things are okay.
 
-        uri - a full URI for the given test
-        timeout - number of milliseconds to wait before aborting this test.
-        checksum - if present, the expected checksum for the image for this
-            test
+        Args:
+          test_input: a TestInput object
 
         Returns a TestOutput object.
         """
index 1e9c2b75e0249099b18f1482973401eb68f09991..22709eabdf82fb884954fdb9ad5f63f97a8c6d00 100644 (file)
@@ -290,7 +290,7 @@ class VirtualTest(unittest.TestCase):
                 pass
 
         driver = VirtualDriver()
-        self.assertVirtual(driver.run_test, None, None, None)
+        self.assertVirtual(driver.run_test, None)
         self.assertVirtual(driver.poll)
         self.assertVirtual(driver.stop)
 
index 5bfb8ffb3bdeb561edb3ce187e7a7ae368b088de..25c18cb216f73d6a63bdc9cd38d82449adbba08c 100644 (file)
@@ -470,7 +470,7 @@ class ChromiumDriver(base.Driver):
                     raise e
         return self._output_image()
 
-    def run_test(self, uri, timeoutms, checksum):
+    def run_test(self, test_input):
         output = []
         error = []
         crash = False
@@ -480,7 +480,9 @@ class ChromiumDriver(base.Driver):
 
         start_time = time.time()
 
-        cmd = self._test_shell_command(uri, timeoutms, checksum)
+        uri = self._port.filename_to_uri(test_input.filename)
+        cmd = self._test_shell_command(uri, test_input.timeout,
+                                       test_input.image_hash)
         (line, crash) = self._write_command_and_read_line(input=cmd)
 
         while not crash and line.rstrip() != "#EOF":
index 96d0d55f62d7bc14b4ad43a9eaa9ed069d642016..d444dab123142dde13de0a711f63319dd6165032 100644 (file)
@@ -111,15 +111,13 @@ class DryrunDriver(base.Driver):
     def poll(self):
         return None
 
-    def run_test(self, uri, timeoutms, image_hash):
+    def run_test(self, test_input):
         start_time = time.time()
-        test_name = self._port.uri_to_test_name(uri)
-        path = os.path.join(self._port.layout_tests_dir(), test_name)
-        text_output = self._port.expected_text(path)
+        text_output = self._port.expected_text(test_input.filename)
 
-        if image_hash is not None:
-            image = self._port.expected_image(path)
-            hash = self._port.expected_checksum(path)
+        if test_input.image_hash is not None:
+            image = self._port.expected_image(test_input.filename)
+            hash = self._port.expected_checksum(test_input.filename)
         else:
             image = None
             hash = None
index 0a278214dc1b259a9748d2dbb3565d50fa2515b4..dd8f618a8ea9ecdd2f61514ae0c03a16c1a66c52 100644 (file)
@@ -290,16 +290,16 @@ class TestDriver(base.Driver):
     def poll(self):
         return True
 
-    def run_test(self, uri, timeoutms, image_hash):
+    def run_test(self, test_input):
         start_time = time.time()
-        test_name = self._port.uri_to_test_name(uri)
+        test_name = self._port.relative_test_filename(test_input.filename)
         test = self._port._tests[test_name]
         if test.keyboard:
             raise KeyboardInterrupt
         if test.exception:
             raise ValueError('exception from ' + test_name)
         if test.hang:
-            time.sleep((float(timeoutms) * 4) / 1000.0)
+            time.sleep((float(test_input.timeout) * 4) / 1000.0)
         return test_output.TestOutput(test.actual_text, test.actual_image,
                                       test.actual_checksum, test.crash,
                                       time.time() - start_time, test.timeout,
index 06797c6d38e254570d3ffa0eb61a2b3c69436087..f5f925267031cecb394055f82d590c054a90833d 100644 (file)
@@ -433,14 +433,15 @@ class WebKitDriver(base.Driver):
         return
 
     # FIXME: This function is huge.
-    def run_test(self, uri, timeoutms, image_hash):
+    def run_test(self, test_input):
+        uri = self._port.filename_to_uri(test_input.filename)
         if uri.startswith("file:///"):
             command = uri[7:]
         else:
             command = uri
 
-        if image_hash:
-            command += "'" + image_hash
+        if test_input.image_hash:
+            command += "'" + test_input.image_hash
         command += "\n"
 
         start_time = time.time()
@@ -451,7 +452,7 @@ class WebKitDriver(base.Driver):
         output = str()  # Use a byte array for output, even though it should be UTF-8.
         image = str()
 
-        timeout = int(timeoutms) / 1000.0
+        timeout = int(test_input.timeout) / 1000.0
         deadline = time.time() + timeout
         line = self._server_process.read_line(timeout)
         while (not self._server_process.timed_out
index 9128ae8542bb4cbd4c9d9a5e9799eff2b42b48d9..9bb76047f72928b4f632acf4cca3be2c84ab458e 100755 (executable)
@@ -100,6 +100,10 @@ class TestInput:
         # FIXME: filename should really be test_name as a relative path.
         self.filename = filename
         self.timeout = timeout
+        # The image_hash is used to avoid doing an image dump if the
+        # checksums match. The image_hash is set later, and only if it is needed
+        # for the test.
+        self.image_hash = None
 
 
 class ResultSummary(object):
index 3dfc3e612614c5b8bd3a30df1cef9556a50fa4c5..bf1f0aa96c16f87e8e9937b0d5a47d6aa9662f90 100644 (file)
@@ -139,12 +139,13 @@ def get_tests_run(extra_args=None, tests_included=False, flatten_batches=False):
         def stop(self):
             self._current_test_batch = None
 
-        def run_test(self, uri, timeoutms, image_hash):
+        def run_test(self, test_input):
             if self._current_test_batch is None:
                 self._current_test_batch = []
                 test_batches.append(self._current_test_batch)
-            self._current_test_batch.append(self._port.uri_to_test_name(uri))
-            return TestDriver.run_test(self, uri, timeoutms, image_hash)
+            test_name = self._port.relative_test_filename(test_input.filename)
+            self._current_test_batch.append(test_name)
+            return TestDriver.run_test(self, test_input)
 
     class RecordingTestPort(TestPort):
         def create_driver(self, image_path, options):