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

Side by Side Diff: lib/src/utils.dart

Issue 1090513002: Support configuring timeouts per-test and -group. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 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
« no previous file with comments | « lib/src/frontend/timeout.dart ('k') | lib/test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library test.utils; 5 library test.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:crypto/crypto.dart'; 10 import 'package:crypto/crypto.dart';
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Otherwise truncate to return the trailing text, but attempt to start at 142 // Otherwise truncate to return the trailing text, but attempt to start at
143 // the beginning of a word. 143 // the beginning of a word.
144 var result = text.substring(text.length - maxLength + 4); 144 var result = text.substring(text.length - maxLength + 4);
145 var firstSpace = result.indexOf(' '); 145 var firstSpace = result.indexOf(' ');
146 if (firstSpace > 0) { 146 if (firstSpace > 0) {
147 result = result.substring(firstSpace); 147 result = result.substring(firstSpace);
148 } 148 }
149 return '...$result'; 149 return '...$result';
150 } 150 }
151 151
152 /// Returns a human-friendly representation of [duration].
153 String niceDuration(Duration duration) {
154 var minutes = duration.inMinutes;
155 var seconds = duration.inSeconds % 59;
156 var decaseconds = (duration.inMilliseconds % 1000) ~/ 100;
157
158 var buffer = new StringBuffer();
159 if (minutes != 0) buffer.write("$minutes minutes");
160
161 if (minutes == 0 || seconds != 0) {
162 if (minutes != 0) buffer.write(", ");
163 buffer.write(seconds);
164 if (decaseconds != 0) buffer.write(".$decaseconds");
165 buffer.write(" seconds");
166 }
167
168 return buffer.toString();
169 }
170
152 /// Merges [streams] into a single stream that emits events from all sources. 171 /// Merges [streams] into a single stream that emits events from all sources.
153 Stream mergeStreams(Iterable<Stream> streamIter) { 172 Stream mergeStreams(Iterable<Stream> streamIter) {
154 var streams = streamIter.toList(); 173 var streams = streamIter.toList();
155 174
156 var subscriptions = new Set(); 175 var subscriptions = new Set();
157 var controller; 176 var controller;
158 controller = new StreamController(sync: true, onListen: () { 177 controller = new StreamController(sync: true, onListen: () {
159 for (var stream in streams) { 178 for (var stream in streams) {
160 var subscription; 179 var subscription;
161 subscription = stream.listen( 180 subscription = stream.listen(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 273 }
255 } 274 }
256 275
257 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. 276 /// Returns middleware that nests all requests beneath the URL prefix [beneath].
258 shelf.Middleware nestingMiddleware(String beneath) { 277 shelf.Middleware nestingMiddleware(String beneath) {
259 return (handler) { 278 return (handler) {
260 var pathHandler = new PathHandler()..add(beneath, handler); 279 var pathHandler = new PathHandler()..add(beneath, handler);
261 return pathHandler.handler; 280 return pathHandler.handler;
262 }; 281 };
263 } 282 }
OLDNEW
« no previous file with comments | « lib/src/frontend/timeout.dart ('k') | lib/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698