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

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

Issue 2908403002: Add a 'bot.dart' executable to the gardening tools. (Closed)
Patch Set: Address comments. 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 | « tools/gardening/bin/bot.dart ('k') | tools/gardening/bin/create_shard_groups.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..ae85bac8815b92feda8b9da73077d7c5f2a59d94 100644
--- a/tools/gardening/bin/compare_failures.dart
+++ b/tools/gardening/bin/compare_failures.dart
@@ -14,15 +14,28 @@ import 'package:gardening/src/buildbot_structures.dart';
import 'package:gardening/src/buildbot_loading.dart';
import 'package:gardening/src/util.dart';
+void help(ArgParser argParser) {
+ print('Given a <log-uri> finds all failing tests in that stdout. Then ');
+ print('fetches earlier runs of the same bot and compares the results.');
+ print('This tool is particularly useful to detect flakes and their ');
+ print('frequency.');
+ print('Usage: compare_failures [options] <log-uri>');
+ print('where <log-uri> is the uri the stdio output of a failing test step');
+ print('and options are:');
+ print(argParser.usage);
+}
+
main(List<String> args) async {
ArgParser argParser = createArgParser();
+ argParser.addOption("run-count",
+ defaultsTo: "10", help: "How many previous runs should be fetched");
ArgResults argResults = argParser.parse(args);
processArgResults(argResults);
- 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');
- print('and options are:');
- print(argParser.usage);
+ var runCount = int.parse(argResults['run-count'], onError: (_) => null);
+
+ if (argResults.rest.length != 1 || argResults['help'] || runCount == null) {
+ help(argParser);
+ if (argResults['help']) return;
exit(1);
}
String url = argResults.rest.first;
@@ -33,7 +46,8 @@ main(List<String> args) async {
Uri uri = Uri.parse(url);
HttpClient client = new HttpClient();
BuildUri buildUri = new BuildUri(uri);
- List<BuildResult> results = await readBuildResults(client, buildUri);
+ List<BuildResult> results =
+ await readBuildResults(client, buildUri, runCount);
print(generateBuildResultsSummary(buildUri, results));
client.close();
}
@@ -41,12 +55,12 @@ 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 {
+ HttpClient client, BuildUri buildUri, int runCount) async {
List<BuildResult> summaries = <BuildResult>[];
BuildResult firstSummary = await readBuildResult(client, buildUri);
summaries.add(firstSummary);
if (firstSummary.hasFailures) {
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < runCount; i++) {
buildUri = buildUri.prev();
summaries.add(await readBuildResult(client, buildUri));
}
« no previous file with comments | « tools/gardening/bin/bot.dart ('k') | tools/gardening/bin/create_shard_groups.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698