| 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 kWebKitTestsStepNames = ['webkit_tests', 'layout-test']; | |
| 31 var kCrashedOrHungOutputMarker = 'crashed or hung'; | |
| 32 | |
| 33 function urlForBuildInfo(builderName, buildNumber) | |
| 34 { | |
| 35 return config.buildConsoleURL + '/json/builders/' + encodeURIComponent(build
erName) + '/builds/' + encodeURIComponent(buildNumber); | |
| 36 } | |
| 37 | |
| 38 function didFail(step) | |
| 39 { | |
| 40 if (kWebKitTestsStepNames.indexOf(step.name) != -1) { | |
| 41 // run-webkit-tests fails to generate test coverage when it crashes or h
angs. | |
| 42 // FIXME: Do build.webkit.org bots output this marker when the tests fai
l to run? | |
| 43 return step.text.indexOf(kCrashedOrHungOutputMarker) != -1; | |
| 44 } | |
| 45 // The first item in step.results is the success of the step: | |
| 46 // 0 == pass, 1 == warning, 2 == fail | |
| 47 return step.results[0] == 2; | |
| 48 } | |
| 49 | |
| 50 function failingSteps(buildInfo) | |
| 51 { | |
| 52 return buildInfo.steps.filter(didFail); | |
| 53 } | |
| 54 | |
| 55 function mostRecentCompletedBuildNumber(individualBuilderStatus) | |
| 56 { | |
| 57 if (!individualBuilderStatus) | |
| 58 return null; | |
| 59 | |
| 60 for (var i = individualBuilderStatus.cachedBuilds.length - 1; i >= 0; --i) { | |
| 61 var buildNumber = individualBuilderStatus.cachedBuilds[i]; | |
| 62 if (individualBuilderStatus.currentBuilds.indexOf(buildNumber) == -1) | |
| 63 return buildNumber; | |
| 64 } | |
| 65 | |
| 66 return null; | |
| 67 } | |
| 68 | |
| 69 var g_buildInfoCache = new base.AsynchronousCache(function(key) { | |
| 70 var explodedKey = key.split('\n'); | |
| 71 return net.json(urlForBuildInfo(explodedKey[0], explodedKey[1])); | |
| 72 }); | |
| 73 | |
| 74 builders.clearBuildInfoCache = function() | |
| 75 { | |
| 76 g_buildInfoCache.clear(); | |
| 77 }; | |
| 78 | |
| 79 function fetchMostRecentBuildInfoByBuilder() | |
| 80 { | |
| 81 var buildInfoByBuilder = {}; | |
| 82 var requestPromises = []; | |
| 83 return net.json(config.buildConsoleURL + '/json/builders').then(function(bui
lderStatus) { | |
| 84 var builderNames = Object.keys(builderStatus); | |
| 85 builderNames.forEach(function(builderName) { | |
| 86 if (!config.builderApplies(builderName)) | |
| 87 return; | |
| 88 | |
| 89 var buildNumber = mostRecentCompletedBuildNumber(builderStatus[build
erName]); | |
| 90 if (!buildNumber) | |
| 91 return; | |
| 92 | |
| 93 requestPromises.push(g_buildInfoCache.get(builderName + '\n' + build
Number) | |
| 94 .then(function(buildInfo) { | |
| 95 buildInfoByBuilder[builderName] = buildInfo
; | |
| 96 })); | |
| 97 }); | |
| 98 | |
| 99 return Promise.all(requestPromises).then(function() { | |
| 100 return buildInfoByBuilder; | |
| 101 }); | |
| 102 }); | |
| 103 } | |
| 104 | |
| 105 builders.buildersFailingNonLayoutTests = function() | |
| 106 { | |
| 107 return fetchMostRecentBuildInfoByBuilder().then(function(buildInfoByBuilder)
{ | |
| 108 var failureList = {}; | |
| 109 Object.keys(buildInfoByBuilder, function(builderName, buildInfo) { | |
| 110 if (!buildInfo) | |
| 111 return; | |
| 112 var failures = failingSteps(buildInfo); | |
| 113 if (failures.length) | |
| 114 failureList[builderName] = failures.map(function(failure) { retu
rn failure.name; }); | |
| 115 }); | |
| 116 return failureList; | |
| 117 }); | |
| 118 }; | |
| 119 | |
| 120 builders.mostRecentBuildForBuilder = function(builderName) { | |
| 121 return net.json(config.buildConsoleURL + '/json/builders/' + builderName).th
en(function(builderStatus) { | |
| 122 var cachedBuilds = builderStatus.cachedBuilds; | |
| 123 var mostRecentBuild = Math.max.apply(Math, cachedBuilds); | |
| 124 return mostRecentBuild; | |
| 125 }); | |
| 126 }; | |
| 127 | |
| 128 })(); | |
| OLD | NEW |