Fix bot summary when URIs couldn't be read.

R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2999433002 .
This commit is contained in:
Florian Loitsch 2017-08-04 14:46:53 +02:00
parent 33f1fc8059
commit aaf67e5050
2 changed files with 12 additions and 2 deletions

View file

@ -26,7 +26,7 @@ main(List<String> args) async {
var recentUris = bot.mostRecentUris;
var results = await bot.readResults(recentUris);
results.forEach((result) {
if (result.hasFailures) {
if (result != null && result.hasFailures) {
print("${result.buildUri} has failures.");
}
});

View file

@ -38,6 +38,10 @@ class Bot {
return _client.readResult(buildUri);
}
/// Reads the build results of all given uris.
///
/// Returns a list of the results. If a uri couldn't be read, then the entry
/// in the list is `null`.
Future<List<BuildResult>> readResults(List<BuildUri> buildUris) async {
var result = <BuildResult>[];
int i = 0;
@ -47,7 +51,13 @@ class Bot {
if (end > buildUris.length) end = buildUris.length;
var parallelChunk = buildUris.sublist(i, end);
log("Fetching ${end - i} uris in parallel");
result.addAll(await Future.wait(parallelChunk.map(_client.readResult)));
result.addAll(await Future.wait(parallelChunk.map((uri) {
var result = _client.readResult(uri);
if (result == null) {
log("Error while reading $uri");
}
return result;
})));
i = end + 1;
}
return result;