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 /// Collects the test results for all build bots in [buildGroups] for tests | 5 /// Collects the test results for all build bots in [buildGroups] for tests |
6 /// that mention one of the test names given as argument. | 6 /// that mention one of the test names given as argument. |
7 /// | 7 /// |
8 /// The results are currently pulled from the second to last build since the | 8 /// The results are currently pulled from the second to last build since the |
9 /// last build might not have completed yet. | 9 /// last build might not have completed yet. |
10 | 10 |
11 import 'dart:math'; | 11 import 'dart:async'; |
| 12 import 'dart:math' hide log; |
12 import 'dart:io'; | 13 import 'dart:io'; |
13 | 14 |
14 import 'package:args/args.dart'; | 15 import 'package:args/args.dart'; |
15 import 'package:gardening/src/buildbot_data.dart'; | 16 import 'package:gardening/src/buildbot_data.dart'; |
16 import 'package:gardening/src/buildbot_loading.dart'; | 17 import 'package:gardening/src/buildbot_loading.dart'; |
17 import 'package:gardening/src/buildbot_structures.dart'; | 18 import 'package:gardening/src/buildbot_structures.dart'; |
18 import 'package:gardening/src/util.dart'; | 19 import 'package:gardening/src/util.dart'; |
19 | 20 |
| 21 void help(ArgParser argParser) { |
| 22 print('Displays the current status of specific tests on the buildbot'); |
| 23 print('Only prints output for failing tests.'); |
| 24 print('The test-names may be fully qualified (such as in '); |
| 25 print('"pkg/front_end/test/token_test") or just be a substring of the fully'); |
| 26 print(' qualified name.'); |
| 27 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); |
| 28 print('where options are:'); |
| 29 print(argParser.usage); |
| 30 } |
| 31 |
20 main(List<String> args) async { | 32 main(List<String> args) async { |
21 ArgParser argParser = createArgParser(); | 33 ArgParser argParser = createArgParser(); |
22 ArgResults argResults = argParser.parse(args); | 34 ArgResults argResults = argParser.parse(args); |
23 processArgResults(argResults); | 35 processArgResults(argResults); |
24 if (argResults.rest.length == 0) { | 36 if (argResults.rest.length == 0 || argResults['help']) { |
25 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); | 37 help(argParser); |
26 print('where options are:'); | 38 if (argResults['help']) return; |
27 print(argParser.usage); | |
28 exit(1); | 39 exit(1); |
29 } | 40 } |
30 int maxStatusWidth = 0; | 41 int maxStatusWidth = 0; |
31 int maxConfigWidth = 0; | 42 int maxConfigWidth = 0; |
32 | 43 |
33 HttpClient client = new HttpClient(); | 44 HttpClient client = new HttpClient(); |
34 Map<String, Map<BuildUri, TestStatus>> resultMap = | 45 Map<String, Map<BuildUri, TestStatus>> resultMap = |
35 <String, Map<BuildUri, TestStatus>>{}; | 46 <String, Map<BuildUri, TestStatus>>{}; |
36 for (BuildGroup group in buildGroups) { | 47 for (BuildGroup group in buildGroups) { |
37 // TODO(johnniwinther): Support reading a partially completed shard, i.e. | 48 // TODO(johnniwinther): Support reading a partially completed shard, i.e. |
38 // use build number `-1`. | 49 // use build number `-1`. |
39 for (BuildUri buildUri in group.createUris(-2)) { | 50 var resultFutures = group.createUris(-2).map((uri) { |
40 print('Reading $buildUri'); | 51 log('Fetching $uri'); |
41 BuildResult buildResult = await readBuildResult(client, buildUri); | 52 return readBuildResult(client, uri); |
| 53 }).toList(); |
| 54 var results = await Future.wait(resultFutures); |
| 55 for (BuildResult buildResult in results) { |
| 56 bool havePrintedUri = false; |
| 57 var buildUri = buildResult.buildUri; |
| 58 if (argResults['verbose']) { |
| 59 havePrintedUri = true; |
| 60 print('Reading $buildUri'); |
| 61 } |
42 for (TestStatus testStatus in buildResult.results) { | 62 for (TestStatus testStatus in buildResult.results) { |
43 String testName = testStatus.config.testName; | 63 String testName = testStatus.config.testName; |
44 for (String arg in argResults.rest) { | 64 for (String arg in argResults.rest) { |
45 if (testName.contains(arg) || arg.contains(testName)) { | 65 if (testName.contains(arg) || arg.contains(testName)) { |
| 66 if (!havePrintedUri) { |
| 67 havePrintedUri = true; |
| 68 print("$buildUri:"); |
| 69 } |
46 resultMap.putIfAbsent(testName, () => {})[buildUri] = testStatus; | 70 resultMap.putIfAbsent(testName, () => {})[buildUri] = testStatus; |
47 maxStatusWidth = max(maxStatusWidth, testStatus.status.length); | 71 maxStatusWidth = max(maxStatusWidth, testStatus.status.length); |
48 maxConfigWidth = | 72 maxConfigWidth = |
49 max(maxConfigWidth, testStatus.config.configName.length); | 73 max(maxConfigWidth, testStatus.config.configName.length); |
50 } | 74 } |
51 } | 75 } |
52 } | 76 } |
53 } | 77 } |
54 } | 78 } |
55 print(''); | 79 print(''); |
56 resultMap.forEach((String testName, Map<BuildUri, TestStatus> statusMap) { | 80 resultMap.forEach((String testName, Map<BuildUri, TestStatus> statusMap) { |
57 print(testName); | 81 print(testName); |
58 statusMap.forEach((BuildUri buildUri, TestStatus status) { | 82 statusMap.forEach((BuildUri buildUri, TestStatus status) { |
59 print(' ${padRight(status.status, maxStatusWidth)}: ' | 83 print(' ${padRight(status.status, maxStatusWidth)}: ' |
60 '${padRight(status.config.configName, maxConfigWidth)} ' | 84 '${padRight(status.config.configName, maxConfigWidth)} ' |
61 '${buildUri.shortBuildName}'); | 85 '${buildUri.shortBuildName}'); |
62 }); | 86 }); |
63 }); | 87 }); |
64 client.close(); | 88 client.close(); |
65 } | 89 } |
OLD | NEW |