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 6c26b55..bac0ec9 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 32731ea..f971a65 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 e51768a..54b077a 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 c37711b..592f53e 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 a6d8543..849c9c9 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 d7a90df..cb5b78b 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