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

Side by Side Diff: tools/gardening/bin/create_shard_groups.dart

Issue 2973653002: Updated various gardening data, and ignoring gardening/temp. (Closed)
Patch Set: Now finishing quickly in summary.dart if only doing "help" Created 3 years, 5 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/bin/create_shard_data.dart ('k') | tools/gardening/bin/summary.dart » ('j') | 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 // Outputs source code for `part` used by `shard2group.dart`. Usage:
6 // `dart bin/create_shard_groups.dart source.html >lib/src/shard_data.dart`.
7
8 import 'dart:io';
9 import 'dart:math' as math;
10
11 const String groupsStartMark = r"<td class='DevStatus Alt first";
12 const String groupsEndMark = r"<tr class='DevStatusSpacing'>";
13
14 List<String> findGroups(List<String> source) {
15 List<String> result = <String>[];
16 bool started = false;
17
18 for (String line in source) {
19 if (line.contains(groupsStartMark)) started = true;
20 if (started) {
21 if (line.contains(groupsEndMark)) break;
22 String trimmed = line.trim();
23 if (!trimmed.startsWith('<')) {
24 result.add(trimmed);
25 }
26 }
27 }
28 return result;
29 }
30
31 const String shardsStartMark = groupsEndMark;
32 const String shardsEndMark = r"<td class='DevStatusBox";
33 const String shardsGroupStartMark = r"<td class='DevSlave Alt";
34 const String shardMark = '/builders/';
35
36 List<List<String>> findShards(List<String> source) {
37 List<List<String>> result = <List<String>>[];
38 List<String> shardResult;
39 bool started = false;
40
41 for (String line in source) {
42 if (line.contains(shardsStartMark)) started = true;
43 if (started) {
44 if (line.contains(shardsEndMark)) {
45 if (shardResult != null) result.add(shardResult);
46 break;
47 }
48 String trimmed = line.trim();
49 int buildersIndex = trimmed.indexOf(shardMark);
50 if (buildersIndex >= 0) {
51 int quoteIndex = trimmed.indexOf("'", buildersIndex);
52 if (quoteIndex >= 0) {
53 // Found a shard name, add it.
54 shardResult.add(
55 trimmed.substring(buildersIndex + shardMark.length, quoteIndex));
56 } else {
57 // Unexpected source formatting, skip.
58 }
59 } else if (trimmed.contains(shardsGroupStartMark)) {
60 // This is a group separator, switch to next sublist.
61 if (shardResult != null) result.add(shardResult);
62 shardResult = <String>[];
63 }
64 }
65 }
66 return result;
67 }
68
69 void help() {
70 print("Generates the 'shard_data.dart' file that is used by our gardening");
71 print("tools. This tool needs to be run when the buildbot configuration");
72 print("(shard) changes\n");
73 print('Usage: dart create_shard_groups.dart <darto-source-file>');
74 }
75
76 main(List<String> args) {
77 if (args.length != 1 || args[0] == "--help") {
78 help();
79 if (args.length == 1) return;
80 exit(1);
81 }
82
83 File dartoSourceFile = new File(args[0]);
84 List<String> dartoSource = dartoSourceFile.readAsLinesSync();
85
86 List<String> groups = findGroups(dartoSource);
87 List<List<String>> shards = findShards(dartoSource);
88 int groupCount = math.min(groups.length, shards.length);
89
90 // Print the resulting Dart declaration.
91 print("""
92 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
93 // for details. All rights reserved. Use of this source code is governed by a
94 // BSD-style license that can be found in the LICENSE file.
95 //
96 // ----- Generated by create_shard_groups.dart, do not edit! -----
97
98 part of gardening.shard2group;
99
100 const Map<String, List<String>> shardGroups = const {""");
101 for (int i = 0; i < groupCount; i++) {
102 print(" '${groups[i]}': const <String>[");
103 for (String shard in shards[i]) {
104 print(" '$shard',");
105 }
106 print(" ],");
107 }
108 print('};');
109 }
OLDNEW
« no previous file with comments | « tools/gardening/bin/create_shard_data.dart ('k') | tools/gardening/bin/summary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698