Title: [90430] trunk/Tools
Revision
90430
Author
[email protected]
Date
2011-07-05 20:15:24 -0700 (Tue, 05 Jul 2011)

Log Message

2011-07-05  Adam Barth  <[email protected]>

        Add first unit tests for garden-o-matic
        https://bugs.webkit.org/show_bug.cgi?id=63969

        Reviewed by Eric Seidel.

        I've also reformated base.js to match WebKit style, as discussed in the
        previous bug.

        * Scripts/webkitpy/tool/servers/data/gardeningserver/base.js:
        * Scripts/webkitpy/tool/servers/data/gardeningserver/base_unittests.js: Added.
        * Scripts/webkitpy/tool/servers/data/gardeningserver/run-unittests.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (90429 => 90430)


--- trunk/Tools/ChangeLog	2011-07-06 03:11:44 UTC (rev 90429)
+++ trunk/Tools/ChangeLog	2011-07-06 03:15:24 UTC (rev 90430)
@@ -1,3 +1,17 @@
+2011-07-05  Adam Barth  <[email protected]>
+
+        Add first unit tests for garden-o-matic
+        https://bugs.webkit.org/show_bug.cgi?id=63969
+
+        Reviewed by Eric Seidel.
+
+        I've also reformated base.js to match WebKit style, as discussed in the
+        previous bug.
+
+        * Scripts/webkitpy/tool/servers/data/gardeningserver/base.js:
+        * Scripts/webkitpy/tool/servers/data/gardeningserver/base_unittests.js: Added.
+        * Scripts/webkitpy/tool/servers/data/gardeningserver/run-unittests.html: Added.
+
 2011-07-05  Eric Seidel  <[email protected]>
 
         Move Qt, Gtk and Leopard to NRWT.

Modified: trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/base.js (90429 => 90430)


--- trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/base.js	2011-07-06 03:11:44 UTC (rev 90429)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/base.js	2011-07-06 03:15:24 UTC (rev 90430)
@@ -1,27 +1,34 @@
 var base = base || {};
 
-(function() {
-  base.joinPath = function(parent, child) {
+(function(){
+
+base.joinPath = function(parent, child)
+{
+    if (parent.length == 0)
+        return child;
     return parent + '/' + child;
-  }
+}
 
-  base.filterTree = function(tree, is_leaf, predicate) {
-    var filtered_tree = {};
+base.filterTree = function(tree, isLeaf, predicate)
+{
+    var filteredTree = {};
 
-    function walkSubtree(subtree, directory) {
-      for (var child_name in subtree) {
-        var child = subtree[child_name];
-        var child_path = base.joinPath(directory, child_name);
-        if (is_leaf(child)) {
-          if (predicate(child))
-            filtered_tree[child_path] = child;
-          continue;
+    function walkSubtree(subtree, directory)
+    {
+        for (var childName in subtree) {
+            var child = subtree[childName];
+            var childPath = base.joinPath(directory, childName);
+            if (isLeaf(child)) {
+                if (predicate(child))
+                    filteredTree[childPath] = child;
+                continue;
+            }
+            walkSubtree(child, childPath);
         }
-        walkSubtree(child, child_path);
-      }
     }
 
     walkSubtree(tree, '');
-    return filtered_tree;
-  }
+    return filteredTree;
+}
+
 })();

Added: trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/base_unittests.js (0 => 90430)


--- trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/base_unittests.js	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/base_unittests.js	2011-07-06 03:15:24 UTC (rev 90430)
@@ -0,0 +1,58 @@
+module("base");
+
+test("joinPath", 1, function() {
+    var value = base.joinPath("path/to", "test.html");
+    equals(value, "path/to/test.html");
+});
+
+test("joinPath with empty parent", 1, function() {
+    var value = base.joinPath("", "test.html");
+    equals(value, "test.html");
+});
+
+test("filterTree", 2, function() {
+    var tree = {
+        'path': {
+            'to': {
+                'test.html': {
+                    'actual': 'PASS',
+                    'expected': 'FAIL'
+                }
+            },
+            'another.html': {
+                'actual': 'TEXT',
+                'expected': 'PASS'
+            }
+        }
+    }
+
+    function isLeaf(node)
+    {
+        return !!node.actual;
+    }
+
+    function actualIsText(node)
+    {
+        return node.actual == 'TEXT';
+    }
+
+    var all = base.filterTree(tree, isLeaf, function() { return true });
+    deepEqual(all, {
+        'path/to/test.html': {
+            'actual': 'PASS',
+            'expected': 'FAIL'
+        },
+        'path/another.html': {
+            'actual': 'TEXT',
+            'expected': 'PASS'
+        }
+    });
+
+    var text = base.filterTree(tree, isLeaf, actualIsText);
+    deepEqual(text, {
+        'path/another.html': {
+            'actual': 'TEXT',
+            'expected': 'PASS'
+        }
+    });
+});

Added: trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/run-unittests.html (0 => 90430)


--- trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/run-unittests.html	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/servers/data/gardeningserver/run-unittests.html	2011-07-06 03:15:24 UTC (rev 90430)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<h1 id="qunit-header">Gardening Server _javascript_ Unit Tests</h1>
+<h2 id="qunit-banner"></h2>
+<div id="qunit-testrunner-toolbar"></div>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests"></ol>
+<script src=""
+<script src=""
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to