OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 /// Collects the test results for all build bots in [buildGroups] for tests | |
6 /// that mention one of the test names given as argument. | |
7 /// | |
8 /// The results are currently pulled from the second to last build since the | |
9 /// last build might not have completed yet. | |
10 | |
11 import 'dart:math'; | |
12 import 'dart:io'; | |
13 import 'compare_failures.dart'; | |
14 import 'src/buildbot_data.dart'; | |
15 import 'src/buildbot_structures.dart'; | |
16 import 'src/util.dart'; | |
17 | |
18 main(List<String> args) async { | |
19 if (args.length == 0) { | |
20 print('Usage: current_summary <test-name1> [<test-name2> ...]'); | |
21 exit(1); | |
22 } | |
23 int maxStatusWidth = 0; | |
24 int maxConfigWidth = 0; | |
25 | |
26 HttpClient client = new HttpClient(); | |
27 Map<String, Map<BuildUri, TestStatus>> resultMap = | |
28 <String, Map<BuildUri, TestStatus>>{}; | |
29 for (BuildGroup group in buildGroups) { | |
30 // TODO(johnniwinther): Support reading a partially completed shard, i.e. | |
31 // use build number `-1`. | |
32 for (BuildUri buildUri in group.createUris(-2)) { | |
33 print('Reading $buildUri'); | |
34 String text = await readUriAsText(client, buildUri.toUri()); | |
35 for (String line in text.split('\n')) { | |
36 if (line.startsWith('Done ')) { | |
37 List<String> parts = split(line, ['Done ', ' ', ' ', ': ']); | |
38 String testName = parts[3]; | |
39 String configName = parts[1]; | |
40 String archName = parts[2]; | |
41 String status = parts[4]; | |
42 TestStatus testStatus = new TestStatus( | |
43 new TestConfiguration(configName, archName, testName), status); | |
44 for (String arg in args) { | |
45 if (testName.contains(arg) || arg.contains(testName)) { | |
46 resultMap.putIfAbsent(testName, () => {})[buildUri] = testStatus; | |
47 maxStatusWidth = max(maxStatusWidth, status.length); | |
48 maxConfigWidth = max(maxConfigWidth, configName.length); | |
49 } | |
50 } | |
51 } | |
52 } | |
53 } | |
54 } | |
55 print(''); | |
56 resultMap.forEach((String testName, Map<BuildUri, TestStatus> statusMap) { | |
57 print(testName); | |
58 statusMap.forEach((BuildUri buildUri, TestStatus status) { | |
59 print(' ${padRight(status.status, maxStatusWidth)}: ' | |
60 '${padRight(status.config.configName, maxConfigWidth)} ' | |
61 '${buildUri.shortBuildName}'); | |
62 }); | |
63 }); | |
64 client.close(); | |
65 } | |
66 | |
67 /// The result of a single test for a single test step. | |
68 class TestStatus { | |
69 final TestConfiguration config; | |
70 final String status; | |
71 | |
72 TestStatus(this.config, this.status); | |
73 | |
74 String toString() => '$config: $status'; | |
75 } | |
OLD | NEW |