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

Side by Side Diff: client/testing/unittest/shared.dart

Issue 8586041: Fix to workaround non-propagation of exception stack-traces by dartc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Description text of the current test group. If multiple groups are nested, 6 * Description text of the current test group. If multiple groups are nested,
7 * this will contain all of their text concatenated. 7 * this will contain all of their text concatenated.
8 */ 8 */
9 String _currentGroup = ''; 9 String _currentGroup = '';
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 _platformDefer(() { 153 _platformDefer(() {
154 assert (_currentTest == 0); 154 assert (_currentTest == 0);
155 _nextBatch(); 155 _nextBatch();
156 }); 156 });
157 } 157 }
158 158
159 /** Runs a single test. */ 159 /** Runs a single test. */
160 _runTest(TestCase testCase) { 160 _runTest(TestCase testCase) {
161 try { 161 try {
162 // TODO(sigmund): remove this declaration once dartc supports trapping error
163 // traces.
164 var trace = '';
165 _callbacksCalled = 0; 162 _callbacksCalled = 0;
166 _state = _RUNNING_TEST; 163 _state = _RUNNING_TEST;
167 164
168 testCase.test(); 165 testCase.test();
169 166
170 if (_state != _UNCAUGHT_ERROR) { 167 if (_state != _UNCAUGHT_ERROR) {
171 if (testCase.callbacks == _callbacksCalled) { 168 if (testCase.callbacks == _callbacksCalled) {
172 testCase.pass(); 169 testCase.pass();
173 } 170 }
174 } 171 }
175 172
176 } catch (ExpectException e, var trace) { 173 } catch (ExpectException e, var trace) {
177 if (_state != _UNCAUGHT_ERROR) { 174 if (_state != _UNCAUGHT_ERROR) {
178 testCase.fail(e.message, trace.toString()); 175 //TODO remove guard once dartc reliably propagates traces
Siggi Cherem (dart-lang) 2011/11/17 22:03:59 TODO -> TODO(pquitslund) or TODO(sigmund)
176 testCase.fail(e.message, trace == null ? '' : trace.toString());
179 } 177 }
180 } catch (var e, var trace) { 178 } catch (var e, var trace) {
181 if (_state != _UNCAUGHT_ERROR) { 179 if (_state != _UNCAUGHT_ERROR) {
182 testCase.error('Caught ${e}', trace.toString()); 180 //TODO remove guard once dartc reliably propagates traces
181 testCase.error('Caught ${e}', trace == null ? '' : trace.toString());
183 } 182 }
184 } finally { 183 } finally {
185 _state = _READY; 184 _state = _READY;
186 } 185 }
187 } 186 }
188 187
189 /** 188 /**
190 * Runs a batch of tests, yielding whenever an asynchronous test starts 189 * Runs a batch of tests, yielding whenever an asynchronous test starts
191 * running. Tests will resume executing when such asynchronous test calls 190 * running. Tests will resume executing when such asynchronous test calls
192 * [done] or if it fails with an exception. 191 * [done] or if it fails with an exception.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 343 }
345 344
346 void error(String message, String stackTrace) { 345 void error(String message, String stackTrace) {
347 result = _ERROR; 346 result = _ERROR;
348 this.message = message; 347 this.message = message;
349 this.stackTrace = stackTrace; 348 this.stackTrace = stackTrace;
350 } 349 }
351 } 350 }
352 351
353 typedef void TestFunction(); 352 typedef void TestFunction();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698