Extract code to parse ORWT's results.html file into its own class
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jul 2011 20:42:02 +0000 (20:42 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Jul 2011 20:42:02 +0000 (20:42 +0000)
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.

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

Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js [new file with mode: 0644]
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html
Tools/ChangeLog

index f06ddb7..b7982e3 100644 (file)
@@ -50,54 +50,10 @@ LayoutTestResultsLoader.prototype = {
 
         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;
-
-                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,
-                    };
-                });
+                    result.tooManyFailures = parseResult.tooManyFailures;
 
                 PersistentCache.set(cacheKey, result);
                 callback(result.tests, result.tooManyFailures);
@@ -110,7 +66,7 @@ LayoutTestResultsLoader.prototype = {
         }
 
         if (resultsHTMLSupportsTooManyFailuresInfo) {
-            fetchAndParseResultsHTMLAndCallCallback(callback, false);
+            fetchAndParseResultsHTMLAndCallCallback(callback);
             return;
         }
 
@@ -132,7 +88,7 @@ LayoutTestResultsLoader.prototype = {
             }
 
             // Find out which tests failed.
-            fetchAndParseResultsHTMLAndCallCallback(callback, tooManyFailures);
+            fetchAndParseResultsHTMLAndCallCallback(callback);
         });
     },
 };
diff --git a/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js b/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ORWTResultsParser.js
new file mode 100644 (file)
index 0000000..68170a8
--- /dev/null
@@ -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;
+    },
+};
index 1cb59ab..070309d 100644 (file)
@@ -33,6 +33,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
     <script src="FlakyLayoutTestDetector.js"></script>
     <script src="LayoutTestHistoryAnalyzer.js"></script>
     <script src="LayoutTestResultsLoader.js"></script>
+    <script src="ORWTResultsParser.js"></script>
     <script src="PersistentCache.js"></script>
     <script src="Trac.js"></script>
     <script src="Utilities.js"></script>
index abc0591..790665e 100644 (file)
@@ -1,3 +1,23 @@
+2011-07-06  Adam Roben  <aroben@apple.com>
+
+        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  <eric@webkit.org>
 
         Unreviewed.  Fix a unittest from hitting the network. :)