Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js (195390 => 195391)
--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js 2016-01-20 23:40:44 UTC (rev 195390)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js 2016-01-21 00:20:33 UTC (rev 195391)
@@ -268,13 +268,9 @@
compareIterations: function(a, b)
{
- var sortedRepositories = Dashboard.sortedRepositories;
- for (var i = 0; i < sortedRepositories.length; ++i) {
- var repositoryName = sortedRepositories[i].name;
- var result = b.revision[repositoryName] - a.revision[repositoryName];
- if (result)
- return result;
- }
+ result = this.compareIterationsByRevisions(a, b);
+ if (result)
+ return result;
// A loaded iteration may not have revision numbers if it failed early, before svn steps finished.
result = b.loaded - a.loaded;
@@ -299,6 +295,6 @@
sortIterations: function()
{
- this.iterations.sort(this.compareIterations);
+ this.iterations.sort(this.compareIterations.bind(this));
}
};
Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js (195390 => 195391)
--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js 2016-01-20 23:40:44 UTC (rev 195390)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js 2016-01-21 00:20:33 UTC (rev 195391)
@@ -42,3 +42,97 @@
var revisionsBehind = view.element.getElementsByClassName("message")[0].innerHTML.match(/.*(\d+) revision(|s) behind/)[1];
equal(revisionsBehind, "1", "assert revisions behind");
});
+
+module("BuildBotQueue", {
+ setup: function() {
+ this.queue = new MockBuildbotQueue();
+ this.queue.branches = [{
+ name: "trunk",
+ repository: {
+ name: "openSource",
+ }
+ }];
+ }
+});
+
+test("compareIterations by revisions", function()
+{
+ var finished = false;
+ var iteration1 = new BuildbotIteration(this.queue, 1, finished);
+ var iteration2 = new BuildbotIteration(this.queue, 2, finished);
+ iteration1.revision = { "openSource": 33018 };
+ iteration2.revision = { "openSource": 33019 };
+ iteration1.loaded = true;
+ iteration2.loaded = true;
+ ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
+ ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
+ strictEqual(this.queue.compareIterations(iteration2, iteration2), 0, "compareIterations: equal");
+});
+
+test("compareIterations by loaded (one revision missing)", function()
+{
+ var finished = false;
+ var iteration1 = new BuildbotIteration(this.queue, 1, finished);
+ var iteration2 = new BuildbotIteration(this.queue, 2, finished);
+ iteration1.revision = {};
+ iteration2.revision = { "openSource": 33019 };
+ iteration1.loaded = false;
+ iteration2.loaded = true;
+ ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
+ ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
+});
+
+test("compareIterations by loaded (same revision)", function()
+{
+ var finished = false;
+ var iteration1 = new BuildbotIteration(this.queue, 1, finished);
+ var iteration2 = new BuildbotIteration(this.queue, 2, finished);
+ iteration1.revision = { "openSource": 33019 };
+ iteration2.revision = { "openSource": 33019 };
+ iteration1.loaded = false;
+ iteration2.loaded = true;
+ ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
+ ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
+});
+
+test("compareIterations by id (revisions not specified)", function()
+{
+ var finished = false;
+ var iteration1 = new BuildbotIteration(this.queue, 1, finished);
+ var iteration2 = new BuildbotIteration(this.queue, 2, finished);
+ iteration1.revision = {};
+ iteration2.revision = {};
+ iteration1.loaded = false;
+ iteration2.loaded = false;
+ ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
+ ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
+ strictEqual(this.queue.compareIterations(iteration2, iteration2), 0, "compareIterations: equal");
+});
+
+test("compareIterations by id (same revision)", function()
+{
+ var finished = false;
+ var iteration1 = new BuildbotIteration(this.queue, 1, finished);
+ var iteration2 = new BuildbotIteration(this.queue, 2, finished);
+ iteration1.revision = { "openSource": 33019 };
+ iteration2.revision = { "openSource": 33019 };
+ iteration1.loaded = false;
+ iteration2.loaded = false;
+ ok(this.queue.compareIterations(iteration2, iteration1) < 0, "compareIterations: less than");
+ ok(this.queue.compareIterations(iteration1, iteration2) > 0, "compareIterations: greater than");
+ strictEqual(this.queue.compareIterations(iteration2, iteration2), 0, "compareIterations: equal");
+});
+
+test("compareIterationsByRevisions", function()
+{
+ var finished = false;
+ var iteration1 = new BuildbotIteration(this.queue, 1, finished);
+ var iteration2 = new BuildbotIteration(this.queue, 2, finished);
+ iteration1.revision = { "openSource": 33018 };
+ iteration2.revision = { "openSource": 33019 };
+ iteration1.loaded = true;
+ iteration2.loaded = false;
+ ok(this.queue.compareIterationsByRevisions(iteration2, iteration1) < 0, "compareIterationsByRevisions: less than");
+ ok(this.queue.compareIterationsByRevisions(iteration1, iteration2) > 0, "compareIterationsByRevisions: greater than");
+ strictEqual(this.queue.compareIterationsByRevisions(iteration2, iteration2), 0, "compareIterationsByRevisions: equal");
+});
\ No newline at end of file