| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 var builders = builders || {}; | |
| 27 | |
| 28 (function() { | |
| 29 | |
| 30 var kUpdateStepName = 'update'; | |
| 31 var kUpdateScriptsStepName = 'update_scripts'; | |
| 32 var kCompileStepName = 'compile'; | |
| 33 var kWebKitTestsStepNames = ['webkit_tests', 'layout-test']; | |
| 34 | |
| 35 var kCrashedOrHungOutputMarker = 'crashed or hung'; | |
| 36 | |
| 37 function buildBotURL(platform) | |
| 38 { | |
| 39 return config.kPlatforms[platform].buildConsoleURL; | |
| 40 } | |
| 41 | |
| 42 function urlForBuilderInfo(platform, builderName) | |
| 43 { | |
| 44 return buildBotURL(platform) + '/json/builders/' + encodeURIComponent(builde
rName) + '/'; | |
| 45 } | |
| 46 | |
| 47 function urlForBuildInfo(platform, builderName, buildNumber) | |
| 48 { | |
| 49 return buildBotURL(platform) + '/json/builders/' + encodeURIComponent(builde
rName) + '/builds/' + encodeURIComponent(buildNumber); | |
| 50 } | |
| 51 | |
| 52 function didFail(step) | |
| 53 { | |
| 54 if (kWebKitTestsStepNames.indexOf(step.name) != -1) { | |
| 55 // run-webkit-tests fails to generate test coverage when it crashes or h
angs. | |
| 56 // FIXME: Do build.webkit.org bots output this marker when the tests fai
l to run? | |
| 57 return step.text.indexOf(kCrashedOrHungOutputMarker) != -1; | |
| 58 } | |
| 59 // The first item in step.results is the success of the step: | |
| 60 // 0 == pass, 1 == warning, 2 == fail | |
| 61 return step.results[0] == 2; | |
| 62 } | |
| 63 | |
| 64 function failingSteps(buildInfo) | |
| 65 { | |
| 66 return buildInfo.steps.filter(didFail); | |
| 67 } | |
| 68 | |
| 69 function mostRecentCompletedBuildNumber(individualBuilderStatus) | |
| 70 { | |
| 71 if (!individualBuilderStatus) | |
| 72 return null; | |
| 73 | |
| 74 for (var i = individualBuilderStatus.cachedBuilds.length - 1; i >= 0; --i) { | |
| 75 var buildNumber = individualBuilderStatus.cachedBuilds[i]; | |
| 76 if (individualBuilderStatus.currentBuilds.indexOf(buildNumber) == -1) | |
| 77 return buildNumber; | |
| 78 } | |
| 79 | |
| 80 return null; | |
| 81 } | |
| 82 | |
| 83 var g_buildInfoCache = new base.AsynchronousCache(function(key, callback) { | |
| 84 var explodedKey = key.split('\n'); | |
| 85 net.get(urlForBuildInfo(explodedKey[0], explodedKey[1], explodedKey[2]), cal
lback); | |
| 86 }); | |
| 87 | |
| 88 builders.clearBuildInfoCache = function() | |
| 89 { | |
| 90 g_buildInfoCache.clear(); | |
| 91 } | |
| 92 | |
| 93 function fetchMostRecentBuildInfoByBuilder(platform, callback) | |
| 94 { | |
| 95 net.get(buildBotURL(platform) + '/json/builders', function(builderStatus) { | |
| 96 var buildInfoByBuilder = {}; | |
| 97 var builderNames = Object.keys(builderStatus); | |
| 98 var requestTracker = new base.RequestTracker(builderNames.length, callba
ck, [buildInfoByBuilder]); | |
| 99 builderNames.forEach(function(builderName) { | |
| 100 if (!config.builderApplies(builderName)) { | |
| 101 requestTracker.requestComplete(); | |
| 102 return; | |
| 103 } | |
| 104 | |
| 105 var buildNumber = mostRecentCompletedBuildNumber(builderStatus[build
erName]); | |
| 106 if (!buildNumber) { | |
| 107 buildInfoByBuilder[builderName] = null; | |
| 108 requestTracker.requestComplete(); | |
| 109 return; | |
| 110 } | |
| 111 | |
| 112 g_buildInfoCache.get(platform + '\n' + builderName + '\n' + buildNum
ber, function(buildInfo) { | |
| 113 buildInfoByBuilder[builderName] = buildInfo; | |
| 114 requestTracker.requestComplete(); | |
| 115 }); | |
| 116 }); | |
| 117 }); | |
| 118 } | |
| 119 | |
| 120 builders.builderInfo = function(platform, builderName, callback) | |
| 121 { | |
| 122 var builderInfoURL = urlForBuilderInfo(platform, builderName); | |
| 123 net.get(builderInfoURL, callback); | |
| 124 }; | |
| 125 | |
| 126 builders.cachedBuildInfos = function(platform, builderName, callback) | |
| 127 { | |
| 128 var builderInfoURL = urlForBuilderInfo(platform, builderName); | |
| 129 net.get(builderInfoURL, function(builderInfo) { | |
| 130 var selectURL = urlForBuilderInfo(platform, builderName) + 'builds'; | |
| 131 var start = Math.max(0, builderInfo.cachedBuilds.length - config.kBuildN
umberLimit); | |
| 132 var selectParams = { select : builderInfo.cachedBuilds.slice(start) }; | |
| 133 var traditionalEncoding = true; | |
| 134 selectURL += '?' + $.param(selectParams, traditionalEncoding); | |
| 135 net.get(selectURL, callback); | |
| 136 }); | |
| 137 } | |
| 138 | |
| 139 builders.recentBuildInfos = function(callback) | |
| 140 { | |
| 141 fetchMostRecentBuildInfoByBuilder(config.currentPlatform, function(buildInfo
ByBuilder) { | |
| 142 var buildInfo = {}; | |
| 143 $.each(buildInfoByBuilder, function(builderName, thisBuildInfo) { | |
| 144 if (!buildInfo) | |
| 145 return; | |
| 146 | |
| 147 buildInfo[builderName] = thisBuildInfo; | |
| 148 }); | |
| 149 callback(buildInfo); | |
| 150 }); | |
| 151 }; | |
| 152 | |
| 153 builders.buildersFailingNonLayoutTests = function(callback) | |
| 154 { | |
| 155 fetchMostRecentBuildInfoByBuilder(config.currentPlatform, function(buildInfo
ByBuilder) { | |
| 156 var failureList = {}; | |
| 157 $.each(buildInfoByBuilder, function(builderName, buildInfo) { | |
| 158 if (!buildInfo) | |
| 159 return; | |
| 160 var failures = failingSteps(buildInfo); | |
| 161 if (failures.length) | |
| 162 failureList[builderName] = failures.map(function(failure) { retu
rn failure.name; }); | |
| 163 }); | |
| 164 callback(failureList); | |
| 165 }); | |
| 166 }; | |
| 167 | |
| 168 builders.perfBuilders = function(callback) | |
| 169 { | |
| 170 fetchMostRecentBuildInfoByBuilder(config.currentPlatform, function(buildInfo
ByBuilder) { | |
| 171 var perfTestMap = {}; | |
| 172 $.each(buildInfoByBuilder, function(builderName, buildInfo) { | |
| 173 if (!buildInfo || builderName.indexOf('Perf') == -1) | |
| 174 return; | |
| 175 | |
| 176 buildInfo.steps.forEach(function(step) { | |
| 177 // FIXME: If the compile is broken, grab an older build. | |
| 178 // If the compile/update is broken, no steps will have a results
url. | |
| 179 if (!step.urls.results) | |
| 180 return; | |
| 181 if (!perfTestMap[step.name]) | |
| 182 perfTestMap[step.name] = []; | |
| 183 perfTestMap[step.name].push({ builder: builderName, url: step.ur
ls.results }); | |
| 184 }); | |
| 185 }); | |
| 186 callback(perfTestMap); | |
| 187 }); | |
| 188 } | |
| 189 | |
| 190 })(); | |
| OLD | NEW |