[NRWT] Support --ignore-metrics
authorkbalazs@webkit.org <kbalazs@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 10:10:22 +0000 (10:10 +0000)
committerkbalazs@webkit.org <kbalazs@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 10:10:22 +0000 (10:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76278

Reviewed by Tony Chang.

Port the feature from ORWT.

* Scripts/webkitpy/layout_tests/controllers/single_test_runner.py:
(SingleTestRunner._run_compare_test):
* Scripts/webkitpy/layout_tests/port/driver.py:
(DriverOutput):
(DriverOutput.strip_metrics):
* Scripts/webkitpy/layout_tests/port/driver_unittest.py:
(DriverOutputTest):
(DriverOutputTest.test_strip_metrics):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(_set_up_derived_options):
(parse_args):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py
Tools/Scripts/webkitpy/layout_tests/port/driver.py
Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py
Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

index 29985ff..36a6816 100644 (file)
@@ -1,3 +1,24 @@
+2012-01-26  Balazs Kelemen  <kbalazs@webkit.org>
+
+        [NRWT] Support --ignore-metrics
+        https://bugs.webkit.org/show_bug.cgi?id=76278
+
+        Reviewed by Tony Chang.
+
+        Port the feature from ORWT.
+
+        * Scripts/webkitpy/layout_tests/controllers/single_test_runner.py:
+        (SingleTestRunner._run_compare_test):
+        * Scripts/webkitpy/layout_tests/port/driver.py:
+        (DriverOutput):
+        (DriverOutput.strip_metrics):
+        * Scripts/webkitpy/layout_tests/port/driver_unittest.py:
+        (DriverOutputTest):
+        (DriverOutputTest.test_strip_metrics):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (_set_up_derived_options):
+        (parse_args):
+
 2012-01-26  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r105935 and r105954.
index af4b2d9..791fb62 100644 (file)
@@ -104,6 +104,11 @@ class SingleTestRunner:
     def _run_compare_test(self):
         driver_output = self._driver.run_test(self._driver_input())
         expected_driver_output = self._expected_driver_output()
+
+        if self._options.ignore_metrics:
+            expected_driver_output.strip_metrics()
+            driver_output.strip_metrics()
+
         test_result = self._compare_output(driver_output, expected_driver_output)
         if self._options.new_test_results:
             self._add_missing_baselines(test_result, driver_output)
index 8987c82..8a2857a 100644 (file)
@@ -26,6 +26,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import re
 import shlex
 
 from webkitpy.common.system import path
@@ -40,7 +41,25 @@ class DriverInput(object):
 
 
 class DriverOutput(object):
-    """Groups information about a output from driver for easy passing of data."""
+    """Groups information about a output from driver for easy passing
+    and post-processing of data."""
+
+    strip_patterns = []
+    strip_patterns.append((re.compile('at \(-?[0-9]+,-?[0-9]+\) *'), ''))
+    strip_patterns.append((re.compile('size -?[0-9]+x-?[0-9]+ *'), ''))
+    strip_patterns.append((re.compile('text run width -?[0-9]+: '), ''))
+    strip_patterns.append((re.compile('text run width -?[0-9]+ [a-zA-Z ]+: '), ''))
+    strip_patterns.append((re.compile('RenderButton {BUTTON} .*'), 'RenderButton {BUTTON}'))
+    strip_patterns.append((re.compile('RenderImage {INPUT} .*'), 'RenderImage {INPUT}'))
+    strip_patterns.append((re.compile('RenderBlock {INPUT} .*'), 'RenderBlock {INPUT}'))
+    strip_patterns.append((re.compile('RenderTextControl {INPUT} .*'), 'RenderTextControl {INPUT}'))
+    strip_patterns.append((re.compile('\([0-9]+px'), 'px'))
+    strip_patterns.append((re.compile(' *" *\n +" *'), ' '))
+    strip_patterns.append((re.compile('" +$'), '"'))
+    strip_patterns.append((re.compile('- '), '-'))
+    strip_patterns.append((re.compile('\s+"\n'), '"\n'))
+    strip_patterns.append((re.compile('scrollWidth [0-9]+'), 'scrollWidth'))
+    strip_patterns.append((re.compile('scrollHeight [0-9]+'), 'scrollHeight'))
 
     def __init__(self, text, image, image_hash, audio, crash=False,
             test_time=0, timeout=False, error='', crashed_process_name=None):
@@ -59,6 +78,12 @@ class DriverOutput(object):
     def has_stderr(self):
         return bool(self.error)
 
+    def strip_metrics(self):
+        if not self.text:
+            return
+        for pattern in self.strip_patterns:
+            self.text = re.sub(pattern[0], pattern[1], self.text)
+
 
 class Driver(object):
     """Abstract interface for the DumpRenderTree interface."""
index f2ec1aa..d0a510f 100644 (file)
@@ -35,6 +35,47 @@ from webkitpy.common.system.systemhost_mock import MockSystemHost
 from webkitpy.layout_tests.port import Port, Driver, DriverOutput
 
 
+class DriverOutputTest(unittest.TestCase):
+    def test_strip_metrics(self):
+        patterns = [
+            ('RenderView at (0,0) size 800x600', 'RenderView '),
+            ('text run at (0,0) width 100: "some text"', '"some text"'),
+            ('RenderBlock {HTML} at (0,0) size 800x600', 'RenderBlock {HTML} '),
+            ('RenderBlock {INPUT} at (29,3) size 12x12 [color=#000000]', 'RenderBlock {INPUT}'),
+
+            ('RenderBlock (floating) {DT} at (5,5) size 79x310 [border: (5px solid #000000)]',
+            'RenderBlock (floating) {DT} [border: px solid #000000)]'),
+
+            ('\n    "truncate text    "\n', '\n    "truncate text"\n'),
+
+            ('RenderText {#text} at (0,3) size 41x12\n    text run at (0,3) width 41: "whimper "\n',
+            'RenderText {#text} \n    "whimper"\n'),
+
+            ("""text run at (0,0) width 109: ".one {color: green;}"
+          text run at (109,0) width 0: " "
+          text run at (0,17) width 81: ".1 {color: red;}"
+          text run at (81,17) width 0: " "
+          text run at (0,34) width 102: ".a1 {color: green;}"
+          text run at (102,34) width 0: " "
+          text run at (0,51) width 120: "P.two {color: purple;}"
+          text run at (120,51) width 0: " "\n""",
+            '".one {color: green;}  .1 {color: red;}  .a1 {color: green;}  P.two {color: purple;}"\n'),
+
+            ('text-- other text', 'text--other text'),
+
+            (' some output   "truncate trailing spaces at end of line after text"   \n',
+            ' some output   "truncate trailing spaces at end of line after text"\n'),
+
+            (r'scrollWidth 120', r'scrollWidth'),
+            (r'scrollHeight 120', r'scrollHeight'),
+        ]
+
+        for pattern in patterns:
+            driver_output = DriverOutput(pattern[0], None, None, None)
+            driver_output.strip_metrics()
+            self.assertEqual(driver_output.text, pattern[1])
+
+
 class DriverTest(unittest.TestCase):
     def make_port(self):
         return Port(MockSystemHost())
index 9e17dc4..f7b5f34 100755 (executable)
@@ -175,6 +175,9 @@ def _set_up_derived_options(port, options):
         warnings.append("--no-http is ignored since --force is also provided")
         options.http = True
 
+    if options.ignore_metrics and (options.new_baseline or options.reset_results):
+        warnings.append("--ignore-metrics has no effect with --new-baselines or with --reset-results")
+
     return warnings
 
 
@@ -342,6 +345,9 @@ def parse_args(args=None):
             default=True, help="Run HTTP and WebSocket tests (default)"),
         optparse.make_option("--no-http", action="store_false", dest="http",
             help="Don't run HTTP and WebSocket tests"),
+        optparse.make_option("--ignore-metrics", action="store_true", dest="ignore_metrics",
+            default=False, help="Ignore rendering metrics related information from test "
+            "output, only compare the structure of the rendertree."),
     ]
 
     test_options = [