Title: [105981] trunk/Tools
Revision
105981
Author
kbal...@webkit.org
Date
2012-01-26 02:10:22 -0800 (Thu, 26 Jan 2012)

Log Message

[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):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (105980 => 105981)


--- trunk/Tools/ChangeLog	2012-01-26 10:07:12 UTC (rev 105980)
+++ trunk/Tools/ChangeLog	2012-01-26 10:10:22 UTC (rev 105981)
@@ -1,3 +1,24 @@
+2012-01-26  Balazs Kelemen  <kbal...@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....@gmail.com>
 
         Unreviewed, rolling out r105935 and r105954.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py (105980 => 105981)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py	2012-01-26 10:07:12 UTC (rev 105980)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py	2012-01-26 10:10:22 UTC (rev 105981)
@@ -104,6 +104,11 @@
     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)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py (105980 => 105981)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py	2012-01-26 10:07:12 UTC (rev 105980)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py	2012-01-26 10:10:22 UTC (rev 105981)
@@ -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,8 +41,26 @@
 
 
 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):
         # FIXME: Args could be renamed to better clarify what they do.
@@ -59,7 +78,13 @@
     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."""
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py (105980 => 105981)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py	2012-01-26 10:07:12 UTC (rev 105980)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py	2012-01-26 10:10:22 UTC (rev 105981)
@@ -35,6 +35,47 @@
 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())

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (105980 => 105981)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-01-26 10:07:12 UTC (rev 105980)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-01-26 10:10:22 UTC (rev 105981)
@@ -175,6 +175,9 @@
         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 @@
             default=True, help="Run HTTP and WebSocket tests (default)"),
         optparse.make_option("--no-http", action="" dest="http",
             help="Don't run HTTP and WebSocket tests"),
+        optparse.make_option("--ignore-metrics", action="" dest="ignore_metrics",
+            default=False, help="Ignore rendering metrics related information from test "
+            "output, only compare the structure of the rendertree."),
     ]
 
     test_options = [
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to