| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Compares the test log of a build step with previous builds. | 5 /// Compares the test log of a build step with previous builds. |
| 6 /// | 6 /// |
| 7 /// Use this to detect flakiness of failures, especially timeouts. | 7 /// Use this to detect flakiness of failures, especially timeouts. |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 Uri uri = Uri.parse(url); | 51 Uri uri = Uri.parse(url); |
| 52 BuildUri buildUri = new BuildUri(uri); | 52 BuildUri buildUri = new BuildUri(uri); |
| 53 List<BuildResult> results = | 53 List<BuildResult> results = |
| 54 await readBuildResults(client, buildUri, runCount); | 54 await readBuildResults(client, buildUri, runCount); |
| 55 print(generateBuildResultsSummary(buildUri, results)); | 55 print(generateBuildResultsSummary(buildUri, results)); |
| 56 client.close(); | 56 client.close(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 /// Creates a [BuildResult] for [buildUri] and, if it contains failures, the | 59 /// Creates a [BuildResult] for [buildUri] and, if it contains failures, the |
| 60 /// [BuildResult]s for the previous 5 builds. | 60 /// [BuildResult]s for the previous [runCount] builds. |
| 61 Future<List<BuildResult>> readBuildResults( | 61 Future<List<BuildResult>> readBuildResults( |
| 62 BuildbotClient client, BuildUri buildUri, int runCount) async { | 62 BuildbotClient client, BuildUri buildUri, int runCount) async { |
| 63 List<BuildResult> summaries = <BuildResult>[]; | 63 List<BuildResult> summaries = <BuildResult>[]; |
| 64 BuildResult summary = await client.readResult(buildUri); | 64 BuildResult summary = await client.readResult(buildUri); |
| 65 summaries.add(summary); | 65 summaries.add(summary); |
| 66 if (summary.hasFailures) { | 66 if (summary.hasFailures) { |
| 67 for (int i = 0; i < runCount; i++) { | 67 for (int i = 0; i < runCount; i++) { |
| 68 buildUri = summary.buildUri.prev(); | 68 buildUri = summary.buildUri.prev(); |
| 69 summary = await client.readResult(buildUri); | 69 summary = await client.readResult(buildUri); |
| 70 summaries.add(summary); | 70 summaries.add(summary); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 sb.write(' / '); | 149 sb.write(' / '); |
| 150 sb.write(padRight('-- OK --', 10)); | 150 sb.write(padRight('-- OK --', 10)); |
| 151 } | 151 } |
| 152 sb.write('\n'); | 152 sb.write('\n'); |
| 153 } | 153 } |
| 154 sb.write('\n'); | 154 sb.write('\n'); |
| 155 }); | 155 }); |
| 156 } | 156 } |
| 157 return sb.toString(); | 157 return sb.toString(); |
| 158 } | 158 } |
| OLD | NEW |