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:math'; |
12 import 'dart:io'; | 12 import 'dart:io'; |
13 | 13 |
14 import 'package:args/args.dart'; | 14 import 'package:args/args.dart'; |
15 import 'package:gardening/src/buildbot_data.dart'; | 15 import 'package:gardening/src/buildbot_data.dart'; |
16 import 'package:gardening/src/buildbot_loading.dart'; | 16 import 'package:gardening/src/buildbot_loading.dart'; |
17 import 'package:gardening/src/buildbot_structures.dart'; | 17 import 'package:gardening/src/buildbot_structures.dart'; |
| 18 import 'package:gardening/src/client.dart'; |
18 import 'package:gardening/src/util.dart'; | 19 import 'package:gardening/src/util.dart'; |
19 | 20 |
20 main(List<String> args) async { | 21 main(List<String> args) async { |
21 ArgParser argParser = createArgParser(); | 22 ArgParser argParser = createArgParser(); |
22 ArgResults argResults = argParser.parse(args); | 23 ArgResults argResults = argParser.parse(args); |
23 processArgResults(argResults); | 24 processArgResults(argResults); |
| 25 |
| 26 BuildbotClient client = argResults['logdog'] |
| 27 ? new LogdogBuildbotClient() |
| 28 : new HttpBuildbotClient(); |
| 29 |
24 if (argResults.rest.length == 0) { | 30 if (argResults.rest.length == 0) { |
25 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); | 31 print('Usage: current_summary [options] <test-name1> [<test-name2> ...]'); |
26 print('where options are:'); | 32 print('where options are:'); |
27 print(argParser.usage); | 33 print(argParser.usage); |
28 exit(1); | 34 exit(1); |
29 } | 35 } |
30 int maxStatusWidth = 0; | 36 int maxStatusWidth = 0; |
31 int maxConfigWidth = 0; | 37 int maxConfigWidth = 0; |
32 | 38 |
33 HttpClient client = new HttpClient(); | |
34 Map<String, Map<BuildUri, TestStatus>> resultMap = | 39 Map<String, Map<BuildUri, TestStatus>> resultMap = |
35 <String, Map<BuildUri, TestStatus>>{}; | 40 <String, Map<BuildUri, TestStatus>>{}; |
36 for (BuildGroup group in buildGroups) { | 41 for (BuildGroup group in buildGroups) { |
37 // TODO(johnniwinther): Support reading a partially completed shard, i.e. | 42 // TODO(johnniwinther): Support reading a partially completed shard, i.e. |
38 // use build number `-1`. | 43 // use build number `-1`. |
39 for (BuildUri buildUri in group.createUris(-2)) { | 44 for (BuildUri buildUri in group.createUris(client.mostRecentBuildNumber)) { |
40 print('Reading $buildUri'); | 45 print('Reading $buildUri'); |
41 BuildResult buildResult = await readBuildResult(client, buildUri); | 46 BuildResult buildResult = await client.readResult(buildUri); |
42 for (TestStatus testStatus in buildResult.results) { | 47 for (TestStatus testStatus in buildResult.results) { |
43 String testName = testStatus.config.testName; | 48 String testName = testStatus.config.testName; |
44 for (String arg in argResults.rest) { | 49 for (String arg in argResults.rest) { |
45 if (testName.contains(arg) || arg.contains(testName)) { | 50 if (testName.contains(arg) || arg.contains(testName)) { |
46 resultMap.putIfAbsent(testName, () => {})[buildUri] = testStatus; | 51 resultMap.putIfAbsent(testName, () => {})[buildUri] = testStatus; |
47 maxStatusWidth = max(maxStatusWidth, testStatus.status.length); | 52 maxStatusWidth = max(maxStatusWidth, testStatus.status.length); |
48 maxConfigWidth = | 53 maxConfigWidth = |
49 max(maxConfigWidth, testStatus.config.configName.length); | 54 max(maxConfigWidth, testStatus.config.configName.length); |
50 } | 55 } |
51 } | 56 } |
52 } | 57 } |
53 } | 58 } |
54 } | 59 } |
55 print(''); | 60 print(''); |
56 resultMap.forEach((String testName, Map<BuildUri, TestStatus> statusMap) { | 61 resultMap.forEach((String testName, Map<BuildUri, TestStatus> statusMap) { |
57 print(testName); | 62 print(testName); |
58 statusMap.forEach((BuildUri buildUri, TestStatus status) { | 63 statusMap.forEach((BuildUri buildUri, TestStatus status) { |
59 print(' ${padRight(status.status, maxStatusWidth)}: ' | 64 print(' ${padRight(status.status, maxStatusWidth)}: ' |
60 '${padRight(status.config.configName, maxConfigWidth)} ' | 65 '${padRight(status.config.configName, maxConfigWidth)} ' |
61 '${buildUri.shortBuildName}'); | 66 '${buildUri.shortBuildName}'); |
62 }); | 67 }); |
63 }); | 68 }); |
64 client.close(); | 69 client.close(); |
65 } | 70 } |
OLD | NEW |