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

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

Issue 1196413003: Add a LoadSuite class. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 6 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) 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:convert'; 8 import 'dart:convert';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 /// 76 ///
77 /// Many exceptions include the exception class name at the beginning of their 77 /// Many exceptions include the exception class name at the beginning of their
78 /// [toString], so we remove that if it exists. 78 /// [toString], so we remove that if it exists.
79 String getErrorMessage(error) => 79 String getErrorMessage(error) =>
80 error.toString().replaceFirst(_exceptionPrefix, ''); 80 error.toString().replaceFirst(_exceptionPrefix, '');
81 81
82 /// Indent each line in [str] by two spaces. 82 /// Indent each line in [str] by two spaces.
83 String indent(String str) => 83 String indent(String str) =>
84 str.replaceAll(new RegExp("^", multiLine: true), " "); 84 str.replaceAll(new RegExp("^", multiLine: true), " ");
85 85
86 /// A regular expression matching terminal color codes.
87 final _colorCode = new RegExp('\u001b\\[[0-9;]+m');
88
89 /// Returns [str] without any color codes.
90 String withoutColors(String str) => str.replaceAll(_colorCode, '');
91
86 /// A regular expression matching the path to a temporary file used to start an 92 /// A regular expression matching the path to a temporary file used to start an
87 /// isolate. 93 /// isolate.
88 /// 94 ///
89 /// These paths aren't relevant and are removed from stack traces. 95 /// These paths aren't relevant and are removed from stack traces.
90 final _isolatePath = 96 final _isolatePath =
91 new RegExp(r"/test_[A-Za-z0-9]{6}/runInIsolate\.dart$"); 97 new RegExp(r"/test_[A-Za-z0-9]{6}/runInIsolate\.dart$");
92 98
93 /// Returns [stackTrace] converted to a [Chain] with all irrelevant frames 99 /// Returns [stackTrace] converted to a [Chain] with all irrelevant frames
94 /// folded together. 100 /// folded together.
95 /// 101 ///
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 345 }
340 } 346 }
341 347
342 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. 348 /// Returns middleware that nests all requests beneath the URL prefix [beneath].
343 shelf.Middleware nestingMiddleware(String beneath) { 349 shelf.Middleware nestingMiddleware(String beneath) {
344 return (handler) { 350 return (handler) {
345 var pathHandler = new PathHandler()..add(beneath, handler); 351 var pathHandler = new PathHandler()..add(beneath, handler);
346 return pathHandler.handler; 352 return pathHandler.handler;
347 }; 353 };
348 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698