Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: tools/gardening/bin/compare_failures.dart

Issue 2912343002: Add BuildBotClient to abstract http/logdog access (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gardening/bin/current_summary.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gardening/bin/compare_failures.dart
diff --git a/tools/gardening/bin/compare_failures.dart b/tools/gardening/bin/compare_failures.dart
index 8ccf5d66ce898ebf4e27ef016d073cd13e011397..4005a7c716502e74a78759bc77dfea5ddcb2feb6 100644
--- a/tools/gardening/bin/compare_failures.dart
+++ b/tools/gardening/bin/compare_failures.dart
@@ -11,13 +11,18 @@ import 'dart:io';
import 'package:args/args.dart';
import 'package:gardening/src/buildbot_structures.dart';
-import 'package:gardening/src/buildbot_loading.dart';
+import 'package:gardening/src/client.dart';
import 'package:gardening/src/util.dart';
main(List<String> args) async {
ArgParser argParser = createArgParser();
ArgResults argResults = argParser.parse(args);
processArgResults(argResults);
+
+ BuildbotClient client = argResults['logdog']
+ ? new LogdogBuildbotClient()
+ : new HttpBuildbotClient();
+
if (argResults.rest.length != 1) {
print('Usage: compare_failures [options] <log-uri>');
print('where <log-uri> is the uri the stdio output of a failing test step');
@@ -31,7 +36,6 @@ main(List<String> args) async {
url += '/text';
}
Uri uri = Uri.parse(url);
- HttpClient client = new HttpClient();
BuildUri buildUri = new BuildUri(uri);
List<BuildResult> results = await readBuildResults(client, buildUri);
print(generateBuildResultsSummary(buildUri, results));
@@ -41,14 +45,15 @@ main(List<String> args) async {
/// Creates a [BuildResult] for [buildUri] and, if it contains failures, the
/// [BuildResult]s for the previous 5 builds.
Future<List<BuildResult>> readBuildResults(
- HttpClient client, BuildUri buildUri) async {
+ BuildbotClient client, BuildUri buildUri) async {
List<BuildResult> summaries = <BuildResult>[];
- BuildResult firstSummary = await readBuildResult(client, buildUri);
- summaries.add(firstSummary);
- if (firstSummary.hasFailures) {
+ BuildResult summary = await client.readResult(buildUri);
+ summaries.add(summary);
+ if (summary.hasFailures) {
for (int i = 0; i < 10; i++) {
- buildUri = buildUri.prev();
- summaries.add(await readBuildResult(client, buildUri));
+ buildUri = summary.buildUri.prev();
+ summary = await client.readResult(buildUri);
+ summaries.add(summary);
}
}
return summaries;
@@ -64,8 +69,6 @@ String generateBuildResultsSummary(
timeoutIds.addAll(result.timeouts.map((TestFailure failure) => failure.id));
}
if (timeoutIds.isNotEmpty) {
- int firstBuildNumber = results.first.buildUri.buildNumber;
- int lastBuildNumber = results.last.buildUri.buildNumber;
Map<TestConfiguration, Map<int, Map<String, Timing>>> map =
<TestConfiguration, Map<int, Map<String, Timing>>>{};
Set<String> stepNames = new Set<String>();
@@ -84,9 +87,8 @@ String generateBuildResultsSummary(
sb.write('$id\n');
sb.write(
'${' ' * 8} ${stepNames.map((t) => padRight(t, 14)).join(' ')}\n');
- for (int buildNumber = firstBuildNumber;
- buildNumber >= lastBuildNumber;
- buildNumber--) {
+ for (BuildResult result in results) {
+ int buildNumber = result.buildUri.buildNumber;
Map<String, Timing> steps = timings[buildNumber] ?? const {};
sb.write(padRight(' ${buildNumber}: ', 8));
for (String stepName in stepNames) {
@@ -107,8 +109,6 @@ String generateBuildResultsSummary(
errorIds.addAll(result.errors.map((TestFailure failure) => failure.id));
}
if (errorIds.isNotEmpty) {
- int firstBuildNumber = results.first.buildUri.buildNumber;
- int lastBuildNumber = results.last.buildUri.buildNumber;
Map<TestConfiguration, Map<int, TestFailure>> map =
<TestConfiguration, Map<int, TestFailure>>{};
for (BuildResult result in results) {
@@ -122,9 +122,8 @@ String generateBuildResultsSummary(
map.forEach((TestConfiguration id, Map<int, TestFailure> failures) {
if (!errorIds.contains(id)) return;
sb.write('$id\n');
- for (int buildNumber = firstBuildNumber;
- buildNumber >= lastBuildNumber;
- buildNumber--) {
+ for (BuildResult result in results) {
+ int buildNumber = result.buildUri.buildNumber;
TestFailure failure = failures[buildNumber];
sb.write(padRight(' ${buildNumber}: ', 8));
if (failure != null) {
« no previous file with comments | « no previous file | tools/gardening/bin/current_summary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698