Dashboard cleanup: remove usage of global g_defaultBuilderName
authorjparent@chromium.org <jparent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2013 00:26:26 +0000 (00:26 +0000)
committerjparent@chromium.org <jparent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2013 00:26:26 +0000 (00:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106043

Use now public defaultBuilder() from the BuilderGroup, rather
than global variable.

Also eliminates the setup() and initBuilders() functions since we
no longer need to track the global.

Reviewed by Adam Barth.

* TestResultServer/static-dashboards/builders.js:
(BuilderGroup.prototype.defaultBuilder):
(BuilderGroup.prototype.master):
* TestResultServer/static-dashboards/dashboard_base.js:
(parseParameters):
* TestResultServer/static-dashboards/flakiness_dashboard.js:
(updateDefaultBuilderState):
* TestResultServer/static-dashboards/loader.js:
(.):
* TestResultServer/static-dashboards/loader_unittests.js:

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

Tools/ChangeLog
Tools/TestResultServer/static-dashboards/builders.js
Tools/TestResultServer/static-dashboards/dashboard_base.js
Tools/TestResultServer/static-dashboards/flakiness_dashboard.js
Tools/TestResultServer/static-dashboards/loader.js
Tools/TestResultServer/static-dashboards/loader_unittests.js

index 6c26b55da96021f332957bc2f9b042a5c51956a5..bac0ec9dc4a337e67ceea7dcba96cb543b8faf50 100644 (file)
@@ -1,3 +1,27 @@
+2013-01-03  Julie Parent  <jparent@chromium.org>
+
+        Dashboard cleanup: remove usage of global g_defaultBuilderName
+        https://bugs.webkit.org/show_bug.cgi?id=106043
+
+        Use now public defaultBuilder() from the BuilderGroup, rather
+        than global variable.
+
+        Also eliminates the setup() and initBuilders() functions since we
+        no longer need to track the global.
+
+        Reviewed by Adam Barth.
+
+        * TestResultServer/static-dashboards/builders.js:
+        (BuilderGroup.prototype.defaultBuilder):
+        (BuilderGroup.prototype.master):
+        * TestResultServer/static-dashboards/dashboard_base.js:
+        (parseParameters):
+        * TestResultServer/static-dashboards/flakiness_dashboard.js:
+        (updateDefaultBuilderState):
+        * TestResultServer/static-dashboards/loader.js:
+        (.):
+        * TestResultServer/static-dashboards/loader_unittests.js:
+
 2013-01-03  Ryosuke Niwa  <rniwa@webkit.org>
 
         Disable an intermittently failing unit test for now.
index 32731ea168b5b3d224a02b7bfcc6576878869ac7..f971a651e1c71a7aba8a0ad88f0c33a80ed089c7 100644 (file)
@@ -122,14 +122,7 @@ BuilderGroup.prototype.append = function(builders) {
     }, this);
 };
 
-BuilderGroup.prototype.setup = function()
-{
-    // FIXME: instead of copying these to globals, it would be better if
-    // the rest of the code read things from the BuilderGroup instance directly
-    g_defaultBuilderName = this._defaultBuilder();
-};
-
-BuilderGroup.prototype._defaultBuilder = function()
+BuilderGroup.prototype.defaultBuilder = function()
 {
     for (var builder in this.builders)
         return builder;
@@ -138,7 +131,7 @@ BuilderGroup.prototype._defaultBuilder = function()
 
 BuilderGroup.prototype.master = function()
 {
-    return builderMaster(this._defaultBuilder());
+    return builderMaster(this.defaultBuilder());
 }
 
 BuilderGroup.TOT_WEBKIT = true;
index e51768a8a26225dd58c18a3b235b27222cf71a78..54b077afa35dd6626afe6f5848c80b8887fa9902 100644 (file)
@@ -328,8 +328,9 @@ function parseParameters()
     var dashboardSpecificDiffState = diffStates(oldDashboardSpecificState, g_currentState);
 
     fillMissingValues(g_currentState, g_defaultDashboardSpecificStateValues);
+
     if (!g_crossDashboardState.useTestData)
-        fillMissingValues(g_currentState, {'builder': g_defaultBuilderName});
+        fillMissingValues(g_currentState, {'builder': currentBuilderGroup().defaultBuilder()});
 
     // FIXME: dashboard_base shouldn't know anything about specific dashboard specific keys.
     if (dashboardSpecificDiffState.builder)
@@ -426,12 +427,6 @@ function isTipOfTreeWebKitBuilder()
     return currentBuilderGroup().isToTWebKit;
 }
 
-var g_defaultBuilderName;
-function initBuilders()
-{
-    currentBuilderGroup().setup();
-}
-
 var g_resultsByBuilder = {};
 var g_expectationsByPlatform = {};
 var g_staleBuilders = [];
index c37711b3cd6698d73f874c069fd37d5a1966f692..592f53ef231c1def6c08ae22d93a33794259c3d5 100644 (file)
@@ -2489,7 +2489,7 @@ function updateDefaultBuilderState()
     if (isCrossBuilderView())
         delete g_defaultDashboardSpecificStateValues.builder;
     else
-        g_defaultDashboardSpecificStateValues.builder = g_defaultBuilderName;
+        g_defaultDashboardSpecificStateValues.builder = currentBuilderGroup().defaultBuilder();
 }
 
 // Sets the page state to regenerate the page.
index a6d8543060892e2048badc3e731005ae53013122..849c9c9ae9074b6ddac6601d3bc9cb2e958bc403 100644 (file)
@@ -83,7 +83,6 @@ loader.Loader.prototype = {
     _loadBuildersList: function()
     {
         loadBuildersList(g_crossDashboardState.group, g_crossDashboardState.testType);
-        initBuilders();
         this._loadNext();
     },
     _loadResultsFiles: function()
@@ -170,19 +169,15 @@ loader.Loader.prototype = {
         delete currentBuilders()[builderName];
 
         // Change the default builder name if it has been deleted.
-        if (g_defaultBuilderName == builderName) {
-            g_defaultBuilderName = null;
-            for (var availableBuilderName in currentBuilders()) {
-                g_defaultBuilderName = availableBuilderName;
-                g_defaultDashboardSpecificStateValues.builder = availableBuilderName;
-                break;
-            }
-            if (!g_defaultBuilderName) {
+        if (g_defaultDashboardSpecificStateValues.builder == builderName) {
+            var defaultBuilderName = currentBuilderGroup().defaultBuilder();
+            g_defaultDashboardSpecificStateValues.builder = defaultBuilderName;
+            if (!defaultBuilderName) {
                 var error = 'No tests results found for ' + g_crossDashboardState.testType + '. Reload the page to try fetching it again.';
                 console.error(error);
                 addError(error);
             }
-        }
+       }
 
         // Proceed as if the resource had loaded.
         this._handleResourceLoad();
index d7a90dfb525dde693654ecf1ea89674ba641394d..cb5b78b6ff3b4c437d9b43bf8c992176d3f47b63 100644 (file)
@@ -139,14 +139,14 @@ test('Default builder gets set.', 3, function() {
     resetGlobals();
     loadBuildersList('@ToT - chromium.org', 'layout-tests');
     
-    var defaultBuilder = g_defaultBuilderName;
+    var defaultBuilder = currentBuilderGroup().defaultBuilder();
     ok(defaultBuilder, "Default builder should exist.");
    
     // Simulate error loading the default builder data, then make sure
     // a new defaultBuilder is set, and isn't the now invalid one.
     var resourceLoader = new loader.Loader();
     resourceLoader._handleResultsFileLoadError(defaultBuilder);
-    var newDefaultBuilder = g_defaultBuilderName;
+    var newDefaultBuilder = currentBuilderGroup().defaultBuilder();
     ok(newDefaultBuilder, "There should still be a default builder.");
     notEqual(newDefaultBuilder, defaultBuilder, "Default builder should not be the old default builder");
 });
\ No newline at end of file