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:async'; | |
12 import 'dart:math' hide log; | 11 import 'dart:math' hide log; |
13 import 'dart:io'; | 12 import 'dart:io'; |
14 | 13 |
15 import 'package:args/args.dart'; | 14 import 'package:args/args.dart'; |
| 15 import 'package:gardening/src/bot.dart'; |
16 import 'package:gardening/src/buildbot_data.dart'; | 16 import 'package:gardening/src/buildbot_data.dart'; |
17 import 'package:gardening/src/buildbot_structures.dart'; | 17 import 'package:gardening/src/buildbot_structures.dart'; |
18 import 'package:gardening/src/client.dart'; | |
19 import 'package:gardening/src/util.dart'; | 18 import 'package:gardening/src/util.dart'; |
20 | 19 |
21 void help(ArgParser argParser) { | 20 void help(ArgParser argParser) { |
22 print('Displays the current status of specific tests on the buildbot'); | 21 print('Displays the current status of specific tests on the buildbot'); |
23 print('Only prints output for failing tests.'); | 22 print('Only prints output for failing tests.'); |
24 print('The test-names may be fully qualified (such as in '); | 23 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'); | 24 print('"pkg/front_end/test/token_test") or just be a substring of the fully'); |
26 print(' qualified name.'); | 25 print(' qualified name.'); |
27 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); | 26 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); |
28 print('where options are:'); | 27 print('where options are:'); |
(...skipping 14 matching lines...) Expand all Loading... |
43 | 42 |
44 main(List<String> args) async { | 43 main(List<String> args) async { |
45 ArgParser argParser = createArgParser(); | 44 ArgParser argParser = createArgParser(); |
46 argParser.addOption('group', | 45 argParser.addOption('group', |
47 help: "Restricts the build groups\n" | 46 help: "Restricts the build groups\n" |
48 "to be searched for the results of the given test\n" | 47 "to be searched for the results of the given test\n" |
49 "to those containing the given substring, case insensitive."); | 48 "to those containing the given substring, case insensitive."); |
50 ArgResults argResults = argParser.parse(args); | 49 ArgResults argResults = argParser.parse(args); |
51 processArgResults(argResults); | 50 processArgResults(argResults); |
52 | 51 |
53 BuildbotClient client = argResults['logdog'] | 52 Bot bot = new Bot(logdog: argResults['logdog']); |
54 ? new LogdogBuildbotClient() | |
55 : new HttpBuildbotClient(); | |
56 | 53 |
57 if (argResults.rest.length == 0 || argResults['help']) { | 54 if (argResults.rest.length == 0 || argResults['help']) { |
58 help(argParser); | 55 help(argParser); |
59 if (argResults['help']) return; | 56 if (argResults['help']) return; |
60 exit(1); | 57 exit(1); |
61 } | 58 } |
62 int maxStatusWidth = 0; | 59 int maxStatusWidth = 0; |
63 int maxConfigWidth = 0; | 60 int maxConfigWidth = 0; |
64 | 61 |
65 Map<String, Map<BuildUri, TestStatus>> resultMap = | 62 Map<String, Map<BuildUri, TestStatus>> resultMap = |
66 <String, Map<BuildUri, TestStatus>>{}; | 63 <String, Map<BuildUri, TestStatus>>{}; |
| 64 |
| 65 bool testsFound = false; |
| 66 List<BuildGroup> notFoundGroups = <BuildGroup>[]; |
67 for (BuildGroup group in buildGroups) { | 67 for (BuildGroup group in buildGroups) { |
68 if (argResults['group'] != null && | 68 if (argResults['group'] != null && |
69 !containsIgnoreCase(group.groupName, argResults['group'])) { | 69 !containsIgnoreCase(group.groupName, argResults['group'])) { |
| 70 log('Skipping group $group'); |
70 continue; | 71 continue; |
71 } | 72 } |
72 // TODO(johnniwinther): Support reading a partially completed shard from | 73 // TODO(johnniwinther): Support reading a partially completed shard from |
73 // http, i.e. always use build number `-1`. | 74 // http, i.e. always use build number `-1`. |
74 var resultFutures = | 75 List<BuildUri> uriList = group.createUris(bot.mostRecentBuildNumber); |
75 group.createUris(client.mostRecentBuildNumber).map((uri) { | 76 if (uriList.isEmpty) continue; |
76 log('Fetching $uri'); | 77 print('Fetching ${uriList.first} + ${uriList.length - 1} more ...'); |
77 return client.readResult(uri); | 78 List<BuildResult> results = await bot.readResults(uriList); |
78 }).toList(); | 79 bool testsFoundInGroup = false; |
79 var results = await Future.wait(resultFutures); | |
80 for (BuildResult buildResult in results) { | 80 for (BuildResult buildResult in results) { |
81 bool havePrintedUri = false; | 81 if (buildResult == null) continue; |
82 var buildUri = buildResult.buildUri; | 82 var buildUri = buildResult.buildUri; |
83 if (argResults['verbose']) { | |
84 havePrintedUri = true; | |
85 print('Reading $buildUri'); | |
86 } | |
87 for (TestStatus testStatus in buildResult.results) { | 83 for (TestStatus testStatus in buildResult.results) { |
88 String testName = testStatus.config.testName; | 84 String testName = testStatus.config.testName; |
89 for (String arg in argResults.rest) { | 85 for (String arg in argResults.rest) { |
90 if (testName.contains(arg) || arg.contains(testName)) { | 86 if (testName.contains(arg) || arg.contains(testName)) { |
91 if (!havePrintedUri) { | 87 testsFoundInGroup = true; |
92 havePrintedUri = true; | |
93 print("$buildUri:"); | |
94 } | |
95 resultMap.putIfAbsent(testName, () => {})[buildUri] = testStatus; | 88 resultMap.putIfAbsent(testName, () => {})[buildUri] = testStatus; |
96 maxStatusWidth = max(maxStatusWidth, testStatus.status.length); | 89 maxStatusWidth = max(maxStatusWidth, testStatus.status.length); |
97 maxConfigWidth = | 90 maxConfigWidth = |
98 max(maxConfigWidth, testStatus.config.configName.length); | 91 max(maxConfigWidth, testStatus.config.configName.length); |
99 } | 92 } |
100 } | 93 } |
101 } | 94 } |
102 } | 95 } |
| 96 if (testsFoundInGroup) { |
| 97 testsFound = true; |
| 98 } else { |
| 99 notFoundGroups.add(group); |
| 100 } |
103 } | 101 } |
104 print(''); | 102 print(''); |
105 resultMap.forEach((String testName, Map<BuildUri, TestStatus> statusMap) { | 103 if (testsFound) { |
106 print(testName); | 104 resultMap.forEach((String testName, Map<BuildUri, TestStatus> statusMap) { |
107 statusMap.forEach((BuildUri buildUri, TestStatus status) { | 105 print(testName); |
108 print(' ${padRight(status.status, maxStatusWidth)}: ' | 106 statusMap.forEach((BuildUri buildUri, TestStatus status) { |
109 '${padRight(status.config.configName, maxConfigWidth)} ' | 107 print(' ${padRight(status.status, maxStatusWidth)}: ' |
110 '${buildUri.shortBuildName}'); | 108 '${padRight(status.config.configName, maxConfigWidth)} ' |
| 109 '${buildUri.shortBuildName}'); |
| 110 }); |
111 }); | 111 }); |
112 }); | 112 if (notFoundGroups.isNotEmpty) { |
113 client.close(); | 113 if (argResults.rest.length == 1) { |
| 114 print("Test pattern '${argResults.rest.single}' not found " |
| 115 "in these build bot groups:"); |
| 116 } else { |
| 117 print("Test patterns '${argResults.rest.join("', '")}' not found " |
| 118 "in these build bot groups:"); |
| 119 } |
| 120 for (BuildGroup group in notFoundGroups) { |
| 121 print(' $group'); |
| 122 } |
| 123 } |
| 124 } else { |
| 125 if (argResults.rest.length == 1) { |
| 126 print("Test pattern '${argResults.rest.single}' not found " |
| 127 "in any build bot groups."); |
| 128 } else { |
| 129 print("Test patterns '${argResults.rest.join("', '")}' not found " |
| 130 "in any build bot groups."); |
| 131 } |
| 132 } |
| 133 bot.close(); |
114 } | 134 } |
OLD | NEW |