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

Side by Side Diff: pkg/unittest/unittest.dart

Issue 10909123: Fix issue 2933 - if an exception is thrown before we start the first test, but after the testcase i… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | 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 * A library for writing dart unit tests. 6 * A library for writing dart unit tests.
7 * 7 *
8 * To import this library, specify the relative path to 8 * To import this library, specify the relative path to
9 * pkg/unittest/unittest.dart. 9 * pkg/unittest/unittest.dart.
10 * 10 *
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // Groups can be nested, so we need to preserve the current 573 // Groups can be nested, so we need to preserve the current
574 // settings for test setup/teardown. 574 // settings for test setup/teardown.
575 Function parentSetup = _testSetup; 575 Function parentSetup = _testSetup;
576 Function parentTeardown = _testTeardown; 576 Function parentTeardown = _testTeardown;
577 577
578 try { 578 try {
579 _testSetup = null; 579 _testSetup = null;
580 _testTeardown = null; 580 _testTeardown = null;
581 body(); 581 body();
582 } catch (e, trace) { 582 } catch (e, trace) {
583 _reportTestError(e.toString(), trace == null ? '' : trace.toString()); 583 var stack = (trace == null) ? '' : ': ${trace.toString()}';
584 _uncaughtErrorMessage = "${e.toString()}$stack";
584 } finally { 585 } finally {
585 // Now that the group is over, restore the previous one. 586 // Now that the group is over, restore the previous one.
586 _currentGroup = parentGroup; 587 _currentGroup = parentGroup;
587 _testSetup = parentSetup; 588 _testSetup = parentSetup;
588 _testTeardown = parentTeardown; 589 _testTeardown = parentTeardown;
589 } 590 }
590 } 591 }
591 592
592 /** 593 /**
593 * Register a [setUp] function for a test [group]. This function will 594 * Register a [setUp] function for a test [group]. This function will
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 _handleCallbackFunctionComplete(); 656 _handleCallbackFunctionComplete();
656 } 657 }
657 658
658 /** 659 /**
659 * Utility function that can be used to notify the test framework that an 660 * Utility function that can be used to notify the test framework that an
660 * error was caught outside of this library. 661 * error was caught outside of this library.
661 */ 662 */
662 void _reportTestError(String msg, String trace) { 663 void _reportTestError(String msg, String trace) {
663 if (_currentTest < _tests.length) { 664 if (_currentTest < _tests.length) {
664 final testCase = _tests[_currentTest]; 665 final testCase = _tests[_currentTest];
665 testCase.error(msg, trace); 666 if (testCase.running) {
Siggi Cherem (dart-lang) 2012/09/07 19:27:37 this part should probably go away? (seems that you
666 if (testCase.callbackFunctionsOutstanding > 0) { 667 testCase.error(msg, trace);
667 _nextTestCase(); 668 if (testCase.callbackFunctionsOutstanding > 0) {
669 _nextTestCase();
670 }
671 return;
668 } 672 }
669 } else {
670 _uncaughtErrorMessage = "$msg: $trace";
671 } 673 }
674 _uncaughtErrorMessage = "$msg: $trace";
672 } 675 }
673 676
674 /** Runs [callback] at the end of the event loop. */ 677 /** Runs [callback] at the end of the event loop. */
675 _defer(void callback()) { 678 _defer(void callback()) {
676 // Exploit isolate ports as a platform-independent mechanism to queue a 679 // Exploit isolate ports as a platform-independent mechanism to queue a
677 // message at the end of the event loop. 680 // message at the end of the event loop.
678 // TODO(sigmund): expose this functionality somewhere in our libraries. 681 // TODO(sigmund): expose this functionality somewhere in our libraries.
679 final port = new ReceivePort(); 682 final port = new ReceivePort();
680 port.receive((msg, reply) { 683 port.receive((msg, reply) {
681 callback(); 684 callback();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 867 }
865 868
866 /** Enable a test by ID. */ 869 /** Enable a test by ID. */
867 void enableTest(int testId) => _setTestEnabledState(testId, true); 870 void enableTest(int testId) => _setTestEnabledState(testId, true);
868 871
869 /** Disable a test by ID. */ 872 /** Disable a test by ID. */
870 void disableTest(int testId) => _setTestEnabledState(testId, false); 873 void disableTest(int testId) => _setTestEnabledState(testId, false);
871 874
872 /** Signature for a test function. */ 875 /** Signature for a test function. */
873 typedef void TestFunction(); 876 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