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

Side by Side Diff: tools/gardening/lib/status_summary.dart

Issue 2751543006: structure gardening tool (Closed)
Patch Set: oops Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « tools/gardening/lib/src/util.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 configurations for all status files in the 'tests' folder that
6 /// mention one of the test names given as argument.
7
8 import 'dart:async';
9 import 'dart:math' hide log;
10 import 'dart:io';
11
12 import 'src/util.dart';
13
14 main(List<String> args) async {
15 if (args.length == 0) {
16 print('Usage: status_summary <test-name1> [<test-name2> ...]');
17 exit(1);
18 }
19 int maxStatusWidth = 0;
20 int maxConfigWidth = 0;
21
22 List<Uri> statusFiles = await findStatusFiles('tests');
23 Map<String, List<StatusFile>> statusMap = <String, List<StatusFile>>{};
24 for (Uri uri in statusFiles) {
25 Map<String, StatusFile> currentMap = <String, StatusFile>{};
26 log('Scanning $uri');
27 String currentConfig = '';
28 for (String line in new File.fromUri(uri).readAsLinesSync()) {
29 if (line.startsWith('[')) {
30 currentConfig = line;
31 } else {
32 int colonIndex = line.indexOf(':');
33 if (colonIndex != -1) {
34 String testName = line.substring(0, colonIndex).trim();
35 int hashIndex = line.indexOf('#', colonIndex + 1);
36 String status;
37 String comment;
38 if (hashIndex != -1) {
39 status = line.substring(colonIndex + 1, hashIndex).trim();
40 comment = line.substring(hashIndex + 1).trim();
41 } else {
42 status = line.substring(colonIndex + 1).trim();
43 comment = '';
44 }
45
46 for (String arg in args) {
47 if (testName.contains(arg) || arg.contains(testName)) {
48 StatusFile statusFile =
49 currentMap.putIfAbsent(testName, () => new StatusFile(uri));
50 statusFile.entries
51 .add(new StatusEntry(currentConfig, status, comment));
52
53 maxStatusWidth = max(maxStatusWidth, status.length);
54 maxConfigWidth = max(maxConfigWidth, currentConfig.length);
55 }
56 }
57 }
58 }
59 }
60 currentMap.forEach((String testName, StatusFile configFile) {
61 statusMap.putIfAbsent(testName, () => <StatusFile>[]).add(configFile);
62 });
63 }
64 statusMap.forEach((String arg, List<StatusFile> statusFiles) {
65 print('$arg');
66 for (StatusFile statusFile in statusFiles) {
67 print(' ${statusFile.uri}');
68 statusFile.entries.forEach((StatusEntry entry) {
69 print(' ${padRight(entry.status, maxStatusWidth)}'
70 ' ${padRight(entry.config, maxConfigWidth)} ${entry.comment}');
71 });
72 }
73 });
74 }
75
76 /// Returns the [Uri]s for all `.status` files in [path] and subdirectories.
77 Future<List<Uri>> findStatusFiles(String path) async {
78 List<Uri> statusFiles = <Uri>[];
79 await for (FileSystemEntity entity
80 in new Directory(path).list(recursive: true)) {
81 if (entity.path.endsWith('.status')) {
82 statusFiles.add(entity.uri);
83 }
84 }
85 return statusFiles;
86 }
87
88 /// The entries collected for a single status file.
89 class StatusFile {
90 final Uri uri;
91 final List<StatusEntry> entries = <StatusEntry>[];
92
93 StatusFile(this.uri);
94 }
95
96 /// A single entry in a status file.
97 class StatusEntry {
98 /// The preceding config line, if any. I.e. the `[...]` line that contained
99 /// this entry, or the empty string otherwise.
100 final String config;
101
102 /// The status of the entry, e.g. `Pass, Slow`.
103 final String status;
104
105 /// The comment after the status, if any.
106 final String comment;
107
108 StatusEntry(this.config, this.status, this.comment);
109
110 String toString() => '$status $config $comment';
111 }
OLDNEW
« no previous file with comments | « tools/gardening/lib/src/util.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698