Chromium Code Reviews| Index: pkg/scheduled_test/lib/src/utils.dart |
| diff --git a/pkg/scheduled_test/lib/src/utils.dart b/pkg/scheduled_test/lib/src/utils.dart |
| index 7daac77553b13dea55e76cf04318a1fafeb0c29f..85ad898350ac9bafaddbf8174f7447a2454c183a 100644 |
| --- a/pkg/scheduled_test/lib/src/utils.dart |
| +++ b/pkg/scheduled_test/lib/src/utils.dart |
| @@ -31,6 +31,9 @@ void chainToCompleter(Future future, Completer completer) { |
| future.then(completer.complete, onError: completer.completeError); |
| } |
| +/// Like [Future.sync], but wraps the Future in [Chain.track] as well. |
| +Future syncFuture(callback()) => Chain.track(new Future.sync(callback)); |
|
Bob Nystrom
2013/12/03 22:24:47
Why is this needed? Does this not go through the z
nweiz
2013/12/03 22:34:32
No; Future.sync has its own try/catch that applies
|
| + |
| /// Prepends each line in [text] with [prefix]. If [firstPrefix] is passed, the |
| /// first line is prefixed with that instead. |
| String prefixLines(String text, {String prefix: '| ', String firstPrefix}) { |
| @@ -72,10 +75,6 @@ bool orderedIterableEquals(Iterable iterable1, Iterable iterable2) { |
| } |
| } |
| -// TODO(nweiz): remove this when issue 8731 is fixed. |
| -/// Returns a [Stream] that will immediately emit [error] and then close. |
| -Stream errorStream(error) => new Future.error(error).asStream(); |
| - |
| /// Returns a buffered stream that will emit the same values as the stream |
| /// returned by [future] once [future] completes. |
| /// |
| @@ -127,12 +126,11 @@ Stream futureStream(Future<Stream> future, {bool broadcast: false}) { |
| /// |
| /// If the [StreamIterator] has no elements, the result is a state error. |
| Future<String> streamIteratorFirst(StreamIterator<String> streamIterator) { |
| - StackTrace stackTrace = new Trace.current(); |
| return streamIterator.moveNext().then((hasNext) { |
| if (hasNext) { |
| return streamIterator.current; |
| } else { |
| - return new Future.error(new StateError("No elements"), stackTrace); |
| + throw new StateError("No elements"); |
| } |
| }); |
| } |
| @@ -233,8 +231,10 @@ bool fullMatch(String string, Pattern pattern) { |
| /// Returns a string representation of [trace] that has the core and test frames |
| /// folded together. |
| String terseTraceString(StackTrace trace) { |
| - return new Trace.from(trace).terse.foldFrames((frame) { |
| - return frame.package == 'scheduled_test' || frame.package == 'unittest' || |
| - frame.isCore; |
| - }).toString().trim(); |
| + return new Chain(new Chain.forTrace(trace).traces.map((trace) { |
| + return trace.foldFrames((frame) { |
| + return frame.package == 'scheduled_test' || frame.package == 'unittest' || |
| + frame.package == 'stack_trace' || frame.isCore; |
|
Bob Nystrom
2013/12/03 22:24:47
How do you feel about wrapping each to its own lin
nweiz
2013/12/03 22:34:32
Done.
|
| + }); |
| + })).terse.toString().trim(); |
| } |