Add a unit test to test BuildbotQueueView._appendPendingRevisionCount. https://bugs...
authorjmarcell@apple.com <jmarcell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jan 2016 19:01:36 +0000 (19:01 +0000)
committerjmarcell@apple.com <jmarcell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jan 2016 19:01:36 +0000 (19:01 +0000)
Reviewed by Daniel Bates.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueue.js: Added.
(MockBuildbotQueue): Added. Mock BuildbotQueue object that doesn't need to talk to an actual Buildbot server.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueueView.js: Added.
(MockBuildbotQueueView): Added. Mock BuildbotQueueView object that returns a pre-specified _latestProductiveIteration without
the need to talk to a real Buildbot server.
(MockBuildbotQueueView.prototype._latestProductiveIteration): Added. Returns a pre-specified _latestProductiveIteration
without the need to talk to a real Buildbot server.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js: Added.
(MockTrac): Added. Mock Trac constructor that has pre-populated "recordedCommits" and does not need to talk to a real Trac
server.
(MockTrac.prototype.get oldestRecordedRevisionNumber): Added. Returns a pre-specified revision.
(MockTrac.prototype.get latestRecordedRevisionNumber): Ditto.
(MockTrac.prototype.loadMoreHistoricalData): Added. Overrides the real loadMoreHistoricalData so that we don't waste time
trying to talk to Trac.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/index.html: Added. Web page container for
QUnit unit tests.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added. QUnit unit tests.

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

Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueue.js [new file with mode: 0644]
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueueView.js [new file with mode: 0644]
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js [new file with mode: 0644]
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/index.html [new file with mode: 0644]
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js [new file with mode: 0644]
Tools/ChangeLog

diff --git a/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueue.js b/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueue.js
new file mode 100644 (file)
index 0000000..2107ee7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+MockBuildbotQueue = function()
+{
+    info = {
+        branches: "",
+        platform: "",
+        debug: "",
+        builder: "",
+        tester: "",
+        performance: "",
+        staticAnalyzer: "",
+        leaks: "",
+        architecture: "",
+        testCategory: "",
+        heading: "",
+        crashesOnly: ""
+    };
+    BuildbotQueue.call(this, "Mock BuildBot", "id", info);
+};
+
+BaseObject.addConstructorFunctions(MockBuildbotQueue);
+
+MockBuildbotQueue.prototype = {
+    constructor: MockBuildbotQueue,
+    __proto__: BuildbotQueue.prototype
+}
diff --git a/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueueView.js b/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueueView.js
new file mode 100644 (file)
index 0000000..ce6fa19
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+MockBuildbotQueueView = function(queues)
+{
+    this.element = document.createElement("div");
+    this.element.classList.add("queue-view");
+    this.element.__queueView = this;
+
+    this.queues = queues || [];
+
+    BaseObject.call(this);
+};
+
+BaseObject.addConstructorFunctions(MockBuildbotQueueView);
+
+MockBuildbotQueueView.prototype = {
+    constructor: MockBuildbotQueueView,
+    __proto__: BuildbotQueueView.prototype,
+
+    _latestProductiveIteration: function(queue)
+    {
+        return {
+            revision: {
+                "openSource": 33020
+            }
+        };
+    }
+};
diff --git a/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js b/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js
new file mode 100644 (file)
index 0000000..1c65441
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+MockTrac = function()
+{
+    Trac.call(this, "https://trac.webkit.org/");
+    this.recordedCommits = [
+        {
+            "revisionNumber": 33018,
+            "link": "http://trac.webkit.org/repository/changeset/77018/safari",
+            "title": {},
+            "author": "John",
+            "date": "2015-11-15T17:05:44.000Z",
+            "description": "description",
+            "containsBranchLocation": true,
+            "branch": "trunk"
+        },
+        {
+            "revisionNumber": 33019,
+            "link": "http://trac.webkit.org/repository/changeset/77019/safari",
+            "title": {},
+            "author": "Paul",
+            "date": "2015-11-16T01:18:23.000Z",
+            "description": "description",
+            "containsBranchLocation": true,
+            "branch": "trunk"
+        },
+        {
+            "revisionNumber": 33020,
+            "link": "http://trac.webkit.org/repository/changeset/77020/safari",
+            "title": {},
+            "author": "George",
+            "date": "2015-11-16T01:19:27.000Z",
+            "description": "description",
+            "containsBranchLocation": true,
+            "branch": "trunk"
+        },
+        {
+            "revisionNumber": 33021,
+            "link": "http://trac.webkit.org/repository/changeset/77021/safari",
+            "title": {},
+            "author": "Ringo",
+            "date": "2015-11-16T01:20:58.000Z",
+            "description": "description",
+            "containsBranchLocation": true,
+            "branch": "someOtherBranch"
+        },
+        {
+            "revisionNumber": 33022,
+            "link": "http://trac.webkit.org/repository/changeset/77022/safari",
+            "title": {},
+            "author": "Bob",
+            "date": "2015-11-16T01:22:01.000Z",
+            "description": "description",
+            "containsBranchLocation": true,
+            "branch": "trunk"
+        }
+    ];
+};
+
+BaseObject.addConstructorFunctions(MockTrac);
+
+MockTrac.prototype = {
+    constructor: MockTrac,
+    __proto__: Trac.prototype,
+
+    get oldestRecordedRevisionNumber()
+    {
+        return 33018;
+    },
+
+    get latestRecordedRevisionNumber()
+    {
+        return 33022;
+    },
+
+    loadMoreHistoricalData: function()
+    {
+    },
+};
diff --git a/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/index.html b/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/index.html
new file mode 100644 (file)
index 0000000..cb4245d
--- /dev/null
@@ -0,0 +1,78 @@
+<!doctype html>
+<!--
+Copyright (C) 2016 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.
+-->
+
+<html>
+<head>
+    <meta charset="UTF-8">
+
+    <title>WebKit Bot Watcher's Dashboard QUnit Test Runner</title>
+
+    <link rel="stylesheet" href="../../../../../../../Source/ThirdParty/qunit/qunit/qunit.css">
+    <link rel="stylesheet" href="../../Styles/Main.css"></link>
+    <link rel="stylesheet" href="../../Styles/Popover.css"></link>
+    <link rel="stylesheet" href="../../Styles/QueueView.css"></link>
+    <link rel="stylesheet" href="../../Styles/StatusLineView.css"></link>
+
+    <script src="../Utilities.js"></script>
+    <script src="../BaseObject.js"></script>
+    <script src="../Dashboard.js"></script>
+    <script src="../Buildbot.js"></script>
+    <script src="../Bugzilla.js"></script>
+    <script src="../BubbleQueueServer.js"></script>
+    <script src="../WebKitBuildbot.js"></script>
+    <script src="../BuildbotQueue.js"></script>
+    <script src="../BubbleQueue.js"></script>
+    <script src="../BuildbotIteration.js"></script>
+    <script src="../BuildbotTestResults.js"></script>
+    <script src="../Geometry.js"></script>
+    <script src="../Popover.js"></script>
+    <script src="../PopoverTracker.js"></script>
+    <script src="../QueueView.js"></script>
+    <script src="../BuildbotQueueView.js"></script>
+    <script src="../BuildbotBuilderQueueView.js"></script>
+    <script src="../BuildbotTesterQueueView.js"></script>
+    <script src="../BuildbotCombinedQueueView.js"></script>
+    <script src="../BuildbotPerformanceQueueView.js"></script>
+    <script src="../BuildbotLeaksQueueView.js"></script>
+    <script src="../BubbleQueueView.js"></script>
+    <script src="../StatusLineView.js"></script>
+    <script src="../Settings.js"></script>
+    <script src="../Trac.js"></script>
+    <script src="../../../../../../../Source/ThirdParty/qunit/qunit/qunit.js"></script>
+    <script src="MockTrac.js"></script>
+    <script src="MockBuildbotQueue.js"></script>
+    <script src="MockBuildbotQueueView.js"></script>
+    <script src="tests.js"></script>
+
+</head>
+<body>
+    <h1 id="qunit-header">WebKit Bot Watcher's Dashboard QUnit Test Runner</h1>
+    <h2 id="qunit-banner"></h2>
+    <div id="qunit-testrunner-toolbar"></div>
+    <h2 id="qunit-userAgent"></h2>
+    <ol id="qunit-tests"></ol>
+</body>
+</html>
\ No newline at end of file
diff --git a/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js b/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js
new file mode 100644 (file)
index 0000000..1934008
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+module("BuildBotQueueView");
+
+var settings = new Settings;
+test("_appendPendingRevisionCount", function()
+{
+    trac = new MockTrac();
+    var queue = new MockBuildbotQueue();
+    queue.branches = [{
+        name: "trunk",
+        repository: {
+            name: "openSource",
+            trac: trac
+        }
+    }]
+    var view = new MockBuildbotQueueView([queue]);
+    view._appendPendingRevisionCount(queue);
+    var revisionsBehind = view.element.getElementsByClassName("message")[0].innerHTML.match(/.*(\d+) revision(|s) behind/)[1];
+    equal(revisionsBehind, "1", "assert revisions behind");
+});
index b3709f5..c1161a8 100644 (file)
@@ -1,3 +1,28 @@
+2016-01-14  Jason Marcell  <jmarcell@apple.com>
+
+        Add a unit test to test BuildbotQueueView._appendPendingRevisionCount.
+        https://bugs.webkit.org/show_bug.cgi?id=152910
+
+        Reviewed by Daniel Bates.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueue.js: Added.
+        (MockBuildbotQueue): Added. Mock BuildbotQueue object that doesn't need to talk to an actual Buildbot server.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockBuildbotQueueView.js: Added.
+        (MockBuildbotQueueView): Added. Mock BuildbotQueueView object that returns a pre-specified _latestProductiveIteration without
+        the need to talk to a real Buildbot server.
+        (MockBuildbotQueueView.prototype._latestProductiveIteration): Added. Returns a pre-specified _latestProductiveIteration
+        without the need to talk to a real Buildbot server.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js: Added.
+        (MockTrac): Added. Mock Trac constructor that has pre-populated "recordedCommits" and does not need to talk to a real Trac
+        server.
+        (MockTrac.prototype.get oldestRecordedRevisionNumber): Added. Returns a pre-specified revision.
+        (MockTrac.prototype.get latestRecordedRevisionNumber): Ditto.
+        (MockTrac.prototype.loadMoreHistoricalData): Added. Overrides the real loadMoreHistoricalData so that we don't waste time
+        trying to talk to Trac.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/index.html: Added. Web page container for
+        QUnit unit tests.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added. QUnit unit tests.
+
 2016-01-14  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
 
         [CMake][GTK] CMake Error: Could not create named generator Eclipse CDT4 - Ninja
 2016-01-14  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
 
         [CMake][GTK] CMake Error: Could not create named generator Eclipse CDT4 - Ninja