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

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

Issue 2797253006: Add find_timeouts and caching to tools/gardening (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
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 // Outputs source code for `part` used by `shard2group.dart`. Usage: 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`. 6 // `dart bin/create_shard_groups.dart source.html >lib/src/shard_data.dart`.
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
11 const String groupsStartMark = r"<td class='DevStatus Alt first"; 11 const String groupsStartMark = r"<td class='DevStatus Alt first";
12 const String groupsEndMark = r"<tr class='DevStatusSpacing'>"; 12 const String groupsEndMark = r"<tr class='DevStatusSpacing'>";
13 13
14 List<String> findGroups(List<String> source) { 14 List<String> findGroups(List<String> source) {
15 List<String> result = <String>[]; 15 List<String> result = <String>[];
16 bool started = false; 16 bool started = false;
17 17
18 for (String line in source) { 18 for (String line in source) {
19 if (line.contains(groupsStartMark)) started = true; 19 if (line.contains(groupsStartMark)) started = true;
20 if (started) { 20 if (started) {
21 if (line.contains(groupsEndMark)) break; 21 if (line.contains(groupsEndMark)) break;
22 String trimmed = line.trim(); 22 String trimmed = line.trim();
23 if (!trimmed.startsWith('<')) { 23 if (!trimmed.startsWith('<')) {
24 result.add(trimmed); 24 result.add(trimmed);
25 } 25 }
26 } 26 }
27 } 27 }
(...skipping 16 matching lines...) Expand all
44 if (line.contains(shardsEndMark)) { 44 if (line.contains(shardsEndMark)) {
45 if (shardResult != null) result.add(shardResult); 45 if (shardResult != null) result.add(shardResult);
46 break; 46 break;
47 } 47 }
48 String trimmed = line.trim(); 48 String trimmed = line.trim();
49 int buildersIndex = trimmed.indexOf(shardMark); 49 int buildersIndex = trimmed.indexOf(shardMark);
50 if (buildersIndex >= 0) { 50 if (buildersIndex >= 0) {
51 int quoteIndex = trimmed.indexOf("'", buildersIndex); 51 int quoteIndex = trimmed.indexOf("'", buildersIndex);
52 if (quoteIndex >= 0) { 52 if (quoteIndex >= 0) {
53 // Found a shard name, add it. 53 // Found a shard name, add it.
54 shardResult.add(trimmed.substring( 54 shardResult.add(
55 buildersIndex + shardMark.length, quoteIndex)); 55 trimmed.substring(buildersIndex + shardMark.length, quoteIndex));
56 } else { 56 } else {
57 // Unexpected source formatting, skip. 57 // Unexpected source formatting, skip.
58 } 58 }
59 } else if (trimmed.contains(shardsGroupStartMark)) { 59 } else if (trimmed.contains(shardsGroupStartMark)) {
60 // This is a group separator, switch to next sublist. 60 // This is a group separator, switch to next sublist.
61 if (shardResult != null) result.add(shardResult); 61 if (shardResult != null) result.add(shardResult);
62 shardResult = <String>[]; 62 shardResult = <String>[];
63 } 63 }
64 } 64 }
65 } 65 }
66 return result; 66 return result;
67 } 67 }
68 68
69 main(List<String> args) { 69 main(List<String> args) {
70 if (args.length != 1) { 70 if (args.length != 1) {
71 print('Usage: dart create_shard_groups.dart <darto-source-file>'); 71 print('Usage: dart create_shard_groups.dart <darto-source-file>');
72 exit(1); 72 exit(1);
73 } 73 }
74 74
75 File dartoSourceFile = new File(args[0]); 75 File dartoSourceFile = new File(args[0]);
76 List<String> dartoSource = dartoSourceFile.readAsLinesSync(); 76 List<String> dartoSource = dartoSourceFile.readAsLinesSync();
(...skipping 16 matching lines...) Expand all
93 """); 93 """);
94 for (int i = 0; i < groupCount; i++) { 94 for (int i = 0; i < groupCount; i++) {
95 print(" '${groups[i]}': const <String>["); 95 print(" '${groups[i]}': const <String>[");
96 for (String shard in shards[i]) { 96 for (String shard in shards[i]) {
97 print(" '$shard',"); 97 print(" '$shard',");
98 } 98 }
99 print(" ],"); 99 print(" ],");
100 } 100 }
101 print('};'); 101 print('};');
102 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698