Title: [90488] trunk/Tools
Revision
90488
Author
[email protected]
Date
2011-07-06 13:42:02 -0700 (Wed, 06 Jul 2011)

Log Message

Extract code to parse ORWT's results.html file into its own class

Prep work for fixing <http://webkit.org/b/61877> TestFailures page doesn't show testers that
use new-run-webkit-tests

Reviewed by Adam Barth.

* BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js:
(LayoutTestResultsLoader.prototype.start): Moved a bunch of code from here...

* BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js: Added.
(ORWTResultsParser):
(ORWTResultsParser.prototype.parse):
...to here.

* BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html: Pull in
ORWTResultsParser.js.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js (90487 => 90488)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js	2011-07-06 20:40:21 UTC (rev 90487)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js	2011-07-06 20:42:02 UTC (rev 90488)
@@ -50,55 +50,11 @@
 
         function fetchAndParseResultsHTMLAndCallCallback(callback) {
             getResource(self._builder.resultsPageURL(buildName), function(xhr) {
-                var root = document.createElement('html');
-                root.innerHTML = xhr.responseText;
-
+                var parseResult = (new ORWTResultsParser()).parse(xhr.responseText);
+                result.tests = parseResult.tests;
                 if (resultsHTMLSupportsTooManyFailuresInfo)
-                    result.tooManyFailures = root.getElementsByClassName('stopped-running-early-message').length > 0;
+                    result.tooManyFailures = parseResult.tooManyFailures;
 
-                function parseResultTable(regex) {
-                    var paragraph = Array.prototype.findFirst.call(root.querySelectorAll('p'), function(paragraph) {
-                        return regex.test(paragraph.innerText);
-                    });
-                    if (!paragraph)
-                        return [];
-                    var table = paragraph.nextElementSibling;
-                    console.assert(table.nodeName === 'TABLE');
-                    return Array.prototype.map.call(table.rows, function(row) {
-                        var links = row.getElementsByTagName('a');
-                        var result = {
-                            name: links[0].innerText,
-                        };
-                        for (var i = 1; i < links.length; ++i) {
-                            var match = /^crash log \((.*)\)$/.exec(links[i].innerText);
-                            if (!match)
-                                continue;
-                            result.crashingSymbol = match[1];
-                            break;
-                        }
-                        return result;
-                    });
-                }
-
-                parseResultTable(/did not match expected results/).forEach(function(testData) {
-                    result.tests[testData.name] = { failureType: 'fail' };
-                });
-                parseResultTable(/timed out/).forEach(function(testData) {
-                    result.tests[testData.name] = { failureType: 'timeout' };
-                });
-                parseResultTable(/tool to crash/).forEach(function(testData) {
-                    result.tests[testData.name] = {
-                        failureType: 'crash',
-                        crashingSymbol: testData.crashingSymbol,
-                    };
-                });
-                parseResultTable(/Web process to crash/).forEach(function(testData) {
-                    result.tests[testData.name] = {
-                        failureType: 'webprocess crash',
-                        crashingSymbol: testData.crashingSymbol,
-                    };
-                });
-
                 PersistentCache.set(cacheKey, result);
                 callback(result.tests, result.tooManyFailures);
             },
@@ -110,7 +66,7 @@
         }
 
         if (resultsHTMLSupportsTooManyFailuresInfo) {
-            fetchAndParseResultsHTMLAndCallCallback(callback, false);
+            fetchAndParseResultsHTMLAndCallCallback(callback);
             return;
         }
 
@@ -132,7 +88,7 @@
             }
 
             // Find out which tests failed.
-            fetchAndParseResultsHTMLAndCallCallback(callback, tooManyFailures);
+            fetchAndParseResultsHTMLAndCallCallback(callback);
         });
     },
 };

Added: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js (0 => 90488)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js	                        (rev 0)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js	2011-07-06 20:42:02 UTC (rev 90488)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2011 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+function ORWTResultsParser() {
+}
+
+ORWTResultsParser.prototype = {
+    parse: function(resultsHTMLString) {
+        var result = { tests: {}, tooManyFailures: false };
+
+        var root = document.createElement('html');
+        root.innerHTML = resultsHTMLString;
+
+        // Note that some old results.html files won't contain this element even if we had to stop
+        // running early due to too many failures. Our caller will have to figure that out
+        // themselves.
+        result.tooManyFailures = root.getElementsByClassName('stopped-running-early-message').length > 0;
+
+        function parseResultTable(regex) {
+            var paragraph = Array.prototype.findFirst.call(root.querySelectorAll('p'), function(paragraph) {
+                return regex.test(paragraph.innerText);
+            });
+            if (!paragraph)
+                return [];
+            var table = paragraph.nextElementSibling;
+            console.assert(table.nodeName === 'TABLE');
+            return Array.prototype.map.call(table.rows, function(row) {
+                var links = row.getElementsByTagName('a');
+                var result = {
+                    name: links[0].innerText,
+                };
+                for (var i = 1; i < links.length; ++i) {
+                    var match = /^crash log \((.*)\)$/.exec(links[i].innerText);
+                    if (!match)
+                        continue;
+                    result.crashingSymbol = match[1];
+                    break;
+                }
+                return result;
+            });
+        }
+
+        parseResultTable(/did not match expected results/).forEach(function(testData) {
+            result.tests[testData.name] = { failureType: 'fail' };
+        });
+        parseResultTable(/timed out/).forEach(function(testData) {
+            result.tests[testData.name] = { failureType: 'timeout' };
+        });
+        parseResultTable(/tool to crash/).forEach(function(testData) {
+            result.tests[testData.name] = {
+                failureType: 'crash',
+                crashingSymbol: testData.crashingSymbol,
+            };
+        });
+        parseResultTable(/Web process to crash/).forEach(function(testData) {
+            result.tests[testData.name] = {
+                failureType: 'webprocess crash',
+                crashingSymbol: testData.crashingSymbol,
+            };
+        });
+
+        return result;
+    },
+};

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html (90487 => 90488)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html	2011-07-06 20:40:21 UTC (rev 90487)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html	2011-07-06 20:42:02 UTC (rev 90488)
@@ -33,6 +33,7 @@
     <script src=""
     <script src=""
     <script src=""
+    <script src=""
     <script src=""
     <script src=""
     <script src=""

Modified: trunk/Tools/ChangeLog (90487 => 90488)


--- trunk/Tools/ChangeLog	2011-07-06 20:40:21 UTC (rev 90487)
+++ trunk/Tools/ChangeLog	2011-07-06 20:42:02 UTC (rev 90488)
@@ -1,3 +1,23 @@
+2011-07-06  Adam Roben  <[email protected]>
+
+        Extract code to parse ORWT's results.html file into its own class
+
+        Prep work for fixing <http://webkit.org/b/61877> TestFailures page doesn't show testers that
+        use new-run-webkit-tests
+
+        Reviewed by Adam Barth.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js:
+        (LayoutTestResultsLoader.prototype.start): Moved a bunch of code from here...
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js: Added.
+        (ORWTResultsParser):
+        (ORWTResultsParser.prototype.parse):
+        ...to here.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html: Pull in
+        ORWTResultsParser.js.
+
 2011-07-06  Eric Seidel  <[email protected]>
 
         Unreviewed.  Fix a unittest from hitting the network. :)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to