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

Unified Diff: tools/gardening/lib/src/util.dart

Issue 2797253006: Add find_timeouts and caching to tools/gardening (Closed)
Patch Set: Updated cf. comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gardening/lib/src/logdog.dart ('k') | tools/gardening/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gardening/lib/src/util.dart
diff --git a/tools/gardening/lib/src/util.dart b/tools/gardening/lib/src/util.dart
index 278d4e3c29db43e3ba67ceb562614b2e77a1c319..66f986944367fe9fb7bfb4fbf7565bca703e2c0c 100644
--- a/tools/gardening/lib/src/util.dart
+++ b/tools/gardening/lib/src/util.dart
@@ -6,6 +6,10 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
+import 'package:args/args.dart';
+
+import 'cache.dart';
+
/// Split [text] using [infixes] as infix markers.
List<String> split(String text, List<String> infixes) {
List<String> result = <String>[];
@@ -27,9 +31,15 @@ String padRight(String text, int length) {
return text;
}
-const bool LOG = const bool.fromEnvironment('LOG', defaultValue: false);
+/// Pad [text] with spaces to the left to fit [length].
+String padLeft(String text, int length) {
+ if (text.length < length) return '${' ' * (length - text.length)}${text}';
+ return text;
+}
+
+bool LOG = const bool.fromEnvironment('LOG', defaultValue: false);
-void log(String text) {
+void log(Object text) {
if (LOG) print(text);
}
@@ -39,3 +49,22 @@ Future<String> readUriAsText(HttpClient client, Uri uri) async {
HttpClientResponse response = await request.close();
return await response.transform(UTF8.decoder).join();
}
+
+ArgParser createArgParser() {
+ ArgParser argParser = new ArgParser();
+ argParser.addFlag('verbose',
+ abbr: 'v', negatable: false, help: "Turn on logging output.");
+ argParser.addOption('cache',
+ help: "Use <dir> for caching test output.\n"
+ "Defaults to 'temp/gardening-cache/'.");
+ return argParser;
+}
+
+void processArgResults(ArgResults argResults) {
+ if (argResults['verbose']) {
+ LOG = true;
+ }
+ if (argResults['cache'] != null) {
+ cache.base = Uri.base.resolve('${argResults['cache']}/');
+ }
+}
« no previous file with comments | « tools/gardening/lib/src/logdog.dart ('k') | tools/gardening/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698