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

Side by Side Diff: lib/src/frontend/throws_matcher.dart

Issue 1124113002: Add a flag controlling how verbose stack traces are. (Closed) Base URL: git@github.com:dart-lang/test.git@master
Patch Set: Created 5 years, 7 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/future_matchers.dart ('k') | lib/src/runner/loader.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.frontend.throws_matcher; 5 library test.frontend.throws_matcher;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:matcher/matcher.dart' hide fail, expect; 9 import 'package:matcher/matcher.dart' hide fail, expect;
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Invoker.current.addOutstandingCallback(); 53 Invoker.current.addOutstandingCallback();
54 // Queue up an asynchronous expectation that validates when the future 54 // Queue up an asynchronous expectation that validates when the future
55 // completes. 55 // completes.
56 item.then((value) { 56 item.then((value) {
57 fail("Expected future to fail, but succeeded with '$value'."); 57 fail("Expected future to fail, but succeeded with '$value'.");
58 }, onError: (error, trace) { 58 }, onError: (error, trace) {
59 if (_matcher == null) return; 59 if (_matcher == null) return;
60 60
61 var reason; 61 var reason;
62 if (trace != null) { 62 if (trace != null) {
63 var stackTrace = terseChain(trace).toString(); 63 var stackTrace = terseChain(trace,
64 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; 64 verbose: Invoker.current.metadata.verboseTrace);
65 stackTrace = " ${stackTrace.toString().replaceAll("\n", "\n ")}";
65 reason = "Actual exception trace:\n$stackTrace"; 66 reason = "Actual exception trace:\n$stackTrace";
66 } 67 }
67 68
68 // Re-run [expect] to get the proper formatting. 69 // Re-run [expect] to get the proper formatting.
69 expect(() => throw error, this, reason: reason); 70 expect(() => throw error, this, reason: reason);
70 }).then((_) => Invoker.current.removeOutstandingCallback()); 71 }).then((_) => Invoker.current.removeOutstandingCallback());
71 // It hasn't failed yet. 72 // It hasn't failed yet.
72 return true; 73 return true;
73 } 74 }
74 75
(...skipping 28 matching lines...) Expand all
103 mismatchDescription 104 mismatchDescription
104 .add('threw ') 105 .add('threw ')
105 .addDescriptionOf(matchState['exception']); 106 .addDescriptionOf(matchState['exception']);
106 if (verbose) { 107 if (verbose) {
107 mismatchDescription.add(' at ').add(matchState['stack'].toString()); 108 mismatchDescription.add(' at ').add(matchState['stack'].toString());
108 } 109 }
109 return mismatchDescription; 110 return mismatchDescription;
110 } 111 }
111 } 112 }
112 } 113 }
OLDNEW
« no previous file with comments | « lib/src/frontend/future_matchers.dart ('k') | lib/src/runner/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698