| OLD | NEW |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 /// A regular expression matching the path to a temporary file used to start an | 82 /// A regular expression matching the path to a temporary file used to start an |
| 83 /// isolate. | 83 /// isolate. |
| 84 /// | 84 /// |
| 85 /// These paths aren't relevant and are removed from stack traces. | 85 /// These paths aren't relevant and are removed from stack traces. |
| 86 final _isolatePath = | 86 final _isolatePath = |
| 87 new RegExp(r"/test_[A-Za-z0-9]{6}/runInIsolate\.dart$"); | 87 new RegExp(r"/test_[A-Za-z0-9]{6}/runInIsolate\.dart$"); |
| 88 | 88 |
| 89 /// Returns [stackTrace] converted to a [Chain] with all irrelevant frames | 89 /// Returns [stackTrace] converted to a [Chain] with all irrelevant frames |
| 90 /// folded together. | 90 /// folded together. |
| 91 Chain terseChain(StackTrace stackTrace) { | 91 /// |
| 92 /// If [verbose] is `true`, returns the chain for [stackTrace] unmodified. |
| 93 Chain terseChain(StackTrace stackTrace, {bool verbose: false}) { |
| 94 if (verbose) return new Chain.forTrace(stackTrace); |
| 92 return new Chain.forTrace(stackTrace).foldFrames((frame) { | 95 return new Chain.forTrace(stackTrace).foldFrames((frame) { |
| 93 if (frame.package == 'test') return true; | 96 if (frame.package == 'test') return true; |
| 94 | 97 |
| 95 // Filter out frames from our isolate bootstrap as well. | 98 // Filter out frames from our isolate bootstrap as well. |
| 96 if (frame.uri.scheme != 'file') return false; | 99 if (frame.uri.scheme != 'file') return false; |
| 97 return frame.uri.path.contains(_isolatePath); | 100 return frame.uri.path.contains(_isolatePath); |
| 98 }, terse: true); | 101 }, terse: true); |
| 99 } | 102 } |
| 100 | 103 |
| 101 /// Flattens nested [Iterable]s inside an [Iterable] into a single [List] | 104 /// Flattens nested [Iterable]s inside an [Iterable] into a single [List] |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 317 } |
| 315 } | 318 } |
| 316 | 319 |
| 317 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. | 320 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. |
| 318 shelf.Middleware nestingMiddleware(String beneath) { | 321 shelf.Middleware nestingMiddleware(String beneath) { |
| 319 return (handler) { | 322 return (handler) { |
| 320 var pathHandler = new PathHandler()..add(beneath, handler); | 323 var pathHandler = new PathHandler()..add(beneath, handler); |
| 321 return pathHandler.handler; | 324 return pathHandler.handler; |
| 322 }; | 325 }; |
| 323 } | 326 } |
| OLD | NEW |